Skip to main content

ODIN Provenance Passport — Python instrumentation + CLI

Project description

OPP Python SDK (opp_py)

Instrumentation + CLI for ODIN Provenance Passport (OPP).

Features

  • @stamp(step_type, attrs=..., inputs=..., outputs=...) decorator emits start/end signed receipts.
  • Automatic input/output content IDs (CIDs) via optional callables.
  • Fallback lightweight OPE client (no external odin-sdk required) using env Ed25519 seed.
  • Graph + Passport generation (opp graph, opp passport).
  • Policy evidence aggregation & breach summary (opp policy).
  • Optional C2PA bridge (opp.c2pa.embed_bundle_cid) to embed bundle CID into images (extra deps).

Install (editable dev)

pip install -e packages/opp_py

Required env for stamping (generate a random 32‑byte seed once):

export OPP_GATEWAY_URL=http://127.0.0.1:8080
export OPP_SENDER_PRIV_B64=<base64url_32byte_seed>
export OPP_SENDER_KID=opp-sender

Generate a seed (PowerShell):

$bytes = New-Object byte[] 32; [Security.Cryptography.RandomNumberGenerator]::Create().GetBytes($bytes); \
$seed = [Convert]::ToBase64String($bytes).TrimEnd('=') -replace '\+','-' -replace '/','_'; $seed

Decorator Usage

from opp.decorators import stamp

@stamp(
		"train.v1",
		attrs={"model":"resnet"},
		inputs=lambda args, kwargs: {"hyperparams": kwargs.get("hp")},
		outputs=lambda ret: {"metrics": ret.get("metrics")}
)
def train(data, *, hp):
		# ... training ...
		return {"metrics": {"accuracy": 0.93}}

train([], hp={"lr":1e-3})

Emitted start receipt includes inputs_cid; end receipt includes outputs_cid and status.

CLI

opp graph --trace TRACE --gateway $OPP_GATEWAY_URL         # build minimal graph
opp validate --trace TRACE --gateway $OPP_GATEWAY_URL      # continuity + basic validation
opp passport --trace TRACE --gateway $OPP_GATEWAY_URL      # rich model/data passport JSON
opp policy --trace TRACE --gateway $OPP_GATEWAY_URL        # summarized policy evidence + breaches

Passport Fields (excerpt)

{
	"trace_id": "...",
	"receipts": 12,
	"steps": ["ingest.v1","train.v1"],
	"dataset_roots": ["sha256:..."],
	"model_id": "model-123",
	"metrics": {"accuracy": 0.93},
	"safety_flags": {"pii_redacted": true},
	"policy_engines": ["opa"],
	"policy_breaches": [{"rule":"no_public_data","outcome":"deny"}]
}

Policy Evidence

If receipts carry a normalized policy object with engine + decisions[], breaches are auto‑derived when an outcome is not in {allow, pass, ok}.

Optional C2PA Bridge

pip install c2pa Pillow
python examples/c2pa_embed.py image.png

Adds a custom assertion with the bundle_cid to the image manifest.

Airflow & Dagster Examples

See examples/airflow_dag.py and examples/dagster_job.py for task/op instrumentation and trace continuity.

Testing

pytest -q packages/opp_py/tests

Backward Compatibility

New fields are additive; existing receipt payload fields preserved. Hashing uses canonical JSON (stable order, no whitespace).

License

Apache 2.0

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

opp_py-0.1.0.tar.gz (12.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

opp_py-0.1.0-py3-none-any.whl (11.5 kB view details)

Uploaded Python 3

File details

Details for the file opp_py-0.1.0.tar.gz.

File metadata

  • Download URL: opp_py-0.1.0.tar.gz
  • Upload date:
  • Size: 12.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for opp_py-0.1.0.tar.gz
Algorithm Hash digest
SHA256 c9ea16cf77f479d86b60a8bc69c0bf416d0222ec358c15c6ccd144b4cbf456f2
MD5 a19e4c042704f5e0efe4a3735cdbd093
BLAKE2b-256 bd186c7527da30bbe9e0c567943c6d0e3aec739e176048f5fd12cc2ee5cd24b0

See more details on using hashes here.

File details

Details for the file opp_py-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: opp_py-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 11.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for opp_py-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 21b2b86899ef1a4e083afd1edf69ddf65784217a7eb97e4be1f4ad8e06fecbcf
MD5 493c39cfe7f9a7e548220ce9eb3ebc34
BLAKE2b-256 82c4f8618bc06e1c1e6ef932222973641362740d46421bb2225019ba550e39d1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page