Solved

Let the workspace do something if there is eventually no feature coming out of a port?


Badge

Hi! I am writing a translation, and thinking about how to handle an unexpected situation while there is eventually no feature going through a pipe. For example, when a reader or a http call returns nothing, it usually indicates some error or rare situation, such that I may want a email to be sent or some message to be logged.

I tried but couldn't find a simple way to do that. Except a way that seems unnecessarily complicated:

  • fire a feature by a Creator,
  • pipe it into the requestor of a FeatureMerger,
  • let the port to be checked connect to the supplier port of FeatureMerger,
  • connect the NotMerged port of the FeatureMerger to the "rare case" handling transformer

However, this method seems unnecessarily complicated to me if I only want to do simple handling such as writing a log message. Is there easier way?

Thank you!

icon

Best answer by geosander 6 October 2017, 23:50

View original

11 replies

Badge

You could install the NoFeaturesTester custom transformer from FME Hub. That might work for you.

Badge

You could install the NoFeaturesTester custom transformer from FME Hub. That might work for you.

I downloaded the NoFeaturesTester custom transformer and looked at its logic. It should work, but it adds a bit statistic work to the workspace. Is there something simpler?

 

 

Badge

I have made a PythonCaller variant once with only a few lines of code (initialize with a self.count attribute, increment count on incoming features in input method, check if self.count == 0 on close method, if it is, create output feature). Could share it tomorrow, but really need to go to bed now...

Badge

I have made a PythonCaller variant once with only a few lines of code (initialize with a self.count attribute, increment count on incoming features in input method, check if self.count == 0 on close method, if it is, create output feature). Could share it tomorrow, but really need to go to bed now...

 

Thank you @sander

 

Badge

 

Thank you @sander

 

Hi @sui_huang,

 

Sorry for the delay.. I have included a linked non-blocking custom transformer that should do what you want without too much overhead. The method described above used to work in Python 2.7 on older versions of FME, but I noticed that it didn't work anymore on Python 3.4 in FME 2017.1.

 

The attached FMX works for both Python versions and was created with FME 2017.1. Let me know if this is a problem (since you tagged this question with 2016.1) and please provide your FME build number, then I'll post an FMX that hopefully does work for you.

 

Badge

Hi @sui_huang,

 

Sorry for the delay.. I have included a linked non-blocking custom transformer that should do what you want without too much overhead. The method described above used to work in Python 2.7 on older versions of FME, but I noticed that it didn't work anymore on Python 3.4 in FME 2017.1.

 

The attached FMX works for both Python versions and was created with FME 2017.1. Let me know if this is a problem (since you tagged this question with 2016.1) and please provide your FME build number, then I'll post an FMX that hopefully does work for you.

 

Hi Sander, I downloaded and saw the custom transformer. I think it should work if I specify the dummy attribute name in the creator. It has less transformers than the NoFeaturesTester and I think the python script will make it more efficient than NoFeaturesTester.

 

 

Userlevel 4

Hi @sui_huang,

 

Sorry for the delay.. I have included a linked non-blocking custom transformer that should do what you want without too much overhead. The method described above used to work in Python 2.7 on older versions of FME, but I noticed that it didn't work anymore on Python 3.4 in FME 2017.1.

 

The attached FMX works for both Python versions and was created with FME 2017.1. Let me know if this is a problem (since you tagged this question with 2016.1) and please provide your FME build number, then I'll post an FMX that hopefully does work for you.

 

Nice solution with the PythonCaller Sander!
Badge

Hi @sui_huang,

 

Sorry for the delay.. I have included a linked non-blocking custom transformer that should do what you want without too much overhead. The method described above used to work in Python 2.7 on older versions of FME, but I noticed that it didn't work anymore on Python 3.4 in FME 2017.1.

 

The attached FMX works for both Python versions and was created with FME 2017.1. Let me know if this is a problem (since you tagged this question with 2016.1) and please provide your FME build number, then I'll post an FMX that hopefully does work for you.

 

 

I accept both answers (the NoFeaturesTester and your customer transformer with Python), because they are good choice in some circumstances. The NoFeaturesTester will work well when user want to make it work quickly and not so concerned about performance.

 

Userlevel 4
I downloaded the NoFeaturesTester custom transformer and looked at its logic. It should work, but it adds a bit statistic work to the workspace. Is there something simpler?

 

 

There are several versions of the NoFeaturesTester and notably the first versions used the StatisticsCalculator.

 

Look for versions starting from 2016-10-28, it got a pretty good facelift then and no longer uses the StatisticsCalculator.
Badge

Hi @sui_huang,

 

Sorry for the delay.. I have included a linked non-blocking custom transformer that should do what you want without too much overhead. The method described above used to work in Python 2.7 on older versions of FME, but I noticed that it didn't work anymore on Python 3.4 in FME 2017.1.

 

The attached FMX works for both Python versions and was created with FME 2017.1. Let me know if this is a problem (since you tagged this question with 2016.1) and please provide your FME build number, then I'll post an FMX that hopefully does work for you.

 

Thanks @david_r and @sui_huang!
Badge
There are several versions of the NoFeaturesTester and notably the first versions used the StatisticsCalculator.

 

Look for versions starting from 2016-10-28, it got a pretty good facelift then and no longer uses the StatisticsCalculator.
@david_r I double checked. You are right. The reason I saw the StatisticsCalculator maybe because I searched this custom transformer in FME 2016.1 and it downloaded the old version for me ...

 

Reply