Skip to main content

Offline-first ML dataset metadata validator for NFDI schemas (Croissant, ML-Schema, XDM, Chemotion, and more)

Project description

ml-validate

Offline-first Python validator for NFDI and ML metadata schemas.

Features

  • Bundled schema registry (no network required for schemas)
  • Python API via Validator and Profiler
  • CLI for CI/CD pipelines
  • Supports Croissant, ML-Schema, JSON Schema-based formats, and repository schemas

Install

pip install ml-validate

For URL validation support:

pip install "ml-validate[fetch]"

Quickstart

from ml_validate import Validator

validator = Validator()
result = validator.validate("dataset.json", "croissant-1.0")
print(result.passed, result.score)
ml-validate validate dataset.json --schema croissant-1.0

Example Data (Chemotion JSON-LD)

This repository now includes reusable example files in examples/ derived from:

  • ../example_datasets/JSON-LD_Analysis_874350-20260219122553.json

Included examples:

  • examples/chemotion_jsonld_sample.json: curated, realistic JSON-LD sample
  • examples/chemotion_jsonld_incomplete.json: intentionally incomplete sample for failure demos

The sample keeps the metadata structure and key fields used by the validators while avoiding large personal-author blocks.

CLI Examples

Validate a realistic Chemotion-style JSON-LD example with Croissant heuristics:

ml-validate validate examples/chemotion_jsonld_sample.json --schema croissant-1.0

Run a profile across two schemas and get machine-readable output:

ml-validate profile examples/chemotion_jsonld_sample.json --schemas croissant-1.0,w3c-ml-2.0 --output json

Show a failing validation case:

ml-validate validate examples/chemotion_jsonld_incomplete.json --schema croissant-1.0

Python API Examples

from pathlib import Path
from ml_validate import Profiler, Validator

payload = Path("examples/chemotion_jsonld_sample.json").read_text(encoding="utf-8")

validator = Validator()
single = validator.validate(payload, "croissant-1.0", source_type="json")
print(single.passed, single.score)

profiler = Profiler()
results = profiler.profile(payload, schema_ids=["croissant-1.0", "w3c-ml-2.0"], source_type="json")
for schema_id, result in results.items():
    print(schema_id, result.status, result.score)

CI/CD Example (GitHub Actions)

You can validate metadata files automatically in pull requests and fail the build when rules are not met.

PR validation workflow

Create .github/workflows/metadata-validation.yml:

name: Metadata Validation

on:
  pull_request:
    paths:
      - "datasets/**/*.json"
      - ".github/workflows/metadata-validation.yml"

jobs:
  validate:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v4

      - name: Set up Python
        uses: actions/setup-python@v5
        with:
          python-version: "3.12"

      - name: Install validator
        run: pip install ml-validate

      - name: Validate a dataset (strict)
        run: |
          ml-validate validate datasets/metadata.json \
            --schema croissant-1.0 \
            --fail-under 90

Multi-schema profile gate

Use profiling if your pipeline must satisfy more than one schema:

- name: Profile against multiple schemas
  run: |
    ml-validate profile datasets/metadata.json \
      --schemas croissant-1.0,w3c-ml-2.0 \
      --fail-under 80

Publish workflow note

If you publish this package from GitHub Actions, see:

  • .github/workflows/publish.yml

That workflow builds on tag push (for example v0.1.0) and uploads distributions to PyPI.

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

ml_validate-0.1.0.tar.gz (20.5 kB view details)

Uploaded Source

Built Distribution

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

ml_validate-0.1.0-py3-none-any.whl (23.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: ml_validate-0.1.0.tar.gz
  • Upload date:
  • Size: 20.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for ml_validate-0.1.0.tar.gz
Algorithm Hash digest
SHA256 058a6c4e9a14f46ac460bbc8663e785990e13bf7902bb422a8394dc574c97845
MD5 f9cddaf9c58483929e3ffe1f918e6f95
BLAKE2b-256 3b517eff05a9eebdacb23845e0a2f499ca4db30efb4ba55a0669d09c8a79ed67

See more details on using hashes here.

Provenance

The following attestation bundles were made for ml_validate-0.1.0.tar.gz:

Publisher: publish.yml on ataulhaleem/ai-validation-gate

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

  • Download URL: ml_validate-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 23.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for ml_validate-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a328b99ba1a909b59bf37095476c6beedfc15e4ded41c4cbfa1fde07b24d2ee9
MD5 30648fbc374c0edb3d7713a9a66ffcfc
BLAKE2b-256 544bbc350c57cc4eae289c70cea02bf2dc6c72060dbe288dafadcbaa76210223

See more details on using hashes here.

Provenance

The following attestation bundles were made for ml_validate-0.1.0-py3-none-any.whl:

Publisher: publish.yml on ataulhaleem/ai-validation-gate

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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