how can I set fw_id using python script?

Dear Fireworks support,

I have a simple python script that sets fw_id of two subworkflows to 101, and 102:

from fireworks import Firework, Workflow, FWorker, LaunchPad, ScriptTask

from fireworks.features.multi_launcher import launch_multiprocess

launchpad = LaunchPad(port=27017)

launchpad.reset(’’, require_password=False)

task1 = ScriptTask.from_str(‘echo “Ingrid is the CEO.”’)

task2 = ScriptTask.from_str(‘echo “Kip is an intern.” && sleep 15’)

fw1 = Firework(task1, fw_id=101)

fw2 = Firework(task2, fw_id=102)

workflow = Workflow([fw1, fw2], {fw1: [fw2]})

launchpad.add_wf(workflow)

launch_multiprocess(launchpad, FWorker(), ‘INFO’, 1, 2, 10)

The id_map seems to say that fw_ids are reset, but the message later still says fw_ids are 1 and 2:

2015-06-26 10:01:35,652 INFO Added a workflow. id_map: {101: 1, 102: 2}

2015-06-26 10:01:35,939 INFO Created new dir /home/lialex/fireworks/launcher_2015-06-26-15-01-35-937845

2015-06-26 10:01:35,940 INFO Launching Rocket : (Process-2)

2015-06-26 10:01:36,024 INFO Sleeping for 10 secs : (Process-3)

2015-06-26 10:01:36,054 INFO RUNNING fw_id: 1 in directory: /home/lialex/fireworks/launcher_2015-06-26-15-01-35-937845

2015-06-26 10:01:36,218 INFO Task started: ScriptTask.

Ingrid is the CEO.

2015-06-26 10:01:36,225 INFO Task completed: ScriptTask

2015-06-26 10:01:36,420 INFO Rocket finished : (Process-2)

2015-06-26 10:01:46,025 INFO Checking for FWs to run… : (Process-3)

2015-06-26 10:01:46,029 INFO Created new dir /home/lialex/fireworks/launcher_2015-06-26-15-01-46-027933

2015-06-26 10:01:46,030 INFO Launching Rocket : (Process-3)

2015-06-26 10:01:46,139 INFO RUNNING fw_id: 2 in directory: /home/lialex/fireworks/launcher_2015-06-26-15-01-46-027933

Could you please tell me how to set fw_id to the value I want?

Thanks in advance!

Alex.

Hi Alex,

FWS automatically re-assigns ids to prevent conflicts. The purpose of an id is not to identify a Firework and the id should carry no meaning; there are other fields like “name” and “spec” for that, and this is also best practice wrt to unique ids.

If you can say why you would like to maintain ids yourself, I can perhaps help direct you on how to accomplish your end goal. For example, if you are just trying to set a name by which you can remember the FireWork for later, you can use the “name” parameter instead of id (and assign a “name” of “1”, “2”, “3”, etc).

Best,

Anubhav

···

On Fri, Jun 26, 2015 at 8:04 AM, Alex Li [email protected] wrote:

Dear Fireworks support,

I have a simple python script that sets fw_id of two subworkflows to 101, and 102:

from fireworks import Firework, Workflow, FWorker, LaunchPad, ScriptTask

from fireworks.features.multi_launcher import launch_multiprocess

launchpad = LaunchPad(port=27017)

launchpad.reset(‘’, require_password=False)

task1 = ScriptTask.from_str(‘echo “Ingrid is the CEO.”’)

task2 = ScriptTask.from_str(‘echo “Kip is an intern.” && sleep 15’)

fw1 = Firework(task1, fw_id=101)

fw2 = Firework(task2, fw_id=102)

workflow = Workflow([fw1, fw2], {fw1: [fw2]})

launchpad.add_wf(workflow)

launch_multiprocess(launchpad, FWorker(), ‘INFO’, 1, 2, 10)

The id_map seems to say that fw_ids are reset, but the message later still says fw_ids are 1 and 2:

2015-06-26 10:01:35,652 INFO Added a workflow. id_map: {101: 1, 102: 2}

2015-06-26 10:01:35,939 INFO Created new dir /home/lialex/fireworks/launcher_2015-06-26-15-01-35-937845

2015-06-26 10:01:35,940 INFO Launching Rocket : (Process-2)

2015-06-26 10:01:36,024 INFO Sleeping for 10 secs : (Process-3)

2015-06-26 10:01:36,054 INFO RUNNING fw_id: 1 in directory: /home/lialex/fireworks/launcher_2015-06-26-15-01-35-937845

2015-06-26 10:01:36,218 INFO Task started: ScriptTask.

Ingrid is the CEO.

2015-06-26 10:01:36,225 INFO Task completed: ScriptTask

2015-06-26 10:01:36,420 INFO Rocket finished : (Process-2)

2015-06-26 10:01:46,025 INFO Checking for FWs to run… : (Process-3)

2015-06-26 10:01:46,029 INFO Created new dir /home/lialex/fireworks/launcher_2015-06-26-15-01-46-027933

2015-06-26 10:01:46,030 INFO Launching Rocket : (Process-3)

2015-06-26 10:01:46,139 INFO RUNNING fw_id: 2 in directory: /home/lialex/fireworks/launcher_2015-06-26-15-01-46-027933

Could you please tell me how to set fw_id to the value I want?

Thanks in advance!

Alex.

You received this message because you are subscribed to the Google Groups “fireworkflows” group.

To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].

To view this discussion on the web visit https://groups.google.com/d/msgid/fireworkflows/d03fa400-5ef5-4908-8ade-1cb6c915ac2a%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Anubhav,

Thanks for your reply! I already tried setting the name of each subworkflow to a unique string, but it did not work as I expected. All I want to do is to separate two execution instances of the same python script (of course with different parameters) cleanly so that their firetasks won’t not interfere each other. As I mentioned in another post earlier this morning, a single run works perfectly, but when I tried to run the same script on two sets of files, the collision happened.

Alex.

···

On Friday, June 26, 2015 at 10:50:20 AM UTC-5, Anubhav Jain wrote:

Hi Alex,

FWS automatically re-assigns ids to prevent conflicts. The purpose of an id is not to identify a Firework and the id should carry no meaning; there are other fields like “name” and “spec” for that, and this is also best practice wrt to unique ids.

If you can say why you would like to maintain ids yourself, I can perhaps help direct you on how to accomplish your end goal. For example, if you are just trying to set a name by which you can remember the FireWork for later, you can use the “name” parameter instead of id (and assign a “name” of “1”, “2”, “3”, etc).

Best,

Anubhav

On Fri, Jun 26, 2015 at 8:04 AM, Alex Li [email protected] wrote:

Dear Fireworks support,

I have a simple python script that sets fw_id of two subworkflows to 101, and 102:

from fireworks import Firework, Workflow, FWorker, LaunchPad, ScriptTask

from fireworks.features.multi_launcher import launch_multiprocess

launchpad = LaunchPad(port=27017)

launchpad.reset(‘’, require_password=False)

task1 = ScriptTask.from_str(‘echo “Ingrid is the CEO.”’)

task2 = ScriptTask.from_str(‘echo “Kip is an intern.” && sleep 15’)

fw1 = Firework(task1, fw_id=101)

fw2 = Firework(task2, fw_id=102)

workflow = Workflow([fw1, fw2], {fw1: [fw2]})

launchpad.add_wf(workflow)

launch_multiprocess(launchpad, FWorker(), ‘INFO’, 1, 2, 10)

The id_map seems to say that fw_ids are reset, but the message later still says fw_ids are 1 and 2:

2015-06-26 10:01:35,652 INFO Added a workflow. id_map: {101: 1, 102: 2}

2015-06-26 10:01:35,939 INFO Created new dir /home/lialex/fireworks/launcher_2015-06-26-15-01-35-937845

2015-06-26 10:01:35,940 INFO Launching Rocket : (Process-2)

2015-06-26 10:01:36,024 INFO Sleeping for 10 secs : (Process-3)

2015-06-26 10:01:36,054 INFO RUNNING fw_id: 1 in directory: /home/lialex/fireworks/launcher_2015-06-26-15-01-35-937845

2015-06-26 10:01:36,218 INFO Task started: ScriptTask.

Ingrid is the CEO.

2015-06-26 10:01:36,225 INFO Task completed: ScriptTask

2015-06-26 10:01:36,420 INFO Rocket finished : (Process-2)

2015-06-26 10:01:46,025 INFO Checking for FWs to run… : (Process-3)

2015-06-26 10:01:46,029 INFO Created new dir /home/lialex/fireworks/launcher_2015-06-26-15-01-46-027933

2015-06-26 10:01:46,030 INFO Launching Rocket : (Process-3)

2015-06-26 10:01:46,139 INFO RUNNING fw_id: 2 in directory: /home/lialex/fireworks/launcher_2015-06-26-15-01-46-027933

Could you please tell me how to set fw_id to the value I want?

Thanks in advance!

Alex.

You received this message because you are subscribed to the Google Groups “fireworkflows” group.

To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].

To view this discussion on the web visit https://groups.google.com/d/msgid/fireworkflows/d03fa400-5ef5-4908-8ade-1cb6c915ac2a%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Anubhav,

The FW_id problem is fixed.

I blindly copied the sample python script without checking each line carefully. So every time I ran my script, mongodb was reset and so were the FW_ids.

Now I know the l need only do this once for the life time of the mongodb:

launchpad.reset(‘’, require_password=False)

The case can be closed.

Regards,

Alex.

···

On Friday, June 26, 2015 at 12:39:15 PM UTC-5, Alex Li wrote:

Anubhav,

Thanks for your reply! I already tried setting the name of each subworkflow to a unique string, but it did not work as I expected. All I want to do is to separate two execution instances of the same python script (of course with different parameters) cleanly so that their firetasks won’t not interfere each other. As I mentioned in another post earlier this morning, a single run works perfectly, but when I tried to run the same script on two sets of files, the collision happened.

Alex.

On Friday, June 26, 2015 at 10:50:20 AM UTC-5, Anubhav Jain wrote:

Hi Alex,

FWS automatically re-assigns ids to prevent conflicts. The purpose of an id is not to identify a Firework and the id should carry no meaning; there are other fields like “name” and “spec” for that, and this is also best practice wrt to unique ids.

If you can say why you would like to maintain ids yourself, I can perhaps help direct you on how to accomplish your end goal. For example, if you are just trying to set a name by which you can remember the FireWork for later, you can use the “name” parameter instead of id (and assign a “name” of “1”, “2”, “3”, etc).

Best,

Anubhav

On Fri, Jun 26, 2015 at 8:04 AM, Alex Li [email protected] wrote:

Dear Fireworks support,

I have a simple python script that sets fw_id of two subworkflows to 101, and 102:

from fireworks import Firework, Workflow, FWorker, LaunchPad, ScriptTask

from fireworks.features.multi_launcher import launch_multiprocess

launchpad = LaunchPad(port=27017)

launchpad.reset(‘’, require_password=False)

task1 = ScriptTask.from_str(‘echo “Ingrid is the CEO.”’)

task2 = ScriptTask.from_str(‘echo “Kip is an intern.” && sleep 15’)

fw1 = Firework(task1, fw_id=101)

fw2 = Firework(task2, fw_id=102)

workflow = Workflow([fw1, fw2], {fw1: [fw2]})

launchpad.add_wf(workflow)

launch_multiprocess(launchpad, FWorker(), ‘INFO’, 1, 2, 10)

The id_map seems to say that fw_ids are reset, but the message later still says fw_ids are 1 and 2:

2015-06-26 10:01:35,652 INFO Added a workflow. id_map: {101: 1, 102: 2}

2015-06-26 10:01:35,939 INFO Created new dir /home/lialex/fireworks/launcher_2015-06-26-15-01-35-937845

2015-06-26 10:01:35,940 INFO Launching Rocket : (Process-2)

2015-06-26 10:01:36,024 INFO Sleeping for 10 secs : (Process-3)

2015-06-26 10:01:36,054 INFO RUNNING fw_id: 1 in directory: /home/lialex/fireworks/launcher_2015-06-26-15-01-35-937845

2015-06-26 10:01:36,218 INFO Task started: ScriptTask.

Ingrid is the CEO.

2015-06-26 10:01:36,225 INFO Task completed: ScriptTask

2015-06-26 10:01:36,420 INFO Rocket finished : (Process-2)

2015-06-26 10:01:46,025 INFO Checking for FWs to run… : (Process-3)

2015-06-26 10:01:46,029 INFO Created new dir /home/lialex/fireworks/launcher_2015-06-26-15-01-46-027933

2015-06-26 10:01:46,030 INFO Launching Rocket : (Process-3)

2015-06-26 10:01:46,139 INFO RUNNING fw_id: 2 in directory: /home/lialex/fireworks/launcher_2015-06-26-15-01-46-027933

Could you please tell me how to set fw_id to the value I want?

Thanks in advance!

Alex.

You received this message because you are subscribed to the Google Groups “fireworkflows” group.

To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].

To view this discussion on the web visit https://groups.google.com/d/msgid/fireworkflows/d03fa400-5ef5-4908-8ade-1cb6c915ac2a%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.