dr-graph
| Terms and contracts | Terms TOML | Contracts TOML | dr-serialize |
|---|
dr-graph represents hashable computation graphs as data, interprets them deterministically, and provides exact flow optimization primitives. Graph structure is separate from caller-supplied node behavior and optimization.
- Definitions describe reusable graph topology, node fields, dependencies, and variable requirements.
- Configuration models concrete variable values and validates the resulting graph.
- Identity gives every complete graph configuration a stable, versioned identity.
- Execution interprets a graph in topological order while delegating node behavior to the caller.
- Results models per-node and graph-level outcomes, including reuse of completed node outputs when continuing execution.
- Flow optimization solves exact min-cost flow and balanced separable convex transportation problems independently of computation-graph execution.
- Infra
The following sketches show the public contract shapes. Validation and implementation details are omitted.
Definitions
Definitions describe reusable graph topology before concrete variable values are supplied. Materialization binds those values and produces an executable graph configuration.
class NodeDefinition(BaseModel):
node_id: str
node_type: str
fields: tuple[NodeFieldSpec, ...]
input_sources: dict[str, NodeInputSourceRef]
output_field: str
variable_names: frozenset[str]
class GraphDefinition(BaseModel):
schema_version: Literal[1] = 1
nodes: tuple[NodeDefinition, ...]
terminal_node_id: str
def materialize(
self,
variable_assignments: Mapping[str, Mapping[str, Any]] | None = None,
) -> GraphConfig: ...
Configuration
Configurations are complete, validated graphs with concrete values. Their dependency structure has a deterministic topological order.
class NodeConfig(BaseModel):
node_id: str
node_type: str
fields: tuple[NodeFieldSpec, ...]
input_sources: dict[str, NodeInputSourceRef]
output_field: str
variables: dict[str, Any]
class GraphConfig(BaseModel):
nodes: tuple[NodeConfig, ...]
terminal_node_id: str
def topological_order(self) -> tuple[NodeConfig, ...]: ...
def validate_graph_external_inputs(
graph: GraphConfig,
*,
allowed_fields: Collection[str],
) -> None: ...
Identity
Every static configuration field participates in a versioned canonical
identity document. dr-serialize turns that document into the graph's full
SHA-256 hash.
GRAPH_CONFIG_IDENTITY_SCHEMA = "dr_graph.graph_config"
GRAPH_CONFIG_IDENTITY_SCHEMA_VERSION = 1
def graph_config_identity_document(
graph: GraphConfig,
) -> IdentityDocument: ...
def graph_hash(graph: GraphConfig) -> str: ...
Execution
Execution owns graph traversal and dependency wiring while the caller owns node behavior. A dependency-closed set of completed node outputs may be supplied to continue execution.
type RunNode = Callable[
[NodeConfig, Mapping[str, Any]],
NodeOutput | Mapping[str, Any],
]
def execute_graph(
*,
graph: GraphConfig,
inputs: Mapping[str, Any],
run_node: RunNode,
completed: Mapping[str, NodeOutput | Mapping[str, Any]] | None = None,
) -> GraphRunResult: ...
Results
Results distinguish node outcomes from the aggregate graph outcome and retain enough structured state to inspect or continue a run.
class NodeOutcomeStatus(StrEnum):
SUCCESS = "success"
ERROR = "error"
BLOCKED = "blocked"
class GraphRunStatus(StrEnum):
SUCCESS = "success"
ERROR = "error"
BLOCKED = "blocked"
class NodeOutput(BaseModel):
values: dict[str, Jsonable]
metadata: dict[str, Jsonable]
class NodeOutcome(BaseModel):
node_id: str
status: NodeOutcomeStatus
output: NodeOutput | None
error: NodeError | None
blocked_by: tuple[str, ...]
class GraphRunResult(BaseModel):
graph_hash: str
external_inputs: dict[str, Jsonable]
status: GraphRunStatus
outcomes: dict[str, NodeOutcome]
execution_order: tuple[str, ...]
terminal_node_id: str
terminal_output: Jsonable
terminal_error: TerminalError | None
attempt_evidence_refs: tuple[str, ...]
provenance: dict[str, Jsonable]
Flow optimization
Flow optimization is independent of graph configuration and interpretation. The base package models declared network order and returns exact arc flows in that order.
class FlowArc:
arc_id: ArcId
source: NodeId
target: NodeId
capacity: int
unit_cost: int
class FlowProblem:
nodes: tuple[NodeId, ...]
arcs: tuple[FlowArc, ...]
source: NodeId
sink: NodeId
required_flow: int
class FlowResult:
sent_flow: int
total_cost: int
arc_flows: tuple[ArcFlow, ...]
def solve_min_cost_flow(problem: FlowProblem) -> FlowResult: ...
The nested transportation package models each available route by its ordered marginal costs; every entry supplies one unit of capacity. Its result preserves source and destination index order as an allocation matrix.
class TransportCell:
source_index: int
destination_index: int
marginal_costs: tuple[int, ...]
class TransportProblem:
supplies: tuple[int, ...]
demands: tuple[int, ...]
cells: tuple[TransportCell, ...]
class TransportSolution:
allocations: tuple[tuple[int, ...], ...]
total_flow: int
total_cost: int
def solve_separable_transport(
problem: TransportProblem,
) -> TransportSolution: ...
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file dr_graph-0.1.2.tar.gz.
File metadata
- Download URL: dr_graph-0.1.2.tar.gz
- Upload date:
- Size: 20.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bf74d24287b5545ed9a5af04fba26e3aa6b6704909bc477acd3577657200ee1e
|
|
| MD5 |
4088466f53617e2c10cd17cd25a4b813
|
|
| BLAKE2b-256 |
8d3b08fd40793260d32e9fb7474ddddd3af87f6ae61611bb99d0006420ba67af
|
Provenance
The following attestation bundles were made for dr_graph-0.1.2.tar.gz:
Publisher:
release.yml on danielle-rothermel/dr-graph
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dr_graph-0.1.2.tar.gz -
Subject digest:
bf74d24287b5545ed9a5af04fba26e3aa6b6704909bc477acd3577657200ee1e - Sigstore transparency entry: 2356759110
- Sigstore integration time:
-
Permalink:
danielle-rothermel/dr-graph@bbcd0fa9dc592ae3e74a0d120303da8b78c61632 -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/danielle-rothermel
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@bbcd0fa9dc592ae3e74a0d120303da8b78c61632 -
Trigger Event:
push
-
Statement type:
File details
Details for the file dr_graph-0.1.2-py3-none-any.whl.
File metadata
- Download URL: dr_graph-0.1.2-py3-none-any.whl
- Upload date:
- Size: 36.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e4dbad8b5fa086f769846f3df1e0ce22aadd40bc3e48e4b2640ef2c1185cea04
|
|
| MD5 |
153727eafac668e6712e7b7af927bd52
|
|
| BLAKE2b-256 |
cdb04d1fc6f3e3c79c6a9aa68bd4863b4838ecf69c04a48b06f26727a30d904f
|
Provenance
The following attestation bundles were made for dr_graph-0.1.2-py3-none-any.whl:
Publisher:
release.yml on danielle-rothermel/dr-graph
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dr_graph-0.1.2-py3-none-any.whl -
Subject digest:
e4dbad8b5fa086f769846f3df1e0ce22aadd40bc3e48e4b2640ef2c1185cea04 - Sigstore transparency entry: 2356759249
- Sigstore integration time:
-
Permalink:
danielle-rothermel/dr-graph@bbcd0fa9dc592ae3e74a0d120303da8b78c61632 -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/danielle-rothermel
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@bbcd0fa9dc592ae3e74a0d120303da8b78c61632 -
Trigger Event:
push
-
Statement type: