ralsei.graph.dag

Module Contents

Classes

DAG

A graph of tasks

API

class ralsei.graph.dag.DAG

A graph of tasks

tasks : dict[ralsei.graph.path.TreePath, ralsei.task.Task] = None

All tasks by name

relations : dict[ralsei.graph.path.TreePath, set[ralsei.graph.path.TreePath]] = None

from -> to relations (left task is executed first)

tasks_str() dict[str, ralsei.task.Task]
relations_str() dict[str, set[str]]
topological_sort(constrain_starting_nodes: collections.abc.Iterable[ralsei.graph.path.TreePath] | None = None) ralsei.graph.sequence.TaskSequence

Topological sort

Parameters:
constrain_starting_nodes: collections.abc.Iterable[ralsei.graph.path.TreePath] | None = None

If set, will filter out everything except these nodes and their descendants. Otherwise, perform topological sort on the whole graph

sort_filtered(from_filters: collections.abc.Sequence[ralsei.graph.path.TreePath], single_filters: collections.abc.Sequence[ralsei.graph.path.TreePath]) ralsei.graph.sequence.TaskSequence

Perform topological sort and apply a set of filters. See example in the CLI section.

Filters are combined as a union of both sets of tasks. If both filters are empty, returns the whole graph.

Parameters:
from_filters: collections.abc.Sequence[ralsei.graph.path.TreePath]

same as --from in the CLI, means “this task and its descendants”

single_filters: collections.abc.Sequence[ralsei.graph.path.TreePath]

same as --one in the CLI, means “only this task”

graphviz() graphviz.Digraph

Generate graphviz diagram