You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This line is setting the globals to be empty, that is that there are no global variables defined for the Python code that is going to be executed. That line should be:
_globals=None
Which instead is interpreted as that we are not setting any global variables in the scope.
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<string>", line 1, in <module>
However, weirdly, in Appose in order to get this to work, the variables created in one task need to be set explicitly as a global variable to be accessible in other tasks.
globals()['np'] =np
The text was updated successfully, but these errors were encountered:
Hello, I deleted my previous comment because it was completely wrong, I had not understood anything.
After reading the docs (probaly I should have done it way earlier) I realised that setting both globals and locals is equivalent to inserting the piece of code in the script. It basically makes the code in the script share locals and globals with the program the exec is embedded in.
This is why if we do:
It seems that the new variables created in the scope of exec are added to the globals locals dictionary and not the globals. We still can add the to the globals by doing globals()["a"] = a.
With this in mind I think it might make sense to keep track of the globals and locals as attributes of the python service to guarantee variable consistency among tasks.
Currently Appose is not able to access the variables that where created in the same Python Service on previous Tasks.
This means that if we do:
I will get an error saying that the variable a is not defined
The error is caused by the following line:
https://github.com/apposed/appose-python/blob/ed37c651084601d201e7dc7c8e8bb5b5f72e0d70/src/appose/python_worker.py#L108
This line is setting the globals to be empty, that is that there are no global variables defined for the Python code that is going to be executed. That line should be:
Which instead is interpreted as that we are not setting any global variables in the scope.
To test the behaviour try the following:
Output:
and compare to:
Output:
However, weirdly, in Appose in order to get this to work, the variables created in one task need to be set explicitly as a global variable to be accessible in other tasks.
The text was updated successfully, but these errors were encountered: