This project is currently in beta. APIs may evolve as features are added.
dartfx-cdif is a Python toolkit for working with the Cross-Domain Interoperability Framework (CDIF) profiles, models, and metadata utilities within the Data Artifex ecosystem.
It provides:
- Generated Pydantic v2 + RDF (
dartfx-rdf) models for all CDIF profiles (core,discovery,data_description,data_structure,provenance,manifest,codelist, andcomplete) with dual support for framed JSON-LD and fullrdflibserialization/deserialization (Turtle, JSON-LD, RDF/XML, N-Triples). - A deterministic code generator (
dartfx.cdif.codegen) that converts upstream CDIF Draft 2020-12 JSON Schemas,CDIF-context-2026.jsonld, and SKOS.ttlvocabularies into Python modules whenever CDIF profiles change or version. - A Profile Registry & loader (
ProfileRegistry,detect_profiles,load_cdif) for auto-detecting declared or implied CDIF profiles and checking profile conformance (validate_conformance()). - A Typer CLI (
cdif) for inspecting profiles, validating CDIF metadata files, and regenerating models.
This project recommends using uv for fast and reliable Python package management.
In the monorepo shared environment (see PYREFLY.md):
uv sync --group dev --active --inexactFor standalone local setups:
uv sync --group dev# Run tests
hatch run test
# Check types
hatch run types:checkfrom dartfx.cdif import CdifCoreDataset
from dartfx.cdif.models.common import CatalogRecord, Identifier, ObjectReference, Person
dataset = CdifCoreDataset(
id="https://example.org/dataset/1",
name="Ocean Temperature Observations",
identifier=Identifier(
property_id="https://registry.identifiers.org/registry/doi",
value="10.1234/example",
),
date_modified="2026-11-16",
license=["https://creativecommons.org/licenses/by/4.0/"],
url="https://example.org/dataset/1/landing",
creator=[Person(name="Ada Lovelace")],
subject_of=CatalogRecord(
id="https://example.org/record/1",
additional_type=[ObjectReference(id="dcat:CatalogRecord")],
conforms_to=[ObjectReference(id="https://w3id.org/cdif/core/1.1")],
),
jsonld_context=CdifCoreDataset.default_jsonld_context(),
)
# Check profile required & conditional (anyOf) constraints
violations = dataset.validate_conformance()
# Serialize to framed JSON-LD or RDF Turtle
jsonld_text = dataset.to_jsonld()
turtle_text = dataset.to_rdf("turtle")
# Deserialize back from Turtle or JSON-LD
from_turtle = CdifCoreDataset.from_rdf(turtle_text, format="turtle")
from_jsonld = CdifCoreDataset.from_jsonld(jsonld_text)from pathlib import Path
from dartfx.cdif import detect_profiles, load_cdif
model = load_cdif(Path("example.jsonld"))
profiles = detect_profiles(model)
violations = model.validate_conformance()# List registered CDIF profiles and model classes
cdif profiles
# Load and validate a CDIF JSON-LD or RDF file
cdif validate path/to/metadata.jsonld
# Regenerate Pydantic + RDF models from upstream git-cdif schemas
cdif codegen --cdif-root /path/to/git-cdifVersions are managed dynamically in src/dartfx/cdif/__about__.py. Use hatch version to view or bump the version.
uv run --active ruff format --check .
uv run --active ruff check .
uv run --active pyrefly check src tests
uv run --active pytesthatch run docs:buildContributions are welcome! Please see CONTRIBUTING.md for guidelines and information on how to get started.