# pysparky_pipeline.graph

*module*

Spark-independent graph construction and dependency inspection.

[View source](https://github.com/PySparky/pysparky-pipeline/blob/4a64f789246a4be5067124ee05e3c2d06ae49631/src/pysparky_pipeline/graph.py#L1-L1)

## pysparky_pipeline.graph.DependencyGraph

*class* · *dataclass*

```python
class DependencyGraph
```

An immutable graph inferred from explicitly registered callables.

A function parameter is a graph dependency when its name matches a
registered function. Other parameters are external inputs. The graph
records input metadata but does not resolve runtime values or execute a
function.

Build a graph from functions without invoking them.

[View source](https://github.com/PySparky/pysparky-pipeline/blob/4a64f789246a4be5067124ee05e3c2d06ae49631/src/pysparky_pipeline/graph.py#L19-L227)

### pysparky_pipeline.graph.DependencyGraph.external_inputs

*property*

```python
external_inputs: tuple[str, ...]
```

Return all unresolved parameter names in stable order.

[View source](https://github.com/PySparky/pysparky-pipeline/blob/4a64f789246a4be5067124ee05e3c2d06ae49631/src/pysparky_pipeline/graph.py#L148-L150)

### pysparky_pipeline.graph.DependencyGraph.node_names

*property*

```python
node_names: tuple[str, ...]
```

Return registered node names in stable order.

[View source](https://github.com/PySparky/pysparky-pipeline/blob/4a64f789246a4be5067124ee05e3c2d06ae49631/src/pysparky_pipeline/graph.py#L133-L135)

### pysparky_pipeline.graph.DependencyGraph.nodes

*property*

```python
nodes: tuple[Node, ...]
```

Return nodes in stable name order.

[View source](https://github.com/PySparky/pysparky-pipeline/blob/4a64f789246a4be5067124ee05e3c2d06ae49631/src/pysparky_pipeline/graph.py#L128-L130)

### pysparky_pipeline.graph.DependencyGraph.optional_external_inputs

*property*

```python
optional_external_inputs: tuple[str, ...]
```

Return defaulted unresolved inputs not required by another node.

[View source](https://github.com/PySparky/pysparky-pipeline/blob/4a64f789246a4be5067124ee05e3c2d06ae49631/src/pysparky_pipeline/graph.py#L158-L160)

### pysparky_pipeline.graph.DependencyGraph.required_external_inputs

*property*

```python
required_external_inputs: tuple[str, ...]
```

Return unresolved inputs required by at least one registered node.

[View source](https://github.com/PySparky/pysparky-pipeline/blob/4a64f789246a4be5067124ee05e3c2d06ae49631/src/pysparky_pipeline/graph.py#L153-L155)

### pysparky_pipeline.graph.DependencyGraph.topological_levels

*property*

```python
topological_levels: tuple[tuple[str, ...], ...]
```

Return ready-node generations in deterministic alphabetical order.

[View source](https://github.com/PySparky/pysparky-pipeline/blob/4a64f789246a4be5067124ee05e3c2d06ae49631/src/pysparky_pipeline/graph.py#L138-L140)

### pysparky_pipeline.graph.DependencyGraph.topological_order

*property*

```python
topological_order: tuple[str, ...]
```

Return nodes in deterministic topological order.

[View source](https://github.com/PySparky/pysparky-pipeline/blob/4a64f789246a4be5067124ee05e3c2d06ae49631/src/pysparky_pipeline/graph.py#L143-L145)

### pysparky_pipeline.graph.DependencyGraph.downstream

*method*

```python
def downstream(name: str) -> tuple[str, ...]
```

Return transitive dependents in topological order, excluding name.

[View source](https://github.com/PySparky/pysparky-pipeline/blob/4a64f789246a4be5067124ee05e3c2d06ae49631/src/pysparky_pipeline/graph.py#L184-L197)

### pysparky_pipeline.graph.DependencyGraph.get_node

*method*

```python
def get_node(name: str) -> Node
```

Return a registered node or raise ``UnknownNodeError``.

[View source](https://github.com/PySparky/pysparky-pipeline/blob/4a64f789246a4be5067124ee05e3c2d06ae49631/src/pysparky_pipeline/graph.py#L162-L167)

### pysparky_pipeline.graph.DependencyGraph.prune

*method*

```python
def prune(outputs: Iterable[str]) -> DependencyGraph
```

Return the outputs and their registered dependency closure.

[View source](https://github.com/PySparky/pysparky-pipeline/blob/4a64f789246a4be5067124ee05e3c2d06ae49631/src/pysparky_pipeline/graph.py#L199-L227)

### pysparky_pipeline.graph.DependencyGraph.upstream

*method*

```python
def upstream(name: str) -> tuple[str, ...]
```

Return transitive dependencies in topological order, excluding name.

[View source](https://github.com/PySparky/pysparky-pipeline/blob/4a64f789246a4be5067124ee05e3c2d06ae49631/src/pysparky_pipeline/graph.py#L169-L182)
