Diagramming
The labtech.diagram
module provides the following functions for
automatically generating a diagram to visualise your tasks, their
parameters, and their dependency relationships.
labtech.diagram.build_task_diagram(tasks: Sequence[Task], *, direction: str = 'BT') -> str
Returns a Mermaid diagram representing the task types and dependencies of the given tasks.
Each task type lists its parameters (with their return types) and its run method (with its return type).
Arrows between task types point from a dependency task type to the task type that depends on it, and are labelled with the dependent task's parameter that references the dependency task type.
Parameters:
-
tasks
(Sequence[Task]
) –A collection of tasks to diagram.
-
direction
(str
, default:'BT'
) –Direction that task types should be laid out, from dependent tasks to their dependencies. One of:
'BT'
(bottom-to-top)'TB'
(top-to-bottom)'RL'
(right-to-left)'LR'
(left-to-right)
Source code in labtech/diagram.py
158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 |
|
labtech.diagram.display_task_diagram(tasks: Sequence[Task], **kwargs) -> None
Displays a Mermaid diagram representing the task types and dependencies of the given tasks.
If IPython is available (e.g. the code is being run from a Jupyter
notebook), the diagram will be displayed as a Markdown mermaid
code block, which will be rendered as a Mermaid diagram from
JupyterLab 4.1 and Notebook 7.1.
Because Markdown may render arbitrary HTML, you should only diagram tasks that you trust.
Accepts the same arguments as build_task_diagram.
Source code in labtech/diagram.py
186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 |
|