infochimps/swineherd — Issue #2: What is workflow.id really used for?
Author: kornypoet
Created: 2012-02-20 21:39:57+00:00
State: open

In order to run a ```Swineherd::Workflow``` a user is required to supply a numeric ```Workflow#id```. See the following example;

```ruby
foo = Workflow.new(1234) do

task :some_task do
...
end

task :a_task => :some_task do
...
end

end

foo.workdir = "/some/dir/path"
foo.run(:a_task)
```

What is this numeric id used for? All I can see is that is that is is added to the output directory structure. But so ```Workflow#workdir```. Having two different attributes to create an output structure seems unnecessary, especially since both are required in order for a workflow to run properly.

I propose the use of options when instantiating a ```Workflow``` . That way attributes like workdir can be set at the beginning of a workflow (enhancing readability) and I can suggest a number of other options that I would like to have to describe a workflow(idempotency assertions, override attributes, running as a particular user, etc.) rather than an unused numeric id.

```ruby
Workflow.new(:workdir => "/path/to/dir",
:increment_id => true,
:clobber_old_files => false,
:complete_upto => :a_task) do

task :some_task do
...
end

task :a_task => :some_task do
...
end

end.run!
```

If it is going to be required, at least use the ```workflow.id```. Perhaps incrementing the id every run to compare output results? Maybe allowing an id to be forced from the command line, otherwise a default is set? If nothing is gained from this attribute, then rip it out.