Skip to main content

Using FME 2021.1.0.1

 

When trying to use an FME Server Parameter in a Scripted Parameter, I get this error:

 

-----------------------------------------------------------------------

 

Starting translation...

INFORM: Using Python interpreter from `C:\\Program Files\\FME2021\\fmepython38\\python38.dll' with PYTHONHOME `C:\\Program Files\\FME2021\\fmepython38'

INFORM: Python version 3.8 loaded successfully

ERROR : Python Exception <KeyError>: 'FME_DATA_REPOSITORY'

INCLUDE -- failed to evaluate Python script `def ParamFunc():

import fme

repo = fme.macroValuesu'BOB']

repo = fme.macroValuesu'FME_DATA_REPOSITORY']

if repo == "Example Name - DEV":

env = "DEV"

return env

value = ParamFunc()

macroName = 'ENV'

if value == None:

return { macroName : u'' }

else:

import six

try:

value = six.text_type(value)

except UnicodeDecodeError:

value = six.text_type(value, 'utf-8')

return { macroName : value }

'

Program Terminating

Translation FAILED.

 

----------------------------------------------------------------

 

Are FME Server Parameters populated after Published Parameters? To use published parameters in a scripted parameter, the order of them in the Navigator influences if you can use them (i.e. a published param needs to comes before the scripted parameter it is used in).

 

If Server params are populated after Published params, this would explain my problem. Can anyone confirm and/or provide a workaround if this is so?

Firstly, yes you can use scripted parameters on FME Server, and it shouldn't be an issue referencing FME Server parameters from your script.

I've never used FME_DATA_REPOSITORY myself, are you sure it's defined when running your workspace? You can try disabling the script and running the workspace. Then do a ctrl-F in the job log file for "FME_DATA_REPOSITORY" and see if it's defined, usually on or close to line 7. If there's no mention, the macro is undefined and it explains the exception in your scripted parameter.

 

 


Firstly, yes you can use scripted parameters on FME Server, and it shouldn't be an issue referencing FME Server parameters from your script.

I've never used FME_DATA_REPOSITORY myself, are you sure it's defined when running your workspace? You can try disabling the script and running the workspace. Then do a ctrl-F in the job log file for "FME_DATA_REPOSITORY" and see if it's defined, usually on or close to line 7. If there's no mention, the macro is undefined and it explains the exception in your scripted parameter.

 

 

Thanks for the reply!

 

I have defined the value to run it locally as can be seen here:

 

image 

However, it does not come up in the log where the other published parameters are. None of the FME Server Parameters do though, nor does the scripted parameter (even when I set one successfully) so not sure that is the issue.

 

Have you used any of the other FME Server Parameters in a Scripted Parameter successfully before?


Thanks for the reply!

 

I have defined the value to run it locally as can be seen here:

 

image 

However, it does not come up in the log where the other published parameters are. None of the FME Server Parameters do though, nor does the scripted parameter (even when I set one successfully) so not sure that is the issue.

 

Have you used any of the other FME Server Parameters in a Scripted Parameter successfully before?

I believe that whatever value set for the server parameters will be nixed when running on FME Server. Meaning that you should not set them yourself on FME Desktop and expect to get the same value when running on FME Server.

To answer your question, yes I use scripted parameters with server parameters all the time, it usually works really well.


Thanks for the reply!

 

I have defined the value to run it locally as can be seen here:

 

image 

However, it does not come up in the log where the other published parameters are. None of the FME Server Parameters do though, nor does the scripted parameter (even when I set one successfully) so not sure that is the issue.

 

Have you used any of the other FME Server Parameters in a Scripted Parameter successfully before?

Okay great, good to know it should work!!

 

Yes that's right, the parameters will change once on Server but in order to run locally for testing I set my own Server parameters. I'll try bypassing my local testing and see if it can pick it up when run straight from Server instead 🙂


Reply