-
Notifications
You must be signed in to change notification settings - Fork 198
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
32 changed files
with
208 additions
and
226 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import os | ||
|
||
from parsl.serialize import unpack_res_spec_apply_message | ||
|
||
|
||
def execute_task(bufs: bytes): | ||
"""Deserialize the buffer and execute the task. | ||
Returns the result or throws exception. | ||
""" | ||
f, args, kwargs, resource_spec = unpack_res_spec_apply_message(bufs) | ||
|
||
for varname in resource_spec: | ||
envname = "PARSL_" + str(varname).upper() | ||
os.environ[envname] = str(resource_spec[varname]) | ||
|
||
# We might need to look into callability of the function from itself | ||
# since we change it's name in the new namespace | ||
prefix = "parsl_" | ||
fname = prefix + "f" | ||
argname = prefix + "args" | ||
kwargname = prefix + "kwargs" | ||
resultname = prefix + "result" | ||
|
||
code = "{0} = {1}(*{2}, **{3})".format(resultname, fname, | ||
argname, kwargname) | ||
|
||
user_ns = locals() | ||
user_ns.update({ | ||
'__builtins__': __builtins__, | ||
fname: f, | ||
argname: args, | ||
kwargname: kwargs, | ||
resultname: resultname | ||
}) | ||
|
||
exec(code, user_ns, user_ns) | ||
return user_ns.get(resultname) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.