Dynamic task dependency based on task parameter?

72 views
Skip to first unread message

Brad Dixon

unread,
Feb 1, 2018, 9:44:52 PM2/1/18
to python-doit
Hello:

I'm stumped on how to implement this behavior with doit:

Task 1: Create PDF
Task 2: Create DOCX
Task 3: Archive
    * Has param "fmt" which can be either pdf or docx.
    * Runs either Task 1 or 2 depending on value of fmt parameter.
    * Has action which copies output to a directory
      with a fancy name.

Intended usage:

doit archive --fmt docx
doit archive --fmt pdf

I RTFM'ed that I can use calculated dependencies to, from another task,
make a decision about what tasks to depend on. I added a task_dep to archive which does
just this. I also read that I could, in the archive task, define an action which stashes
the fmt parameter value so that other tasks can use it. The other task would use getargs
to retrieve this stashed value. The catch, of course, is that I can't use these two
features together because the action that stores the variables runs _after_ the task
that determines what to run.

Any advice on how can I have a dynamic task dependency that is determined by a task parameter?

Thanks,

Brad

Eduardo Schettino

unread,
Feb 4, 2018, 8:57:03 AM2/4/18
to python-doit
can you provide a minimal sample?
easier to reason about and make sure we are talking about the same thing.

--
You received this message because you are subscribed to the Google Groups "python-doit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python-doit+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Eduardo Schettino

unread,
Feb 4, 2018, 9:01:38 AM2/4/18
to python-doit
Just having 2 different sub-tasks would solve the problem?
Like:

doit archive:docx
doit archive:pdf

Task "params" is something I added to be used in some long running tasks or to modify output printed to stdout.
In your case having 2 different tasks and executing only one of them would make more sense to me.
But not sure you are talking about a contrived example...

Reply all
Reply to author
Forward
0 new messages