Im trying to implement some dynamic selection based on an API call response. So far I can build a package for scripted selection according to Dynamic choices using Scripted Selection - FME Packages SDK Guide
and debug in VS Code attaching to Workbench (Build a Hello World package - FME Packages SDK Guide).
The problem is that debugging is bound to running the translation and that is already late for the script I need to debug. The selection scripts are run when filling in the transformer parameters. I need to add breakpoints and inspect the execution of selection script (ScriptedSelectionCallback) during the API calls and browsing the object structure. Is there some setup to make this possible?
The final purpose is to get this into User parameter scripted selection in FME Flow. I understand it would work this way in scripted parameter selection as it is in the transformers.
Debug Python Scripted Selection
Best answer by siennaatsafe
Thanks for tagging me
Hi
I’m not a Python expert myself but I did ask a developer for clarity on this.
Using scripted selection parameters in FME Flow is impossible at the moment. I don’t expect movement on this front for a while, so far we haven’t seen sufficient motivation, but I would encourage you to make an Idea here to start gathering interest.
Sometime in the 25 release cycle we should see Dynamic Parameters in FME Flow. These would not be Python based but JSON and the values could from a URL or another workspace .This is very much under development at the moment so I cannot guarantee anything about the final functionality or when it will be released.
However, you can see a sneak peek in this webinar: https://fme.safe.com/webinars/ai-agents-made-simple-unleash-the-power-of-all-your-data-with-any-ai/ See 19:46 Dynamic Parameters a Sneak Peek.
If this was a workspace that is just being run on Form, you could continue down the Python route. Here’s the breakdown from a developer:
-
Scripted Selection parameters mainly work for FME Packages because the Python scripts are installed in well-known locations that FME’s Python interpreter can access easily. So if you're building a custom transformer as an FME Package, everything "just works" once it's installed.
-
Scripted Selection parameters can also be used in workspace User Parameters, but now you must manually manage the Python scripts (transport them with the workspace) so FME can find and execute them.
-
All of the above applies to FME Form. On FME Flow, Scripted Selection parameters are not supported — meaning parameters that need to run custom code will show up as basic text fields only.
Onto the debugging question the developer said:
The debugging steps should all still be the same, except for these steps in the guide:
Then set a breakpoint on the first line of code following debugpy.wait_for_client().Now, run a workspace with the DemoGreeter transformer, and notice how the translation blocks. Attach the debugger by running the “Python: Remote Attach” configuration. The debugger stops at the specified breakpoint.
Do not run the workspace, but instead click the ...
for the Scripted Selection parameter. That will attach the debugger and break at the breakpoint set in the ScriptedSelectionCallback. Also, you may need to restart Workbench when making changes to the Python code because it will be loaded in memory. This is noted as a warning in https://docs.safe.com/fme/html/fpkg-sdk/hello-world-package/#installed-package-source-redirection with:
Python code may be cached in certain execution contexts, such as in transformer parameter dialogs. Code changes may not be reflected in those contexts until FME Workbench is restarted.
Please let me know if you have any questions!
Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.