Custom task metadata

12 views
Skip to first unread message

mle...@gmail.com

unread,
Oct 7, 2021, 12:16:21 PM10/7/21
to python-doit
Hi,

I am using doit for my bioinformatics project. To get an overview about my tasks, I have written a script that loads the tasks using `doit.loader.load_tasks()` and creates a dot graph from them (I know there is doit-graph, but I need to avoid the external dependency of the graphviz libs and use pydot instead).

But I generate some (sub-)tasks automatically and just printing the graph of all tasks gives a too large and confusing graph. So I want to add metadata to my tasks that can be read by my graphing script with information like for example:

 * A short task description
 * Which subgraph the task belongs to
 * That this task should be conflated with certain other tasks to a group that only appears as one node
 * graphviz options, like "rank", color, style etc.

So I need a way to store information in the tasks that is not used by doit but still retained in the task objects. How is this possible?

 Option 1: Is there some field in the Task definition that I am not aware of, like

def task_example:
  return {
    "action" : "my_script args...",
    "metadata" : { "dot_rank" : 3 } }

Option 2: Can I change doit so that it does not generate `doit.Task` object, but a subclass that I create and that has a field for this metadata? How can that be done?

Cheers,
Moritz

schettino72

unread,
Oct 7, 2021, 12:25:41 PM10/7/21
to python-doit
On Friday, October 8, 2021 at 12:16:21 AM UTC+8 mle...@gmail.com wrote:

 Option 1: Is there some field in the Task definition that I am not aware of, like

def task_example:
  return {
    "action" : "my_script args...",
    "metadata" : { "dot_rank" : 3 } }


This one.. I want to add this since long time.
Can you provide a pull-request?
Should be trivial as doit will just ignore it.

Maybe include the output on `info` command. But not required, just add the code you need.

Regards
Reply all
Reply to author
Forward
0 new messages