Skip to content

About

No description, website, or topics provided.

Resources

Code of conduct

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

dartfx-cdif

Development Status Documentation Ask DeepWiki Python 3.12+ Package Status CI Code style: Ruff pre-commit License: MIT Contributor Covenant

This project is currently in beta. APIs may evolve as features are added.

Overview

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, and complete) with dual support for framed JSON-LD and full rdflib serialization/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 .ttl vocabularies 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.

Installation

This project recommends using uv for fast and reliable Python package management.

Using uv (Recommended)

In the monorepo shared environment (see PYREFLY.md):

uv sync --group dev --active --inexact

For standalone local setups:

uv sync --group dev

Using Hatch

# Run tests
hatch run test

# Check types
hatch run types:check

Usage

Creating and Serializing a CDIF Dataset (JSON-LD & RDF)

from 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)

Loading & Auto-Detecting Profiles

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()

CLI

# 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-cdif

Development

Version Management

Versions are managed dynamically in src/dartfx/cdif/__about__.py. Use hatch version to view or bump the version.

Running Tests & Checks

uv run --active ruff format --check .
uv run --active ruff check .
uv run --active pyrefly check src tests
uv run --active pytest

Building Documentation

hatch run docs:build

Contributing

Contributions are welcome! Please see CONTRIBUTING.md for guidelines and information on how to get started.

About

No description, website, or topics provided.

Resources

Code of conduct

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Releases

Sponsor this project

Packages

Contributors

Languages