Skip to content

RML Data Mapping

Declarative RML mappings for CSV, JSON, and XML sources via Morph-KGC.

Auto-generated docs

When trails is installed, run ENABLE_MKDOCSTRINGS=true ./scripts/docs-build for full docstring-extracted reference.

Mapping generation

Symbol Signature Description
generate_mapping generate_mapping(source_path: str \| Path, *, source_type: str = "csv", base_iri: str \| None = None, node_type_name: str \| None = None) -> GeneratedMapping Auto-generate an RML Turtle mapping from a source file's schema with type inference
GeneratedMapping GeneratedMapping(turtle: str, source_type: str, columns: list[str]) Result of generate_mapping

Mapping execution

Symbol Signature Description
run_mapping run_mapping(ctx, mapping_path: str \| Path, **source_overrides: str) -> MappingResult Execute an RML mapping and load results into the KG with PROV-O provenance
MappingResult MappingResult(triples_added: int, sources: list[str], duration_ms: float, activity_iri: str) Summary returned by run_mapping

Validation

Symbol Signature Description
validate_mapping validate_mapping(mapping_path: str \| Path) -> list[ValidationIssue] Parse and validate an RML mapping file without executing it. Empty list = all checks passed
ValidationIssue ValidationIssue(severity: str, message: str) A single validation finding ("error" or "warning")

Source helpers

Symbol Signature Description
rml_source function Helper for declaring RML logical sources