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

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.

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!

···

On Wednesday, July 24, 2019 at 4:57:44 PM UTC-7, Martin Siron wrote:

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.