Skip to main content
Solved

Setting a single DateTime parameter on run initiation?

  • March 10, 2023
  • 5 replies
  • 77 views

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

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.

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.

5 replies

nielsgerrits
VIP
Forum|alt.badge.img+60
  • 2938 replies
  • March 10, 2023

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+59
  • Celebrity
  • 3699 replies
  • March 10, 2023

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
  • 8391 replies
  • 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+35
  • 424 replies
  • March 10, 2023

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
  • 18 replies
  • 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.