Skip to main content
Solved

VariableRetriever seemingly inconsistent behavior? Sometimes works and sometimes doesn't.

  • December 13, 2022
  • 15 replies
  • 103 views

antoine.prince
Contributor
Forum|alt.badge.img+4

Depending on what sections of my FME workflow I run, the VariableRetriever returns with the expected value or returns empty. If I run with the large selection (in red), it does not work. If I run with the small selection (in blue), it does work. Can someone explain the VariableRetriever seemingly inconsistent behavior?

 

See attached screenshots for details.

 

 

Best answer by dustin

Great answers thus far concerning VaribleSetter/VariableRetriever...

Looking at your use-case specifically, you could use the following code in a scripted parameter to return the current date, which could be called in the workspace using a ParameterFetcher (or directly in your other transformers)

from datetime import datetime
 
date_time=datetime.today().strftime('%Y%m%d')
 
return(date_time)

 

This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

15 replies

david_r
Celebrity
  • 8391 replies
  • December 13, 2022

Be aware that the VariableRetriever / VariableSetter transformers don't support partial runs using feature caching.


nielsgerrits
VIP
Forum|alt.badge.img+60
  • 2938 replies
  • December 13, 2022

Using VariableSetters / VariableRetrievers combined with FeatureCaching does not work well for me.

I'm using FeatureMergers with a value "1" in the requestor and supplier when I need this stuff and want to use FeatureCaching, but not sure if that is the best alternative.

2022-12-13_16h15_48


antoine.prince
Contributor
Forum|alt.badge.img+4
  • Author
  • Contributor
  • 10 replies
  • December 13, 2022

Using VariableSetters / VariableRetrievers combined with FeatureCaching does not work well for me.

I'm using FeatureMergers with a value "1" in the requestor and supplier when I need this stuff and want to use FeatureCaching, but not sure if that is the best alternative.

2022-12-13_16h15_48

I am trying to develop an approach to eventually use on much more complex FME workflow and was hoping to not use connected merger like the FeatureMerger. I really liked the elegant approach of the VariableSetter/VariableRetriever which allowed me to pass a variable without having to connect transformers. Thanks for the proposition, I will consider it.


antoine.prince
Contributor
Forum|alt.badge.img+4
  • Author
  • Contributor
  • 10 replies
  • December 13, 2022

Be aware that the VariableRetriever / VariableSetter transformers don't support partial runs using feature caching.

I have the same problem when I run the whole workflow either with or without feature caching activated.


david_r
Celebrity
  • 8391 replies
  • December 13, 2022

I have the same problem when I run the whole workflow either with or without feature caching activated.

In that case it might be a question of feature order, i.e. in which order the Setter and Retriever is triggered. Try setting breakpoints before each transformer and see what happens.


david_r
Celebrity
  • 8391 replies
  • December 13, 2022

Using VariableSetters / VariableRetrievers combined with FeatureCaching does not work well for me.

I'm using FeatureMergers with a value "1" in the requestor and supplier when I need this stuff and want to use FeatureCaching, but not sure if that is the best alternative.

2022-12-13_16h15_48

I've just created an Idea for having the VariableSetter / VariableRetriever support feature caching, feel free to vote for visibility: https://community.safe.com/s/bridea/a0rDm000000CbI9IAK/variableretriever-variablesetter-should-play-nice-with-feature-caching


antoine.prince
Contributor
Forum|alt.badge.img+4
  • Author
  • Contributor
  • 10 replies
  • December 13, 2022

I've just created an Idea for having the VariableSetter / VariableRetriever support feature caching, feel free to vote for visibility: https://community.safe.com/s/bridea/a0rDm000000CbI9IAK/variableretriever-variablesetter-should-play-nice-with-feature-caching

Great idea!! Thanks.


antoine.prince
Contributor
Forum|alt.badge.img+4
  • Author
  • Contributor
  • 10 replies
  • December 13, 2022

I have the same problem when I run the whole workflow either with or without feature caching activated.

If you look at the workflow printscreen in the attached files, the setter is set before the retriever in a connected path. And also, the first retriever (the one straight up following the setter) works fine. But the second one (the one circled in green) does not. However, the two rerievers are configured exactly the same.


david_r
Celebrity
  • 8391 replies
  • December 13, 2022

I have the same problem when I run the whole workflow either with or without feature caching activated.

Unless some of the input feature types in the blue rectangle ("idec...") arrive before the VariableSetter gets triggered?


dustin
Influencer
Forum|alt.badge.img+31
  • Influencer
  • 627 replies
  • Best Answer
  • December 13, 2022

Great answers thus far concerning VaribleSetter/VariableRetriever...

Looking at your use-case specifically, you could use the following code in a scripted parameter to return the current date, which could be called in the workspace using a ParameterFetcher (or directly in your other transformers)

from datetime import datetime
 
date_time=datetime.today().strftime('%Y%m%d')
 
return(date_time)

 


ebygomm
Influencer
Forum|alt.badge.img+44
  • Influencer
  • 3422 replies
  • December 13, 2022

The other thing to be aware of is the setting that was introduced in I think 2020, where Feature Order is not always preserved across ports, which can also upset the Variable Setter/RetrieverimageFeatures from the reader will hit the variable retriever circled in green possibly before it is set which i suspect is the issue. If you add a featureholder before your testfilter that should fix the issue (I think)


david_r
Celebrity
  • 8391 replies
  • December 13, 2022

Great answers thus far concerning VaribleSetter/VariableRetriever...

Looking at your use-case specifically, you could use the following code in a scripted parameter to return the current date, which could be called in the workspace using a ParameterFetcher (or directly in your other transformers)

from datetime import datetime
 
date_time=datetime.today().strftime('%Y%m%d')
 
return(date_time)

 

Agreed, this is exactly what I do. You may not even have to use the ParameterFetcher, in most cases.


antoine.prince
Contributor
Forum|alt.badge.img+4
  • Author
  • Contributor
  • 10 replies
  • December 13, 2022

Great answers thus far concerning VaribleSetter/VariableRetriever...

Looking at your use-case specifically, you could use the following code in a scripted parameter to return the current date, which could be called in the workspace using a ParameterFetcher (or directly in your other transformers)

from datetime import datetime
 
date_time=datetime.today().strftime('%Y%m%d')
 
return(date_time)

 

That works like a charm!! Super easy to implement with minimal transformers. Much thanks! 

I would have one question though : Let's say I run the script at 11:59PM, do you know if the parameter will update during the run or will it settle to the first value it got at the moment the script was executed ?


DanAtSafe
Safer
Forum|alt.badge.img+19
  • Safer
  • 345 replies
  • December 13, 2022

That works like a charm!! Super easy to implement with minimal transformers. Much thanks!

I would have one question though : Let's say I run the script at 11:59PM, do you know if the parameter will update during the run or will it settle to the first value it got at the moment the script was executed ?

The parameter is set before the translation runs; use a DateTimeStamper to reset the date during the translation.


antoine.prince
Contributor
Forum|alt.badge.img+4
  • Author
  • Contributor
  • 10 replies
  • December 13, 2022

That works like a charm!! Super easy to implement with minimal transformers. Much thanks!

I would have one question though : Let's say I run the script at 11:59PM, do you know if the parameter will update during the run or will it settle to the first value it got at the moment the script was executed ?

Perfect! I need that date value to be fixed.