Skip to main content
Solved

Setting a single DateTime parameter on run initiation?


afod
Contributor
Forum|alt.badge.img+6
  • Contributor

Is there a way to automatically set the datetime within a parameter and use it to fanout a dataset so that does not then create a folder for every minute the workspace was running.

 

I just want the initial date time the workspace was run. The default date time parameter is not really ideal for this as it defaults to midnight and requires user input. I'm hoping to not have to use a workspace runner.

 

Using DateTimeNow seems to create multiple folders as the outputs are written.

Best answer by david_r

Here's another pure FME pattern that avoids using a FeatureMerger. Only downside is that the VariableSetter/Retriever doesn't always play nice with feature caching.

imageMy preferred solution is using the Python scripted parameter, however. It's very efficient, as it's only evaluated a single time when the workspace starts.

View original
Did this help you find an answer to your question?

5 replies

nielsgerrits
VIP
Forum|alt.badge.img+54

There are different ways to solve this.

  • Pure FME: Put the DateTimeStamper in the very beginning of the workspace, initiated by a Creator. Then you have only one datetime at the start of the workspace. You can then continue the workspace using FeatureReaders to merge this attribute to all features. As an alternative, you can add this attribute to all feature just before writing using a FeatureMerger set with Requestor = 1 and Supplier = 1.
  • Python: Use a Scripted User Parameter. This is a easier way to get it done and will be faster as not all features will have to drag the datetime attribute through the process. Working sample:
import datetime 
return datetime.datetime.now().strftime("%Y_%m_%d__%H_%M_%S")

 


redgeographics
Celebrity
Forum|alt.badge.img+49
nielsgerrits wrote:

There are different ways to solve this.

  • Pure FME: Put the DateTimeStamper in the very beginning of the workspace, initiated by a Creator. Then you have only one datetime at the start of the workspace. You can then continue the workspace using FeatureReaders to merge this attribute to all features. As an alternative, you can add this attribute to all feature just before writing using a FeatureMerger set with Requestor = 1 and Supplier = 1.
  • Python: Use a Scripted User Parameter. This is a easier way to get it done and will be faster as not all features will have to drag the datetime attribute through the process. Working sample:
import datetime 
return datetime.datetime.now().strftime("%Y_%m_%d__%H_%M_%S")

 

I generally use (and recommend) the Pure FME option,  but I like the Python one too, I'm going to try that out!


david_r
Celebrity
  • Best Answer
  • March 10, 2023

Here's another pure FME pattern that avoids using a FeatureMerger. Only downside is that the VariableSetter/Retriever doesn't always play nice with feature caching.

imageMy preferred solution is using the Python scripted parameter, however. It's very efficient, as it's only evaluated a single time when the workspace starts.


jkr_wrk
Influencer
Forum|alt.badge.img+29
  • March 10, 2023
nielsgerrits wrote:

There are different ways to solve this.

  • Pure FME: Put the DateTimeStamper in the very beginning of the workspace, initiated by a Creator. Then you have only one datetime at the start of the workspace. You can then continue the workspace using FeatureReaders to merge this attribute to all features. As an alternative, you can add this attribute to all feature just before writing using a FeatureMerger set with Requestor = 1 and Supplier = 1.
  • Python: Use a Scripted User Parameter. This is a easier way to get it done and will be faster as not all features will have to drag the datetime attribute through the process. Working sample:
import datetime 
return datetime.datetime.now().strftime("%Y_%m_%d__%H_%M_%S")

 

Creator -> VariableSetter -> FeatureReader -> VariableRetriever is my solution


afod
Contributor
Forum|alt.badge.img+6
  • Author
  • Contributor
  • March 11, 2023

Thanks all!

 

I totally forgot about the ability to set a global variables within a workspace, this is what I ended up going for.

 

The DateTimeStamp transformer was an option as well, but as I had multiple output streams within the workspace that already required a different DateTime for their output name I was hoping not to clutter the workflow with more joins than required.


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings