Skip to content

About

Automated FAIR compliance assessment for dataset metadata

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

datafairwatch

License: MIT ORCID Software Heritage

Automated FAIR compliance assessment for dataset metadata. Combines deterministic rule checks, external validator APIs, SHACL structural validation, and AI-powered synthesis into a single pipeline.

Author: Priyanka — ORCID 0000-0002-6844-6493 Live app: https://datafairwatch.onrender.com · Cite: CITATION.cff · codemeta.json

Architecture

                    ┌──────────────┐
                    │   FastAPI     │  POST /api/assess
                    │   (API + UI)  │  POST /api/assess/upload
                    └──────┬───────┘
                           │
                    ┌──────▼───────┐
                    │   Pipeline    │  Orchestrator
                    └──────┬───────┘
                           │
          ┌────────────────┼────────────────┐
          ▼                ▼                ▼
   ┌──────────────┐ ┌──────────────┐ ┌──────────────┐
   │ Tier 1: FTR  │ │ Tier 2:      │ │ Tier 3:      │
   │ Rule Engine  │ │ Validators   │ │ Analyser     │
   │ + SHACL      │ │ (FAIR-       │ │ (Claude      │
   │ (zero AI)    │ │  Checker)    │ │  tool-use)   │
   │              │ │              │ │              │
   └──────────────┘ └──────────────┘ └──────────────┘

Tier 0 — RDF syntax validation (rdflib, pre-flight gate)

Tier 1 — Deterministic checks: 20 SPARQL-based FTR competency questions + SHACL structural validation against pluggable profiles (DCAT-AP, Health-DCAT-AP)

Tier 2 — External validator APIs (FAIR-Checker). F-UJI support is available but disabled by default (requires self-hosted instance)

Tier 3 — Claude Analyser Agent: resolves conflicts, handles ambiguous principles, generates actionable recommendations

Try it

A hosted instance runs at https://datafairwatch.onrender.com. Paste any of these into the URL tab — they all return RDF directly, which is what the pipeline expects:

Example What it exercises
https://fdp.healthdata.nl/dataset/0dbf32dc-f451-4353-b60c-133e4464f786 A dataset in the Health-RI FAIR Data Point — scores ~0.57, so several checks fail
https://fdp.healthdata.nl A FAIR Data Point root record — scores ~0.83
https://www.w3.org/ns/dcat.ttl The DCAT vocabulary itself — a clean, well-formed graph

The URL must serve RDF (Turtle, RDF/XML, JSON-LD or N-Triples). A landing page or a DOI that resolves to HTML is rejected — the pipeline reports that it received HTML instead of RDF. To try metadata you have on hand, use the Paste RDF tab:

<http://example.org/d> <http://purl.org/dc/terms/title> "My dataset" .

The hosted instance runs on a free tier with a small daily assessment budget, and the first request after an idle period takes a few seconds while the container wakes up.

Quick Start

Prerequisites

  • Python 3.11+
  • uv (recommended) or pip

Install

uv pip install -e ".[dev]"

Configure

Copy .env.example to .env and set your Anthropic API key:

cp .env.example .env
# Edit .env and set ANTHROPIC_API_KEY=sk-ant-...

Run

uvicorn datafairwatch.api.main:app --reload

Open http://localhost:8000 for the dashboard UI.

Docker

docker compose up --build

Input Modes

The API accepts three input modes:

  1. URL — POST /api/assess with {"dataset_url": "https://..."}
  2. Paste — POST /api/assess with {"raw_content": "@prefix dcat: ..."}
  3. Upload — POST /api/assess/upload with multipart file (.ttl, .rdf, .jsonld, .nt)

All modes support a profile parameter: "dcat-ap" (default) or "health-dcat-ap".

SHACL Profiles

Pluggable SHACL profiles for structural validation:

Profile Description Shapes
dcat-ap Standard DCAT-AP constraints fair_shacl_shapes.ttl
health-dcat-ap DCAT-AP + HealthDCAT-AP Release 6 extensions Both shapes files

To add a new profile (e.g., GeoDCAT-AP):

  1. Create datafairwatch/reference/geodcat_ap_shapes.ttl
  2. Add one line to PROFILE_REGISTRY in shacl_validator.py

API Endpoints

Method Path Description
POST /api/assess Run full FAIR assessment (URL or raw content)
POST /api/assess/upload Assess uploaded RDF file
GET /api/assess/{run_id} Retrieve cached assessment
GET /api/assess/{run_id}/report.json Download JSON report
GET /api/assess/{run_id}/report.pdf Download PDF report
GET /api/health Deep health check
GET /api/budget Remaining daily assessment budget
GET /api/profiles Available SHACL profiles
GET /api/profile-hint Auto-detect Health-DCAT-AP
GET /references References & further reading

Rate Limits

  • Per-IP: 2 requests/minute
  • Global daily: 2 assessments/day (configurable via DAILY_GLOBAL_LIMIT)

Rate limits protect the Anthropic API token budget. Disabled when TESTING=1.

Security

  • Input sanitisation (control characters, prompt injection patterns)
  • RDF poisoning detection (oversized literals, embedded scripts)
  • Prompt boundary markers around untrusted data sent to Claude
  • Security headers (CSP, X-Frame-Options, X-Content-Type-Options)
  • Configurable CORS (CORS_ALLOWED_ORIGINS env var)
  • File upload limits (1 MB max, extension whitelist)

Testing

# Unit tests (fast, no API calls)
pytest tests/unit/ -v

# Deterministic evals (no API calls)
pytest tests/evals/ -v

# LLM-as-judge evals (requires ANTHROPIC_API_KEY)
ANTHROPIC_API_KEY=sk-... pytest tests/evals/ -k "LLMAsJudge" -v

# Full suite with coverage
pytest tests/ --cov=datafairwatch --cov-report=term-missing

Environment Variables

Variable Default Description
ANTHROPIC_API_KEY (required) Claude API key
ANTHROPIC_MODEL claude-sonnet-4-20250514 Claude model ID
FAIR_CHECKER_URL https://fair-checker.france-bioinformatique.fr FAIR-Checker endpoint
FUJI_API_URL (disabled) F-UJI API endpoint (requires self-hosted instance)
FUJI_API_USERNAME (disabled) F-UJI basic auth username
FUJI_API_PASSWORD (disabled) F-UJI basic auth password
MAX_ANALYSER_STEPS 5 Max Claude tool-use loop iterations
AGENT_TIMEOUT_SECONDS 60 Timeout for external validator calls
DAILY_GLOBAL_LIMIT 2 Max assessments per day
CORS_ALLOWED_ORIGINS * Comma-separated allowed origins
SHACL_ENABLED 1 Set to 0 to disable SHACL validation
LOG_LEVEL INFO Logging level
TESTING 0 Set to 1 to disable rate limits
RUNS_DIR ./runs Directory for persisted assessment JSON files

Project Structure

datafairwatch/
├── agents/           # Validator wrappers + Analyser Agent
│   ├── analyser.py   # Claude tool-use loop (only AI component)
│   ├── orchestrator.py
│   ├── fuji.py, fair_checker.py
├── api/              # FastAPI app, schemas, middleware, security
│   ├── main.py
│   ├── schemas.py
│   ├── security.py   # Input sanitisation, RDF poisoning, prompt defence
│   ├── middleware.py  # Request ID + security headers
│   └── dependencies.py
├── models/           # Pydantic data models (Finding, Report, ValidatorResult)
├── reference/        # SHACL shapes, FAIR principles, FTR ontology
├── registry/         # Agent registry (agents.json loader)
├── rules/            # FTR rule engine, SPARQL checks, SHACL validator, RDF validator
├── tools/            # Analyser tools (fetch_url, check_lov, resolve_pid)
├── utils/            # Retry logic
├── pipeline.py       # Pipeline orchestrator
├── ftr_export.py     # FTR JSON-LD benchmark export
└── logging_config.py
runs/                 # Persisted assessment JSON files (git-ignored)
tests/
├── unit/             # Fast unit tests (no API calls)
├── evals/            # Deterministic + LLM-as-judge evals
│   └── seed_data/    # Golden + poison TTL files
└── integration/      # Docker integration tests

Report Persistence

Assessment reports are saved as timestamped JSON files in runs/:

runs/
├── a1b2c3d4_20260325T143022Z.json
├── e5f6g7h8_20260325T150112Z.json
└── .gitignore   # keeps data out of git
  • Reports are loaded into memory on server startup (survives restarts)
  • Override location with RUNS_DIR env var (e.g., for Docker volume mounts)
  • Each file contains the full ReportOut JSON including findings, scores, and FTR benchmark

Roadmap (Phase 2)

Planned improvements for future iterations:

Item Description Priority
Managed database Replace local JSON file store with Supabase (free tier: 500MB Postgres) or Render Postgres for multi-instance deployment and queryable history High
Structured JSON logging Swap text log formatter for JSON output so log aggregators (CloudWatch, Datadog, ELK, Loki) can parse and query by run_id natively High
Additional SHACL profiles GeoDCAT-AP, DCAT-AP-IT, and other domain-specific profiles Medium
Batch assessment API Accept multiple dataset URLs in a single request Medium
Historical dashboards Query and visualise trends across assessments over time (requires database) Medium
Health-RI semantic checks New rules for health-dcat-ap profile: HRIO vocabulary alignment (I2) and SSSOM governance fields (R1.2). See Health-RI Semantic Interoperability High
Webhook notifications POST assessment results to a callback URL on completion Low
React frontend Replace vanilla HTML+JS if the UI complexity grows beyond single-page Low

Health-RI Semantic Interoperability checks

New deterministic rules for the health-dcat-ap profile, based on the Health-RI Semantic Interoperability framework:

  • check_i2_hrio(g) — Does the dataset reference vocabularies with HRIO mappings? Uses the HRIV predicates (hasExactMeaning, hasBroaderMeaningThan, hasNarrowerMeaningThan) to assess vocabulary alignment quality.
  • check_r1_2_sssom(g) — Does mapping metadata include SSSOM governance fields? Checks for author_id (ORCID), reviewer_id, mapping_justification, and mapping_date as provenance indicators.

These only run when profile=health-dcat-ap is selected. Implementation goes in datafairwatch/rules/sparql_checks.py as new graph-only checks.

Supabase upgrade path

The current run_store.py has a clean interface (save_report, load_all_reports, delete_report). To upgrade:

  1. pip install supabase
  2. Swap the file I/O in run_store.py for Supabase client calls
  3. Set SUPABASE_URL and SUPABASE_KEY env vars
  4. The rest of the app (API, pipeline, cache) stays unchanged

License

See LICENSE.

About

Automated FAIR compliance assessment for dataset metadata

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages