Hi,
Sorry for the dummy question, but I never used this feature as I usually use an external DB to store data and thus it has never been necessary for me to store/propagate data in/along the workflow …
I have this little test code, the goal is to run some FWs in parallel (the “forkit” PyTasks), then gather their results in the “joinit” PyTask
After execution of the parallel part of the workflow, All data are well gathered in the “joinit” task :
"spec": {
"mytestkey_1": "something_1",
"mytestkey_0": "something_0",
"_tasks": [
{
"_fw_name": "PyTask",
"args": [],
"func": "test_spec.joinit"
}
],
"mytestkey_3": "something_3",
"mytestkey_2": "something_2"
}
But I don’t find in the doc how can I access spec from a PyTask.
How can I retrieve these spec data from within “joinit” PyTask ?
Best regards,
David
PS : test code test_spec.py
#!/usr/bin/env python3
from fireworks import FWAction, Firework, ScriptTask, Workflow, PyTask, LaunchPad
def forkit(i):
print("I am forkit num %d" % i)
mykey = "mytestkey_%d" % i
return FWAction(update_spec={mykey : "something_%d" % i})
def joinit():
print("I am joinit")
# retrieve all keys in spec like mytestkey_*
# do something with them
def get_WF():
fw_start = Firework([ScriptTask.from_str("echo \"start\"")], name="dummy start")
all_fws = [fw_start]
deps = []
# proceed in parallel
for i in range(0,4):
fw = Firework(PyTask(func='test_spec.forkit',args=[i]), name="update_spec_%d" % i, parents=[fw_start])
all_fws.append(fw)
deps.append(fw)
# gather results
all_fws.append(Firework(PyTask(func='test_spec.joinit',args=[]), name="gather_spec", parents = deps))
return Workflow(all_fws, name="test spec passing")
def main():
launchpad = LaunchPad()
launchpad.add_wf(get_WF())
if name == ‘main’:
main()
``