-
Notifications
You must be signed in to change notification settings - Fork 45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Global Python functions no longer works? #49
Comments
This is a namespace issue that I am trying to address, namely we now have On Fri, Mar 25, 2016 at 10:46 AM, gaow notifications@github.com wrote:
|
I see. Will this syntax remain the same and I should wait for an update of SoS, or are there any alternative syntax I can use to achieve my purpose? I assume moving it to inside SoS step is not good idea because the function will be used in multiple steps. |
I also disabled writing to
uses a default value defined in global section. If The same logic goes to |
I am working on this. I left this unfixed but I need to set up sensible rules what can and what cannot be accessed in what way from within SoS steps... Your code should work though. More specifically, SoS currently executes these functions (e.g. |
The updates are reasonable when |
I believe update of |
Indeed. Are you suggesting of designing some options that can allow for flexible post-processing of these file names at the end of |
Yes. The easiest and most general solution is to allow the specification of a user-defined function that take |
I have added a test case ( |
Using another named parameter might be straightforward and a
and is it cool to have |
By general I meant the function should be able to remove some output files. No, I do not think it is good to use
or
if get_md5 cannot handle multiple names. |
I just updated the test. It turns out to be an issue with list comprehension. If I put |
Oh, this is a nested namespace issue. |
Just use this thread to summarize namespace rules:
Pending problems:
|
Great summary! I can change my implementation to not using list comprehension. But how do I make it to |
The problems are not resolved. We can use a single global namespace for everything but the problem is that if
A seeming feasible way to address this problem is to insert
However, updating In the end, we might have to manually merge |
I find a solution, which is as ugly as hell. Note that the namespace rule is
So
works. As long as we do not change anything in Finally, a less-ugly but resource intensive solution would be to use a single |
Oh ... I do not think I understand the example. So here, |
Python |
Ok, I have submitted a patch to merge the global and local namespace of SoS script. This is not ideal but at least the SoS namespace is now separated from the SoS runtime. The separation of local and global namespace could be done by either of the two methods proposed, but let us wait and see because the implementation of DAG would require steps to be executed in parallel so the problem resolves then naturally if the steps are executed in separate processes. |
I have fixed this problem by running each step in its own process and only the aliased object is sent back to the master process (see TestExecute.testLocalNamespace). Now we are sure that variables in each step will not affect others. |
After updating to the current SoS my previous code does not work:
The error message is:
What is the proper way to use customized Python functions with current SoS?
The text was updated successfully, but these errors were encountered: