I think the python annotation could be improved to be more generic and versatile.
There is a few axes of improvements :
- Let the user import any python modules
- Simplify the construction of complex expressions
- Use a better editor
A simple way to fix this from a user point of view is to use, instead of a one-liner, a more “ProgrammableAnnotation” approach, where a specific variable, let say,
output, should contain a string at the end of the execution of the python script. This string is then processed by the same mechanism as the current python annotation.
This basically fixes all three problematic exposed here.
Of course, we could ensure retro compatibility by still evaluating one-liner as a potential output string directly.
Alternatively, adding a field for the user to specify which python modules to import before evaluating would also be acceptable.