How to visualize workflows?#
Taskblaster provides (experimental, not supporting yet all features) visualization of workflows.
$ tb view-workflow --help
Usage: tb view-workflow [OPTIONS] [WORKFLOW_CLASS]
Write HTML files from a specified workflow class.
Example usage: tb view-workflow package.workflows.TestWorkflow
In case workflow cannot be imported from a package, user can also specify
the file that contains the workflow as:
tb view-workflow -f workflow.py TestWorkflow
Options:
-o, --output TEXT
-f, --file TEXT
-s, --style TEXT
-b, --browser
--help Show this message and exit.
We can for example use the workflow.py from the while loop example.
$ tb view-workflow -f workflow.py -o while_loop_workflow.html WhileLoopWorkflow
Succesfully wrote workflow visualization to while_loop_workflow.html.
You can view the generated visualization here.
Customization#
The tb view-workflow command also accepts custom style options. To get latest default style, one can write the
following.
$ python -c "from taskblaster.view_workflow_html import DEFAULT_STYLE;import json;print(json.dumps(DEFAULT_STYLE, indent=4))" | tee default_style.json
{
"hide-branch-labels": false,
"hide-main-workflow": false,
"hide-task-name": false,
"task_width": "200px",
"task-display": "inline-block",
"branch-end-socket": "right",
"task_height": "87px",
"center-branch": false,
"wf_width": "70%",
"display-parameters": null,
"branch-arrow-target": "branchcontent",
"arrow-path": "fluid",
"branch-arrow-size": "10",
"arrow-size": "3",
"workflowtitle-font-size": "2em",
"workflowinput-font-size": "1em",
"taskname-font-size": "1.5em",
"taskimport-font-size": "1.5em",
"startSocketGravity": "[0, 20]",
"endSocketGravity": "[0, -20]",
"customcss": [],
"branch-startSocketGravity": "[80,0]",
"branch-endSocketGravity": "[80,0]",
"taskparameter-font-size": "1em",
"colors": {
"background": "#d3eaff",
"workflowinput": "rgb(135,214,146)",
"branchbackground": "#eee",
"branchcontentbackground": "#eff2ff",
"branchtitle": "#e2edf7",
"taskbody": "rgb(136,204,215)",
"iftaskbody": "rgb(214,135,204)",
"parameterarrow": "rgb(0,255,0)",
"jumparrow": "rgb(0,0,0)",
"iftruearrow": "rgb(0,255,0)",
"iffalsearrow": "rgb(255,0,0)"
}
}
Save this style file to default_style.json to run the tutorial further. It contains all the defaults and paramters that can be adjusted for the workflow visualization, and thus acts as a good skeleton for complete control of workflow visualization. Unfortunately, at this stage, it is impossible to make publication quality plots for complicated workflows, but nevertheless they might help to understand the parameter routings, subworkflow structure, and branching in some cases.
To utilize the style file, one can pass it as -s parameter.
$ tb view-workflow -f workflow.py -s default_style.json -o styled_workflow.html WhileLoopWorkflow
Succesfully wrote workflow visualization to styled_workflow.html.
You can view the generated visualization with the default style here. which should be
identical to the previous one.
$ cmp while_loop_workflow.html styled_workflow.html && echo "Files identical!"
Files identical!