Skip to main content

Is it better practice to use 

 

import fme
param = fme.macroValuesa‘parameterName’]

or

import fmeobjects
param = FME_MacroValues‘parameterName’]

in Python scripted parameters and why?

I've noticed that since FME 2018 I've been getting sporadical errors when importing fmeobjects in startup and shutdown scripts on FME Server. My guess is that this is somehow related to how the server engines seem to share session objects between jobs.

So recently I've adopted the following rule, which seems to work for all my use cases.

Startup/shutdown scripts + scripted parameters

import fme
param = fme.macroValuesm‘parameterName’]

PythonCaller / PythonCreator

import fmeobjects
param = FME_MacroValuesn‘parameterName’]

It would be great if someone from Safe could chime in with the official best-practices.


I've noticed that since FME 2018 I've been getting sporadical errors when importing fmeobjects in startup and shutdown scripts on FME Server. My guess is that this is somehow related to how the server engines seem to share session objects between jobs.

So recently I've adopted the following rule, which seems to work for all my use cases.

Startup/shutdown scripts + scripted parameters

import fme
param = fme.macroValuesm‘parameterName’]

PythonCaller / PythonCreator

import fmeobjects
param = FME_MacroValuesn‘parameterName’]

It would be great if someone from Safe could chime in with the official best-practices.

That's my general rule of thumb too, but as I was preparing some training material it occurred to me that I had no real basis for that, and figured I should ask.

 

 


That's my general rule of thumb too, but as I was preparing some training material it occurred to me that I had no real basis for that, and figured I should ask.

 

 

Knowing that you do the same thing is a relief ;-)

 

Hopefully Safe can give us the official explanation here.
@DaveAtSafe, any thoughts?

 


Hi @jdh,

FME_MacroValues is still available for backwards compatibility, but we would recommend that fme.macroValues be used instead.


Hi @jdh,

FME_MacroValues is still available for backwards compatibility, but we would recommend that fme.macroValues be used instead.

Just for Startup/shutdown scripts + scripted parameters, or in general (PythonCaller/Creator included)?

 

 


Hi @jdh,

FME_MacroValues is still available for backwards compatibility, but we would recommend that fme.macroValues be used instead.

Hi @DaveAtSafe, if you would recommend that fme.macroValues always be used rather than FME_MacroValues, please modify the script editor for the PythonCaller/Creator and some relevant documentations (e.g. here) in which FME_MacroValues is still used.

 


Hi @DaveAtSafe, if you would recommend that fme.macroValues always be used rather than FME_MacroValues, please modify the script editor for the PythonCaller/Creator and some relevant documentations (e.g. here) in which FME_MacroValues is still used.

 

Hi @takashi,

 

Thanks for catching that. I have created a problem report to have that changed to fme.macroValues instead.

 


Hi @takashi,

 

Thanks for catching that. I have created a problem report to have that changed to fme.macroValues instead.

 

Thanks for filing the PR!

 

 


I've noticed that since FME 2018 I've been getting sporadical errors when importing fmeobjects in startup and shutdown scripts on FME Server. My guess is that this is somehow related to how the server engines seem to share session objects between jobs.

So recently I've adopted the following rule, which seems to work for all my use cases.

Startup/shutdown scripts + scripted parameters

import fme
param = fme.macroValuesm‘parameterName’]

PythonCaller / PythonCreator

import fmeobjects
param = FME_MacroValuesn‘parameterName’]

It would be great if someone from Safe could chime in with the official best-practices.

I'm not sure if this was what you're looking for, but for sure for startup and shutdown I'd consider it dangerous to use FME Objects in there. The reason is that at startup/shutdown the whole FME system is not yet available really.  So I like "import fme" there. For PythonCaller/Creator, I don't think there's really any diff but if you want to work with features etc then it feels like "import fmeobjects" sets you up for success better.

 

 

Remember, though, I'm an old school Tcl guy and Python wannabee-pretender.

 

 


I've noticed that since FME 2018 I've been getting sporadical errors when importing fmeobjects in startup and shutdown scripts on FME Server. My guess is that this is somehow related to how the server engines seem to share session objects between jobs.

So recently I've adopted the following rule, which seems to work for all my use cases.

Startup/shutdown scripts + scripted parameters

import fme
param = fme.macroValuesm‘parameterName’]

PythonCaller / PythonCreator

import fmeobjects
param = FME_MacroValuesn‘parameterName’]

It would be great if someone from Safe could chime in with the official best-practices.

By the way, FME_MacroValues is not a member of the fmeobjects module, you can access it without importing the fmeobjects module. I think that discussing on "fme.macroValues vs. FME_MacroValues" is slightly different from discussing on "fme module and fmeobjects module".

 

 


Hi @jdh,

FME_MacroValues is still available for backwards compatibility, but we would recommend that fme.macroValues be used instead.

I'm still seeing the legacy behavior in 2019, at least in Data Interoperability.

i.e. FME_MacroValues


Hi @jdh,

FME_MacroValues is still available for backwards compatibility, but we would recommend that fme.macroValues be used instead.

Still not fixed in 2020.0


As I worked to resolve errors with attempting to reference a User Parameter from within a Python Scripted User Parameter, I discovered this thread.  (Thank you, FME Community!)

When I double-clicked on a user parameter (‘DAYS_PRIOR’) in version 2023.2.1 (build 23774) within the Python Scripted​ Configuration interface, FME Form inserted:  FME_MacroValuesa'DAYS_PRIOR']

In order to get the scripted parameter to function properly, I ended up changing the call to: fme.macroValuese'DAYS_PRIOR']

I also had to explicitly import the fme library.


Reply