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

dag_ml._dag_ml.probe_data_view_in_process(envelope_json, request_json, view_callback) exercises the host view callback without fitting a model. It creates native parent/view handles, rejects IDs outside the envelope relations, and requires a receipt with the same handle, view key, ordered IDs, and SHA-256 schema/content fingerprints. The caller supplies the request; this diagnostic does not prove scheduler fold membership or that training consumed those buffers. CV/refit and explicit phase execution accept their own view callbacks; the host must bind each receipt to the actual buffers consumed by that task. The standalone probe does not qualify those complete execution paths.

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. An optional view_callback receives every scheduler-selected request and its opaque handle in REFIT or PREDICT. The host materializes its actual buffer and returns a DataViewReceipt; Rust checks the handle, key, ordered identities and canonical digests before dispatching the operator. This reuses the CV bridge while retaining the explicit phase provider's training-order and cohort guards. Omitting the callback preserves the existing handle-only path. Neither path moves feature buffers into Rust or makes a host-model portability claim.

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

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.4.3
File Size Uploaded Provenance Actions
dag_ml-0.4.3.tar.gz 2.1 MB With provenance Details for dag_ml-0.4.3.tar.gz

Built distributions (wheels)

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

Total release size: 61.8 MB

Release files / dag_ml-0.4.3.tar.gz

Download URL dag_ml-0.4.3.tar.gz
Size 2.1 MB
Tags Source
SHA-256 checksum
How to use checksums
2c2a93ce4298a31533f4583de5fcff1921e6d30bf54c2cb3720f1eede3ba2928
BLAKE2b-256 checksum
How to use checksums
f26cfb85e92ebe1676676fd79f832dd651dd1a87ca3053cf4f7ac0355cdd75ea
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 17, 2026.

Transparency log

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

Download URL dag_ml-0.4.3-cp311-abi3-win_amd64.whl
Size 11.6 MB
Tags CPython 3.11 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
551f567b9f1b7646b401b61f1d6a6df27ea16d063ef60893d5bd730d79d5f349
BLAKE2b-256 checksum
How to use checksums
f8becc344da2a358ad395179af58858811c6184522c7898ad11d12d5fb4329a0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 17, 2026.

Transparency log

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

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

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 Nov 17, 2026.

Transparency log

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

Download URL dag_ml-0.4.3-cp311-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Size 12.5 MB
Tags CPython 3.11 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
e56efe1eef64a3581c40812324e8fbf2050721d2a9091fa55b0005d8af031fae
BLAKE2b-256 checksum
How to use checksums
0719deecd20a963e92b529c104a7f66de944f445eb52cc3b9525f67eb0825b27
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 17, 2026.

Transparency log

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

Download URL dag_ml-0.4.3-cp311-abi3-macosx_11_0_arm64.whl
Size 11.3 MB
Tags CPython 3.11 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
074842c71d096b7b581cf917402efcf81c7cc3c1ab57f682bc3c7803ceb65903
BLAKE2b-256 checksum
How to use checksums
bd796f328b997bc20843c00248379ad0a35b2eaacd31acda4c9ca6ae3a474c7e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 17, 2026.

Transparency log

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

Download URL dag_ml-0.4.3-cp311-abi3-macosx_10_12_x86_64.whl
Size 11.7 MB
Tags CPython 3.11 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
9a75520f4b5bfd2bbd9acb36b5d2894c84f111721fa98d72e1e1c368b4b0bfa5
BLAKE2b-256 checksum
How to use checksums
51b47d88cb6901adc9ddb8b7a4002f3e9290234fc3765aac74ee6933506a7e8e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 17, 2026.

Transparency log

Security for dag-ml 0.4.3

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.

Full provenance

All 6 files in this release have been uploaded with provenance metadata.

Select from 6 files

Attestation for dag_ml-0.4.3.tar.gz

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 Nov 17, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.4.3 This release

6 release files Full provenance

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