FWAction(additions = new_fw, update_spec={}) -> spawned FW doesn't inherit the updated spec

20 views
Skip to first unread message

Martin Siron

unread,
Jul 24, 2019, 7:57:44 PM7/24/19
to fireworkflows
Hi,

If I have one Firework that has a task with FWAction() that spawns a new firework through additions variable, that new FW that spawns doesn't seem to inherit any update_spec from the FW that launched it.

Am I doing something wrong?

For example, with this very sample code in CFiretasks.py:
from fireworks.core.firework import FiretaskBase, Firework, FWAction, Workflow
from fireworks.utilities.fw_utilities import explicit_serialize


@explicit_serialize
class TaskUpdateSpec(FiretaskBase):
 required_params
= []
 optional_params
= []
 
def run_task(self, fw_spec):
 fw
= Firework(SpecPrint())
 update_spec
={"str1":"test"}
 
return FWAction(additions=fw, update_spec = update_spec)


@explicit_serialize
class SpecPrint(FiretaskBase):
 required_params
= []
 optional_params
= []
 
def run_task(self, fw_spec):
 
print(fw_spec)

And then this helper code in another file:
from CFiretasks import TaskUpdateSpec
from fireworks.core.firework import Firework


t
= []
t
.append(TaskUpdateSpec())
fw
= Firework(t)


When I run this, the only thing that is printed is this in this addition FW:
{'_tasks': [{'_fw_name': '{{CFiretasks.SpecPrint}}'}], '_fw_env': {}}

The update_spec was not passed on.


Martin Siron

unread,
Jul 29, 2019, 1:16:36 PM7/29/19
to fireworkflows
For anyone who had similar problems, Rees Chang has found a solution that has worked, and I would like to share it with other people who might have similar problems:

Rees pointed out that if you update the addition before you call FWAction, you can get around such a problem:

@explicit_serialize
class TaskUpdateSpec(FiretaskBase):
 required_params
= []
 optional_params
= []
 
def run_task(self, fw_spec):
 fw
= Firework(SpecPrint
())
 
#Update the FW Spec of new dynamic FW to pass important information - this is the get around:
 fw.spec["_fworker"] = fw_spec["_fworker"]
 fw
.spec["str1"] = "test"
 
return FWAction(additions=fw)


Hope this helps!
Reply all
Reply to author
Forward
0 new messages