-
Notifications
You must be signed in to change notification settings - Fork 195
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
Explain how to use functions from libraries #2798
Conversation
Decorators are not needed
@@ -112,7 +141,7 @@ Limitations | |||
There are some limitations on the Python functions that can be converted to apps: | |||
|
|||
1. Functions should act only on defined input arguments. That is, they should not use script-level or global variables. | |||
2. Functions must explicitly import any required modules. | |||
2. Functions must explicitly import any required modules if they are defined in script which starts Parsl. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i'm fairly certain there's more subtlety here...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How so?
I'm fairly sure it works this way for functions defined in other files. The main Parsl process will serialize a reference to the location of the function, and the worker will import those libraries as it loads in the function.
That said, my knowledge of Parsl's function serialization is empirical. I don't understand the underlying codebase, just how it has worked for me in practice.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pickle does that, but dill does more complex stuff (including changing behaviour depending on where on the filesystem your Other Files are located...) that is hard to keep in my head
``function_app`` will act as Parsl App function of ``function``. | ||
|
||
It is also possible to create wrapped versions of functions, such as ones with pinned arguments. | ||
Parsl just requires first calling :meth:`~functools.update_wrapped` with the wrapped function |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what happens if you don't do this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I should test to be sure. I think we get errors when a function lacks a name, but might be confused with those errors originating from a code which uses Parsl and not Parsl itself.
Description
The documentation does not explain that you can create Apps outside of the decorator-based mechanism.
It's a convenient route when you just want to make a "Parsl version" of a function already in a module,
and create Parsl functions programatically.
Type of change
Context
Was reviewing code from a user and saw functions similar to:
I suggested they replace with
to make the code more succinct.
It wasn't apparent in the docs that you could do this. I know you can because I'm familiar with function serialization.