Skip to main content

In our environment workspace development and published server are on different systemes, therefore the workspaces have to use not-previously-known fme web connections for communication, especially submitting calls to child workspaces.

After some deliberation it seems that a scripted connection parameter that reads its value(s) from a configuration file would be the ideal solution to gain the necessary indepence of runtime environments.

I found https://knowledge.safe.com/articles/844/setting-up-a-workspace-to-deploy-in-production-sta.html and https://knowledge.safe.com/questions/4296/set-published-parameters-in-a-python-startup-scrip.html but cannot figure out how to use these techniques for a connection parameter

Have you tried to manually create a Published Parameter of the type 'Scripted (Python)' and than to link it to your reader?


@lars_de_vries: In my case I do not need it for a reader database name or password, but for a job submitter like here:

The variable $(SERVER_CONNECTION) is the one that should be scriptable.


If you want to use a scripted parameter in combination with a config file, I would recommend the following:

FME Workbench:

  1. Create a subdirectory in the directory where your .fmw file is located. Call this subdirectory 'config'.
  2. Create a new file __init__.py in the config directory.
  3. Put the configuration parameters you need in the __init__.py file as key value pairs:
host_dev=http://fme-dev.com/
user_dev=admin
password_dev=admin


host_prod=http://fme-prod.com/
user_prod=admin
password_prod=admin
  1. In your FME Workspace, create a new Scripted (Python) parameter for each property from your config you need. Return the required value like this (host_dev in this case):
import config as conf
return conf.host_dev

FME Server:

To be able to use your config file, you will need to upload the config to your FME Servers:

Upload the config-directory and the __init__.py file to resources/Engine/Plugins/python/python27

The result will be a 'config' directory inside the python27 directory.

With that done, your scripted parameters will read the config uploaded to the FME Server.


If you want to use a scripted parameter in combination with a config file, I would recommend the following:

FME Workbench:

  1. Create a subdirectory in the directory where your .fmw file is located. Call this subdirectory 'config'.
  2. Create a new file __init__.py in the config directory.
  3. Put the configuration parameters you need in the __init__.py file as key value pairs:
host_dev=http://fme-dev.com/
user_dev=admin
password_dev=admin


host_prod=http://fme-prod.com/
user_prod=admin
password_prod=admin
  1. In your FME Workspace, create a new Scripted (Python) parameter for each property from your config you need. Return the required value like this (host_dev in this case):
import config as conf
return conf.host_dev

FME Server:

To be able to use your config file, you will need to upload the config to your FME Servers:

Upload the config-directory and the __init__.py file to resources/Engine/Plugins/python/python27

The result will be a 'config' directory inside the python27 directory.

With that done, your scripted parameters will read the config uploaded to the FME Server.

Thanks, @nielsg

 

This is the way I will go, refining it with ini-style config files. 

 

 

I was glad to find out that the fme-server-connections that are used by the FMEServerJobSubmitter can be coded as plain strings, assuming that such a connection is defined in the server environment. This alleviates my task tremendously.

 


Reply