Skip to main content

dag-ml Python bindings

Thin PyO3/maturin bindings for DAG-ML JSON contracts.

This package validates, compiles and plans serialized DAG-ML contracts. Its owning training entry point also executes the native DAG-ML coordinator while operator implementations remain Python callbacks; no numerical or fold logic is reimplemented in the binding.

Build

This crate is excluded from the root cargo workspace (its abi3-py311 floor would force a Python >= 3.11 host on cargo test --workspace / cargo llvm-cov), so build and test it through its own manifest against a Python

= 3.11 interpreter:

PYO3_PYTHON=python3.11 cargo test --manifest-path crates/dag-ml-py/Cargo.toml
maturin build --release --features extension-module   # run from this crate dir
python3 ../../scripts/smoke_python_bindings.py        # after installing the wheel
PYTHONPATH=python python3.11 -m unittest discover -s tests

The source package also contains the tracked _dag_ml.abi3.so used by direct PYTHONPATH=crates/dag-ml-py/python imports. After changing compiled Rust inputs, refresh it with maturin develop --release inside an active Python 3.11+ virtual environment, run python scripts/check_so_freshness.py, and smoke the public source-tree import. The freshness gate rejects dirty or untracked Rust inputs when that tracked extension is unchanged.

Python Surface

For a concrete host-managed pipeline without cross-validation, use execute_phase_in_process(dsl, envelope, controllers, callback, "REFIT", training_sample_ids=[...]). Rust verifies the supplied row ordering is an exact unique permutation of the attested training identities and records it in the effective campaign. Split invocations and unresolved operator choices are refused; use the CV/refit entry point for those campaigns.

The same entry point with phase="PREDICT" requires a separately attested V2 prediction cohort and forbids training_sample_ids. It executes only PREDICT, never fitting or selecting a model. Host-managed fitted state stays the host's responsibility and is not implicitly promoted to a portable predictor package. Both paths return JSON with native node_results, scores, phase and effective_plan; absent target observations produce no invented score.

import dag_ml

dag_ml.validate_graph_json(graph_json)  # raw JSON helper remains available

dsl = dag_ml.PipelineDslSpec(dsl_json)
controllers = dag_ml.ControllerManifests(controller_manifests_json)
artifact = dag_ml.compile_pipeline_dsl_artifact(dsl)
plan = dag_ml.build_execution_plan(
    "plan:example",
    artifact.graph,
    artifact.campaign_template,
    controllers,
)
plan_json = plan.json()

validated_request = dag_ml.TrainingRequest.from_path(
    "examples/fixtures/training/training_request_active_influence.v1.json"
)
validated_request = dag_ml.sign_training_request(unsigned_training_request)
relation_fingerprint = dag_ml.sample_relation_set_fingerprint_json(relations_json)
training_projection = validated_request.project()
package = dag_ml.PortablePredictorPackage.from_path(
    "examples/fixtures/training/portable_predictor_package.v1.json"
)

result = dag_ml.execute_training(
    native_training_request,
    data_envelopes={"model:base.x": signed_envelope},
    relations=sample_relations,
    training_influence=signed_influence,
    op_callback=run_node,
    outcome_id="outcome:example",
    run_id="run:example",
    bundle_id="bundle:example",
)
bundle = result.execution_bundle
scores = result.score_set
portable_artifacts = result.artifacts
result.detach()  # explicitly release callbacks, views and artifact handles

Portable package replay is available without the original TrainingResult. Hosts pass the signed package, a TrainingReplayRequest whose phase is either PREDICT or EXPLAIN, the current cohort data envelopes, and explicit sidecar artifact handles:

outcome = dag_ml.replay_loaded_predictor_package(
    package,
    replay_request,  # {"phase": "PREDICT"} or {"phase": "EXPLAIN"}
    data_envelopes,
    artifact_handles,
    run_node,
    outcome_id="outcome:package.replay",
    run_id="run:package.replay",
)

PREDICT must reproduce the requested package output bindings exactly. EXPLAIN must emit at least one explanation block and may include the final bound predictions for the requested bindings. The package remains handle-free; all process-local model handles are supplied through artifact_handles.

TrainingRequest, TrainingContractProjection, ParameterProjection, CacheNamespace and PortablePredictorPackage are validated by the native dag-ml-core contracts. sign_training_request() canonicalizes and signs an unsigned request through the same native structs, and sample_relation_set_fingerprint_json() exposes the core relation fingerprint for host-side data envelope assembly. project_training_request() is also available as a functional facade. The binding does not reproduce parameter projection, capability-derived influence or portability rules in Python.

execute_training() requires an envelope map keyed by the exact node_id.input_name requirement key plus the matching relations and influence manifest. The PyO3 layer releases the GIL while the core runs and reacquires it only for controller callbacks. TrainingResult retains the controller registry, attested provider and artifact store until detach() or object destruction; portable outcome, bundle, scores, outputs and artifact metadata remain readable after detach, while process-local handles are never serialized.

All Rust-side validation failures are raised as dag_ml.DagMlError. Native errors expose category, code, severity, remediation_hint, context, context_json and descriptor_json attributes for ADR-11-compatible handling.

Metadata

Release files for dag-ml 0.3.27

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dag-ml 0.3.27
File Size Uploaded
dag_ml-0.3.27.tar.gz 1.0 MB Details

Built distributions (wheels)

Table of built distributions (wheels) for dag-ml 0.3.27
File
dag_ml-0.3.27-cp311-abi3-win_amd64.whl CPython 3.11 abi3 Windows x86-64 Details
dag_ml-0.3.27-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.11 abi3 Linux glibc 2.17+ x86-64 Details
dag_ml-0.3.27-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.11 abi3 Linux glibc 2.17+ ARM64 Details
dag_ml-0.3.27-cp311-abi3-macosx_11_0_arm64.whl CPython 3.11 abi3 macOS 11.0+ ARM64 Details
dag_ml-0.3.27-cp311-abi3-macosx_10_12_x86_64.whl CPython 3.11 abi3 macOS 10.12+ x86-64 Details

Total release size: 52.0 MB

Release files / dag_ml-0.3.27.tar.gz

Download URL dag_ml-0.3.27.tar.gz
Size 1.0 MB
Tags Source
SHA-256 checksum
How to use checksums
2973394a427971a9c85eeacae332b97e4829f7cf459162e70b44be64f5538ad3
BLAKE2b-256 checksum
How to use checksums
220f954501b0f4acac48955fcc6564ed3b800e3c6b2cd472e21fc0902d4b62b6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 24, 2026.

Transparency log

Release files / dag_ml-0.3.27-cp311-abi3-win_amd64.whl

Download URL dag_ml-0.3.27-cp311-abi3-win_amd64.whl
Size 9.9 MB
Tags CPython 3.11 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
716943634401376ffac76bd5b8a85455ab91b71ac2087c4d9b2a04b5dd9ff8b4
BLAKE2b-256 checksum
How to use checksums
30f69c01087233c9cdaa49be0b760979971f601652ff3c02327a48011cb2ca9e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 24, 2026.

Transparency log

Release files / dag_ml-0.3.27-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL dag_ml-0.3.27-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 10.7 MB
Tags CPython 3.11 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
f20fe88f812b5c418ad007e6028999bc49b892efee78f7c70f7895d3c8b7470a
BLAKE2b-256 checksum
How to use checksums
f459238eeae98e60e9607a3a8d17e12d47e06a89c4921128da79a48e05218b57
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 24, 2026.

Transparency log

Release files / dag_ml-0.3.27-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL dag_ml-0.3.27-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 10.7 MB
Tags CPython 3.11 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
dc4068bdc42ec6a5b6b0f34769bc67649f4556c480f5a9fa06be64b74373ae0b
BLAKE2b-256 checksum
How to use checksums
8425cb95ac669276909d3c1141ec97b3047f96429cb2e3456d0ee19e3dc77b04
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 24, 2026.

Transparency log

Release files / dag_ml-0.3.27-cp311-abi3-macosx_11_0_arm64.whl

Download URL dag_ml-0.3.27-cp311-abi3-macosx_11_0_arm64.whl
Size 9.6 MB
Tags CPython 3.11 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
3dea7d869c037490887b4cd13f8ce13ad95f2cb3fe08c1cc265e10cff24e1b76
BLAKE2b-256 checksum
How to use checksums
ae9fe08d79b9914582682ff5ba7793a6b4a789272043e592bfba25660e6b1466
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 24, 2026.

Transparency log

Release files / dag_ml-0.3.27-cp311-abi3-macosx_10_12_x86_64.whl

Download URL dag_ml-0.3.27-cp311-abi3-macosx_10_12_x86_64.whl
Size 10.1 MB
Tags CPython 3.11 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
13a1a51c269efdf762c6c475d41a9e15c1c051459f14fdee3d0ca4ebb51fd0a5
BLAKE2b-256 checksum
How to use checksums
2fba013666e9893bd3149d3ac499200361e75c7fb7f788a0135c2a442a35d44e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 24, 2026.

Transparency log

Release history Release notifications | RSS feed

0.3.32

6 release files

0.3.30

6 release files

0.3.29

6 release files

0.3.28

6 release files

This release

0.3.27 This release

6 release files

0.3.26

6 release files

0.3.22

6 release files

0.3.21

6 release files

0.3.20

6 release files

0.3.19

6 release files

0.3.18

6 release files

0.3.17

6 release files

0.3.16

6 release files

0.3.15

6 release files

0.3.14

6 release files

0.3.13

6 release files

0.3.11

6 release files

0.3.10

6 release files

0.3.9

6 release files

0.3.8

6 release files

0.3.7

6 release files

0.3.6

6 release files

0.3.5

6 release files

0.3.4

6 release files

0.3.3

6 release files

0.3.2

6 release files

0.3.0

6 release files

0.2.7

6 release files

0.2.6

6 release files

0.2.5

6 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page