Skip to content

tdfs4ds.scheduling.run_order

tdfs4ds.scheduling.run_order

Run a list of processes in dependency order (0.3.6.0).

Used by run([...]) / run(data_domain=...) and roll_out. The order comes from the persisted lineage graph contracted onto processes (the parallel planner's _process_dependency_edges): an upstream process runs before the processes reading it. The sort is stable: a list already in a valid order is returned unchanged, and processes with no known dependency keep their place. A cycle is reported and its processes keep the order given.

The core (:func:dependency_order, :func:descendants) is pure; :func:process_edges reads the graph (fail-open: no edges).

Edge module-attribute

Edge = Tuple[str, str]

dependency_order

dependency_order(pids: Sequence[str], edges: Iterable[Edge]) -> Tuple[List[str], Optional[List[str]]]

(ordered, cycle): pids sorted so every upstream runs first, stable.

Kahn's algorithm that always takes the earliest ready process in the given order, so nothing moves unless a dependency requires it. edges outside pids are ignored (a dependency on a process not in the list does not order the list). cycle is the processes left in a cycle (appended in the given order), else None.

descendants

descendants(pid: str, edges: Iterable[Edge]) -> Set[str]

Processes transitively downstream of pid (same BFS as the generated script).

process_edges

process_edges(graph=None, proc_df=None) -> Set[Edge]

Upstream -> dependent edges between registered processes, from the persisted lineage graph. Fail-open: an empty set when the graph or the catalog cannot be read.

order_processes

order_processes(pids: Sequence[str], where: str, *, graph=None, proc_df=None, edges: Optional[Iterable[Edge]] = None) -> Tuple[List[str], Set[Edge]]

pids in dependency order, logged when the order changes. Returns (ordered, edges).