Skip to main content
Question

Passing dynamic values to shutdown script


so_much_more
Supporter
Forum|alt.badge.img+6

 

I try to find out how i pass attribute values assigned during runtime to the shutdown script.

I want to pass values of total features read and written from the feature reader\\writer.

I have tried to create private parameters and set the values in runtime with the attribute manager. But the values are <null> / not set when i fetch them in my python script

 

imageimageThis is the value I am tying to set my private parameter as.

I feel somehow this is the wrong way to do it? What other ways can I set dynamic values that I can use in my shutdown script for logging.

7 replies

david_r
Celebrity
  • November 6, 2023

It's not possible to change parameter values once the workspace has started. Also, unfortunately there is no obvious mechanism for transferring attribute values from the running workspace to the shutdown script. The easiest is to use a PythonCaller in your workspace to set a global variable, then retrieve it in the shutdown script.


so_much_more
Supporter
Forum|alt.badge.img+6
  • Author
  • Supporter
  • November 6, 2023

I see, thank you for the help I will give that a go


__alex__
Contributor
Forum|alt.badge.img+2
  • Contributor
  • July 11, 2025

Thanks David ( ​@david_r )!

quick example for those who were as confused as I was at first: 

 


__alex__
Contributor
Forum|alt.badge.img+2
  • Contributor
  • July 11, 2025
import fme
from fme import BaseTransformer
import fmeobjects


def FeatureProcessor(feature):
    ''' tried this first : not worked
    # global _x
    # _x = "fantastic"
    '''
    # this guy:
    fme.macroValues['_x'] = 'Hello from PythonCaller'

 


david_r
Celebrity
  • July 11, 2025
__alex__ wrote:
import fme
from fme import BaseTransformer
import fmeobjects


def FeatureProcessor(feature):
    ''' tried this first : not worked
    # global _x
    # _x = "fantastic"
    '''
    # this guy:
    fme.macroValues['_x'] = 'Hello from PythonCaller'

 

Does that work? If it does, it might break in future versions, as it’s unintended usage. You should never assign anything to fme.macroValues. 

The solution is to declare a global variable in the PythonCaller, then reference it in the shutdown script. That means you’ll need to declare it with e.g. global x in both places.


takashi
Evangelist
  • July 11, 2025

You cannot create and modify a user parameter anyway.

Try creating a Python global variable in the PythonCaller and referring it directly in Shutdown Script, as ​@david_r mentioned.

Note that you will have to write the codes in the input method to assign a featrue attribute value to the global variable. See also the screenshots below.

 

[Addition] Oh, your example was a function. Of course, this function works too. 

 


__alex__
Contributor
Forum|alt.badge.img+2
  • Contributor
  • July 11, 2025
david_r wrote:
__alex__ wrote:
import fme
from fme import BaseTransformer
import fmeobjects


def FeatureProcessor(feature):
    ''' tried this first : not worked
    # global _x
    # _x = "fantastic"
    '''
    # this guy:
    fme.macroValues['_x'] = 'Hello from PythonCaller'

 

Does that work? If it does, it might break in future versions, as it’s unintended usage. You should never assign anything to fme.macroValues. 

The solution is to declare a global variable in the PythonCaller, then reference it in the shutdown script. That means you’ll need to declare it with e.g. global x in both places.

Thanks ​@david_r  and ​@takashi - that’s a really interesting approach.

The code I posted worked in FME Form 2024, as long as I used a parameter called _x of type Text, and assigned a string value to it from the PythonCaller. I was then able to access that value in the shutdown script without any issues.

However, when I tried assigning a list to _x, it threw a custom exception.

 

I’ll take your warning into account and avoid assigning values to macros from the PythonCaller. Using a simple global variable is also cleaner. It didn’t work for me when I tried to run it only with the global keyword, but I’ll give it another try now when I have a complete solution by Takashi.

 


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