Skip to content

Kapernikov/rust-linkml-core

 
 

Repository files navigation

linkml-core

core linkml schema operations written in rust

Crates

  • linkml_meta (src/metamodel): Autogenerated LinkML metamodel types and helpers. Optional Serde/PyO3 features for serialization and Python interop.
  • schemaview (src/schemaview): Schema loading, CURIE/URI conversion, resolution (feature-gated), and view utilities: SchemaView, ClassView, SlotView, EnumView.
  • linkml_runtime (src/runtime): Core runtime: LinkMLInstance parsing (YAML/JSON), basic validation, diff/patch, and Turtle serialization. Pure Rust library.
  • linkml_tools (src/tools): CLI tools wrapping the runtime and schemaview:
    • linkml-validate, linkml-convert, linkml-diff, linkml-patch, linkml-schema-validate.
  • linkml_runtime_python (src/python): PyO3 bindings and Python package (linkml_runtime_rust._native) exposing SchemaView and LinkMLInstance to Python; includes small Python helpers.
  • linkml_wasm (src/wasm): WASM build target (experimental).

SchemaView snapshots

SchemaView instances can be serialized into a snapshot—a self-contained YAML payload that carries every loaded schema definition along with the resolved-import lineage and primary-schema pointer. The snapshot can be reconstructed into an equivalent SchemaView without contacting remote import targets, making it ideal for building views server-side and shipping them to Python, WASM, or browser clients.

  • Rust: SchemaView::to_snapshot_yaml() / SchemaView::from_snapshot_yaml(...)
  • Python: SchemaView.to_snapshot_yaml(), SchemaView.from_snapshot_yaml(...)
  • WASM/JS: JsSchemaView::toSnapshotYaml(), schemaview_from_snapshot_yaml(...)

Regenerating the metamodel

In order to regenerate the metamodel:

  • Make sure you have a python virtual env with linkml_runtime (python!) installed, and that its active
  • In the ../linkml folder there should be a linkml checkout that is on a branch with the rust generator
  • run the regen.sh script from the root of this repo

Note that now the metamodel is generated from src/schemaview/tests/data/meta.yaml.

TODOs

  • generate the metamodel directly from the linkml meta repository

Development on the Python bindings

  1. Create a virtual env and activate it
  2. Install maturin (pip install maturin)
  3. From repo root, run: maturin develop -m src/python/Cargo.toml (or use your venv: ../env/bin/maturin develop -m src/python/Cargo.toml)

Now the linkml_runtime_rust module should be accessible.

Building and testing

  • Build all crates: cargo build --workspace
  • Run all tests: cargo test --workspace
  • Format: cargo fmt --all (check: cargo fmt --all -- --check)
  • Lint: cargo clippy --workspace --all-targets --all-features --exclude linkml_meta -- -D warnings --no-deps (excludes autogenerated linkml_meta)

About

core linkml schema operations written in rust :)

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Rust 80.5%
  • Python 19.5%