Firwfork.from_file ID - can I change it so it's not always -1

14 views
Skip to first unread message

Daniel Shaw

unread,
Sep 8, 2017, 2:33:36 PM9/8/17
to fireworkflows
This is a follow-on to the previous question I had today.  I'm creating 5 fireworks from five different files.  I'd like them to come back with unique IDs, but they all come back -1 (the call is Firework.from_file(filename)).
Is it possible to have these fireworks have different ids?  How?

Thanks,
Dan

Anubhav Jain

unread,
Sep 8, 2017, 2:45:46 PM9/8/17
to Daniel Shaw, fireworkflows
Negative ids will be reassigned when entered into the launchpad so dont worry about it

If you really want to set ids yourself add a fw_id key in your YAML but suggest that you use negative ids. Follow tutorials for examples this should already be documented


--
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 fireworkflow...@googlegroups.com.
To post to this group, send email to firewo...@googlegroups.com.
Visit this group at https://groups.google.com/group/fireworkflows.
To view this discussion on the web visit https://groups.google.com/d/msgid/fireworkflows/d69783db-f182-450d-b575-0b8cac47108e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
Best,
Anubhav

Anubhav Jain

unread,
Sep 8, 2017, 3:00:38 PM9/8/17
to fireworkflows
(actually, don't worry about making the ids negative yourself, just set whatever id you want, although FireWorks may reassign it as negative to prevent conflicts with existing fw_ids in your database)

On Friday, September 8, 2017 at 11:45:46 AM UTC-7, ajain wrote:
Negative ids will be reassigned when entered into the launchpad so dont worry about it

If you really want to set ids yourself add a fw_id key in your YAML but suggest that you use negative ids. Follow tutorials for examples this should already be documented


On Fri, Sep 8, 2017 at 11:34 AM Daniel Shaw <dps...@gmail.com> wrote:
This is a follow-on to the previous question I had today.  I'm creating 5 fireworks from five different files.  I'd like them to come back with unique IDs, but they all come back -1 (the call is Firework.from_file(filename)).
Is it possible to have these fireworks have different ids?  How?

Thanks,
Dan

--
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 fireworkflows+unsubscribe@googlegroups.com.
--
Best,
Anubhav

Daniel Shaw

unread,
Sep 8, 2017, 3:01:50 PM9/8/17
to fireworkflows
Thanks again.

However, my problem is not resolved quite yet...

After I create the fws, I try to manually add them to a Workflow before adding that to the launchpad:
    wf = Workflow([fw1, fw2, fw3, fw4, fw5], {fw1:fw2, fw2:fw3, fw3:fw4, fw4:fw5}, name="single stochastic workflow")

Hence why I need the unique ids now.  I tried hard-coding fw_id in the yaml, but it didn't take.  Where should that go in the yaml?  Is there a better way to do this?

Thanks,
Dan

Anubhav Jain

unread,
Sep 8, 2017, 3:05:11 PM9/8/17
to Daniel Shaw, fireworkflows

To unsubscribe from this group and stop receiving emails from it, send an email to fireworkflows+unsubscribe@googlegroups.com.

To post to this group, send email to firewo...@googlegroups.com.
Visit this group at https://groups.google.com/group/fireworkflows.

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



--
Best,
Anubhav

Daniel Shaw

unread,
Sep 8, 2017, 3:09:08 PM9/8/17
to fireworkflows
From that link, I've got a very similar set-up to this:
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)

# assemble Workflow from FireWorks and their connections by id
workflow = Workflow([fw1, fw2, fw3, fw4], {fw1: [fw2, fw3], fw2: [fw4], fw3: [fw4]})

# store workflow and launch it locally
launchpad.add_wf(workflow)
rapidfire(launchpad, FWorker())

Yet I get all IDs = -1 and the process is dying when it tries to build the workflow...



--
Best,
Anubhav

Anubhav Jain

unread,
Sep 8, 2017, 3:11:48 PM9/8/17
to Daniel Shaw, fireworkflows
Did you look at the example workflow YAML file it points to? I'll paste it below for you:

=========
fws:
- fw_id: 1
  spec:
    _tasks:
    - _fw_name: ScriptTask
      script: echo 'To be, or not to be,'
- fw_id: 2
  spec:
    _tasks:
    - _fw_name: ScriptTask
      script: echo 'that is the question:'
links:
  1:
  - 2
metadata: {}
=========


To unsubscribe from this group and stop receiving emails from it, send an email to fireworkflows+unsubscribe@googlegroups.com.

To post to this group, send email to firewo...@googlegroups.com.
Visit this group at https://groups.google.com/group/fireworkflows.

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



--
Best,
Anubhav

Daniel Shaw

unread,
Sep 11, 2017, 2:48:51 PM9/11/17
to fireworkflows
I set up my case this way, and it worked... sort of.  The fw_id's I assigned (11,12,13,14,15) were reassigned to (1,2,3,4,5) when I added the yaml task.  What can I do about that (if anything)?



--
Best,
Anubhav

Anubhav Jain

unread,
Sep 11, 2017, 3:24:49 PM9/11/17
to Daniel Shaw, fireworkflows
Hi Daniel

There is no way to set the fw_ids yourself in the database. Fireworks will reassign them (and return back a map of what the reassigned ids are compared to the original ones).

Note that ids should not contain any meaningful information. That is in-line with best practices for ids. If there is any information about a Firework that you want to store for later querying, do not embed that information in the fw_id. Instead, modify the "spec" to have whatever tags, ids, etc. that you want to assign.

Note that once the fw_ids are in the database, you can safely assume that they won't change.

Best,
Anubhav


To unsubscribe from this group and stop receiving emails from it, send an email to fireworkflows+unsubscribe@googlegroups.com.

To post to this group, send email to firewo...@googlegroups.com.
Visit this group at https://groups.google.com/group/fireworkflows.

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



--
Best,
Anubhav
Reply all
Reply to author
Forward
0 new messages