[Issue] Appending workflows in Version 1.7.8

Firstly, thank you for providing the excellent software Fireworks Free and OpenSource.

There is an issue with the append_wf feature, I am getting the error:

Workflow object: (fw_ids: [-1  ] , name: unnamed WF)
Traceback (most recent call last):
File "initModels", line 55, in <module>
initWfs.append_wf(m.initialisationStrategy().workflow(m), initWfs.root_fw_ids)
File "/home/sigveka/.local/lib/python2.7/site-packages/fireworks/core/firework.py", line 944, in append_wf
updated_ids = self.refresh(new_fw.fw_id, set(updated_ids))
File "/home/sigveka/.local/lib/python2.7/site-packages/fireworks/core/firework.py", line 980, in refresh
if self.fw_states[parent] not in completed_parent_states:
KeyError: -5

The issue is in the file core/firework.py in a block of the refresh method starting approximately on line 977:

        # check parent states for any that are not completed
        for parent in self.links.parent_links.get(fw_id, []):
if self.fw_states[parent] not in completed_parent_states:
m_state = 'WAITING'
                break

I fixed the issue temporarily as follows:

        # check parent states for any that are not completed
        for parent in self.links.parent_links.get(fw_id, []):
if self.id_fw[parent].state not in completed_parent_states: # <----- BUGFIX: used to be 'self.fw_states[parent]' instead of 'self.id_fw[parent].state'
                m_state = 'WAITING'
                break

However, knowing the inner workings of the library you may have a more elegant fix.

Regards,

Sigve Karolius

Hi Sigve,

Thank you for the report. What you wrote should work, however, the performance on large workflows (e.g. hundreds of Fireworks) will be much worse.

I was trying to reproduce the error but could not. For example, I tried the below:


from fireworks import Firework, Workflow, FWorker, LaunchPad, ScriptTask
from fireworks.core.rocket_launcher import rapidfire
# set up the LaunchPad and reset it
launchpad = LaunchPad()
launchpad.reset('', require_password=False)
# define four individual FireWorks used in the Workflow
task1 = ScriptTask.from_str('echo "Ingrid is the CEO."')
task2 = ScriptTask.from_str('echo "Jill is a manager."')
task3 = ScriptTask.from_str('echo "Jack is a manager."')
task4 = ScriptTask.from_str('echo "Kip is an intern."')
fw1 = Firework(task1)
fw2 = Firework(task2)
fw3 = Firework(task3)
fw4 = Firework(task4)
fw5 = Firework(task1)
fw6 = Firework(task2)
fw7 = Firework(task3)
fw8 = Firework(task4)
# assemble Workflow from FireWorks and their connections by id
workflow = Workflow([fw1, fw2, fw3, fw4], {fw1: [fw2, fw3], fw2: [fw4], fw3: [fw4]})
launchpad.add_wf(workflow)
workflow2 = Workflow([fw5, fw6, fw7, fw8], {fw5: [fw6, fw7], fw6: [fw8], fw7: [fw8]})
launchpad.append_wf(workflow2, [1])

Do you by any chance have a sample code I can run to reproduce the error?

Best,

Anubhav

···

On Monday, September 3, 2018 at 8:54:58 AM UTC-7, Sigve Karolius wrote:

Firstly, thank you for providing the excellent software Fireworks Free and OpenSource.

There is an issue with the append_wf feature, I am getting the error:

Workflow object: (fw_ids: [-1  ] , name: unnamed WF)
Traceback (most recent call last):
File "initModels", line 55, in <module>
initWfs.append_wf(m.initialisationStrategy().  workflow(m), initWfs.root_fw_ids)
File "/home/sigveka/.local/lib/python2.7/site-packages/fireworks/core/firework.py", line 944, in append_wf
updated_ids = self.refresh(new_fw.fw_id, set(updated_ids))
File "/home/sigveka/.local/lib/python2.7/site-packages/fireworks/core/firework.py", line 980, in refresh
if self.fw_states[parent] not in completed_parent_states:
KeyError: -5

The issue is in the file core/firework.py in a block of the refresh method starting approximately on line 977:

        # check parent states for any that are not completed
        for parent in self.links.parent_links.get(            fw_id, []):
if self.fw_states[parent] not in completed_parent_states:
m_state = 'WAITING'
                break

I fixed the issue temporarily as follows:

        # check parent states for any that are not completed
        for parent in self.links.parent_links.get(            fw_id, []):
if self.id_fw[parent].state not in completed_parent_states: # <----- BUGFIX: used to be 'self.fw_states[parent]' instead of 'self.id_fw[parent].state'
                m_state = 'WAITING'
                break

However, knowing the inner workings of the library you may have a more elegant fix.

Regards,

Sigve Karolius

(please note that the code snippet I wrote will reset a local database of <25 workflows, so please check before executing)

···

On Friday, September 7, 2018 at 4:19:17 PM UTC-7, Anubhav Jain wrote:

Hi Sigve,

Thank you for the report. What you wrote should work, however, the performance on large workflows (e.g. hundreds of Fireworks) will be much worse.

I was trying to reproduce the error but could not. For example, I tried the below:


from fireworks import Firework, Workflow, FWorker, LaunchPad, ScriptTask
from fireworks.core.rocket_launcher import rapidfire
# set up the LaunchPad and reset it
launchpad = LaunchPad()
launchpad.reset('', require_password=False)
# define four individual FireWorks used in the Workflow
task1 = ScriptTask.from_str('echo "Ingrid is the CEO."')
task2 = ScriptTask.from_str('echo "Jill is a manager."')
task3 = ScriptTask.from_str('echo "Jack is a manager."')
task4 = ScriptTask.from_str('echo "Kip is an intern."')
fw1 = Firework(task1)
fw2 = Firework(task2)
fw3 = Firework(task3)
fw4 = Firework(task4)
fw5 = Firework(task1)
fw6 = Firework(task2)
fw7 = Firework(task3)
fw8 = Firework(task4)
# assemble Workflow from FireWorks and their connections by id
workflow = Workflow([fw1, fw2, fw3, fw4], {fw1: [fw2, fw3], fw2: [fw4], fw3: [fw4]})
launchpad.add_wf(workflow)
workflow2 = Workflow([fw5, fw6, fw7, fw8], {fw5: [fw6, fw7], fw6: [fw8], fw7: [fw8]})
launchpad.append_wf(workflow2, [1])

Do you by any chance have a sample code I can run to reproduce the error?

Best,

Anubhav

On Monday, September 3, 2018 at 8:54:58 AM UTC-7, Sigve Karolius wrote:

Firstly, thank you for providing the excellent software Fireworks Free and OpenSource.

There is an issue with the append_wf feature, I am getting the error:

Workflow object: (fw_ids: [-1  ] , name: unnamed WF)
Traceback (most recent call last):
File "initModels", line 55, in <module>
initWfs.append_wf(m.initialisationStrategy().  workflow(m), initWfs.root_fw_ids)
File "/home/sigveka/.local/lib/python2.7/site-packages/fireworks/core/firework.py", line 944, in append_wf
updated_ids = self.refresh(new_fw.fw_id, set(updated_ids))
File "/home/sigveka/.local/lib/python2.7/site-packages/fireworks/core/firework.py", line 980, in refresh
if self.fw_states[parent] not in completed_parent_states:
KeyError: -5

The issue is in the file core/firework.py in a block of the refresh method starting approximately on line 977:

        # check parent states for any that are not completed
        for parent in self.links.parent_links.get(            fw_id, []):
if self.fw_states[parent] not in completed_parent_states:
m_state = 'WAITING'
                break

I fixed the issue temporarily as follows:

        # check parent states for any that are not completed
        for parent in self.links.parent_links.get(            fw_id, []):
if self.id_fw[parent].state not in completed_parent_states: # <----- BUGFIX: used to be 'self.fw_states[parent]' instead of 'self.id_fw[parent].state'
                m_state = 'WAITING'
                break

However, knowing the inner workings of the library you may have a more elegant fix.

Regards,

Sigve Karolius