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.

with_downstream

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

(pids_and_downstream, edges, skipped): pids plus every process transitively downstream.

The added processes are restricted to the primary store (FEATURE_STORE == tdfs4ds.SCHEMA when the catalog has the column), to the data domain(s) of pids, and without reference processes (DOMAIN_ROLL_OUT = N). Downstream processes of another data domain are returned in skipped and logged once as a warning. The given pids come first, in the order given; the added ones follow, sorted (order_processes then sorts by dependency). edges are returned so the caller does not read the graph twice. Fail-open: when the graph or the catalog cannot be read, pids are returned unchanged (with a warning).

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).