Getting started
Everything downstream of lokf.yaml — the JSON-LD context, JSON Schema, SHACL
shapes, and OWL ontology — is generated. One command reproduces every artifact,
re-assembles the reference bundle, re-validates it, and re-emits the RDF.
Prerequisites
Section titled “Prerequisites”- uv — Python package and project manager
- just — task runner (optional; every recipe is a
one-line
uv run …you can also type directly)
Install
Section titled “Install”git clone https://github.com/nicholsn/lokf.gitcd lokfuv syncuv sync creates a virtual environment with LinkML, rdflib, and PyYAML pinned
by uv.lock, and installs the lokf package with its lokf-build console
script.
Regenerate the artifacts
Section titled “Regenerate the artifacts”just builduv run lokf-buildThe build:
- runs the four LinkML generators against
lokf.yaml, - publishes the authoring context (aliasing
type→@typeandid→@id), - assembles
examples/acme-knowledge/into a single bundle document, - validates the bundle against the schema, and
- projects it to RDF (
examples/*.nt).
You can also run the individual generators by hand:
# JSON-LD context (aliased type->@type, id->@id for authoring)uv run gen-jsonld-context lokf.yaml > lokf.context.base.jsonlduv run gen-json-schema lokf.yaml > lokf.schema.jsonuv run gen-shacl lokf.yaml > lokf.shacl.ttluv run gen-owl lokf.yaml > lokf.owl.ttlValidate a bundle
Section titled “Validate a bundle”# `just build` assembles examples/acme-knowledge.bundle.json from the markdown, then:uv run linkml-validate -s lokf.yaml -C KnowledgeBundle examples/acme-knowledge.bundle.json# -> No issues found
# Or validate a single concept against its classuv run linkml-validate -s lokf.yaml -C Metric metric.jsonSee Validation for the JSON Schema / SHACL split.
Markdown → RDF in one command
Section titled “Markdown → RDF in one command”The lokf convert command projects a concept — or the whole bundle — to RDF
directly from the checkout you just cloned:
# a single concept -> Turtle on stdoutuv run lokf convert examples/acme-knowledge/metrics/weekly-active-users.md --format ttl
# the same thing behind the just recipejust gen-rdf-turtle examples/acme-knowledge/metrics/weekly-active-users.md--format also takes nt, jsonld, xml, n3, and trig; --output FILE
writes to disk instead of stdout. Point convert at the bundle directory
(examples/acme-knowledge) to project all six concepts at once.
Prefer to stay in Python? lokf.rdf.serialize is the same projection the CLI
calls:
from lokf import rdf
# a concept file, or the bundle directory — either resolves IRIs correctlyprint(rdf.serialize("examples/acme-knowledge/metrics/weekly-active-users.md", "ttl"))This is the whole thesis: OKF authoring in, RDF knowledge graph out. The Convert page covers every format and flag, and the mechanics of the projection are in Markdown to RDF.
Work on the docs
Section titled “Work on the docs”just docs # live-reloading dev serverjust docs-build # strict build, exactly as CI runs itcd web && npm install && npm run dev # live-reloading dev servercd web && npm ci && npm run build # strict build, exactly as CI runs itThe docs site is an Astro Starlight project
in web/; the graph data and API reference are generated from the lokf
package by a prebuild step.