Hi Felix,
unfortunately, FME_MacroValues is considered read-only by FME, so any changes you make to the dictionary values will not be propagated back to the running session. In fact, I believe that it isn't possible to change the value of the user parameters during run-time at all, regardless (I'd be glad to be proved wrong on this one!)...
Two alternative strategies:
- Initialize the parameter value using a Python scripted parameter, or
- Have the PythonCaller create a new attribute, which you then reference in your workspace rather than the user parameter.
Hope this helps.
David
Hi David,
Thanks for your answer. That's too bad.
The whole workbench is for data processing and quality assurance. After processing some data I do quality checks. The output is then compared with a text file, where exceptions can be defined, in the PyhtonCaller.
So, I can't use a scripted Parameter. I think I have to stick to the second strategie and use the VariableSetter & VariableRetriever combo.
Is it possible to use a transformer within the PyhtonCaller (VariableSetter) or set a GlobalVariable?
thanks
felix
Hi Felix,
unfortunately, I do not know of any way to set/get variables like the VariableSetter does.
You can, however, set a session variable in one PythonCaller that you can retrieve in another PythonCaller later on, if that is of any help. The easiest is probably to define a variable (or dictionary, etc) in the startup scrip, such as:
my_global_value = 0
global my_global_value
You can then reference and modify my_global_value from the various PythonCallers in your workspace.
If this does not solve your problem, I would consider taking a step back (figuratively
and see if it is possible to separate the loading and the validation of the data. This is a common way to do it when importin into a database schema with strict constraints:
- load input data (e.g. csv, shape, etc) into a validation schema (copy of production schema, but without any hard constraints, relationships, etc)
- try to apply constraints one by one on validation schema
- if everything ok, transfer data to production schema, if not, report error
This is of course very simplified, but you get the idea.
Hope this helps.
David
Hi David
Thanks, that solved most of my problems. First I tried to access the global variable within a scripted parameter. As you mentioned earlier, that doesn't work.
Now I set the global variable in the PythonCaller (btw. you flipped the order, first global parameter, then parameter ="text"). Instead of assigning the variable to each feature and unsing a Tester I use a second PythonCaller and test programatically for the global variable.
Thanks for your help
felix
P.S.
With the VariableSetter you can set a variable. Later you can asign this variable to an attribute (VariableRetriever).
In my case I createed one feature with an attribute in the PythonCaller and used the VariableSetter. All processed features went into an FeatureHolder. I asigned to each feature the attribute from the PythonCaller with the VariableRetriever. In the end I was able to test for his attribute.