reci.graph¶
Recipe DAG — computational graph built on graphlib.
RecipeGraph wraps graphlib.TopologicalSorter to model
the two-level structure of GitHub Actions workflows: jobs containing
sequential steps, with inter-job parallelism governed by needs:
edges and data-flow dependencies.
Functions
|
A dependency cycle in |
Classes
|
A single step in the recipe graph. |
|
Data-flow edge between steps in different jobs. |
The computational DAG of a recipe. |
- class reci.graph.ActionNode(step_id, job, ref=None, action_spec=None, with_=<factory>, bind=<factory>, if_=None, declared_outputs=<factory>, run=None, name=None, env=<factory>)[source]¶
Bases:
objectA single step in the recipe graph.
Uses
step_id+jobas its identity (the graph keys these as"{job}.{step_id}"strings forTopologicalSorter).
- class reci.graph.CrossJobEdge(source_job, source_step_id, source_output, target_job, target_step_id, target_input, alternatives=())[source]¶
Bases:
objectData-flow edge between steps in different jobs.
- class reci.graph.RecipeGraph[source]¶
Bases:
objectThe computational DAG of a recipe.
Nodes are identified by
"{job}.{step_id}"strings. The actualActionNodeobjects are stored in_nodes.- execution_waves()[source]¶
Return parallel execution waves (topological generations).
Each wave is a tuple of node keys that can execute concurrently. Raises
CycleErrorif the graph has cycles.
- classmethod from_recipe(recipe, action_specs)[source]¶
Build a graph from a parsed recipe and fetched action specs.
action_specs is keyed by action ref (e.g.
"actions/checkout@v4").- Return type:
- reci.graph.find_cycle(deps)[source]¶
A dependency cycle in
{node: nodes it depends on}, orNone.The cycle is returned as a closed path following the dependency direction: each node depends on the next, and the first node is repeated at the end.
>>> find_cycle({'a': ['b'], 'b': ['a']}) ['a', 'b', 'a'] >>> find_cycle({'a': ['b'], 'b': ['c'], 'c': ['a']}) ['a', 'b', 'c', 'a'] >>> find_cycle({'a': ['b'], 'b': []}) is None True