Skip to content

linkml/linkml-tutorial

Repository files navigation

LinkML Tutorial 1: Introduction to LinkML

This is a repository that walks through the LinkML modeling language, helpful LinkML command line tools, and automatic schema documentation generation. The main branch of this repository has the resulting structure of a LinkML project that follows the tutorial to its completion. If you want to walk through the tutorial step by step, or refer back to a section of the tutorial at a later time, you can check out the stepped branches as needed.

For example, if you wanted to see the schema and infrastructure as it looks before implementing enumerations, you could refer to the step_5_validation branch.

For reference, the available sections are:

Section 1: Setting up a LinkML project from scratch

1-cookiecutter.jpg 2-cookiecutter.jpg 3-cookiecutter.jpg 4-cookiecutter.jpg 5-cookiecutter.jpg

Section 2: Developing a model, validating the model with test data

1a-modeling.jpg 1-modeling.jpg

Section 3: Checking the model for best practices (linting)

Section 4: Generating model documentation

1-doc.jpg 2-doc-details.jpg 3-doc-varieties.jpg 4-doc-reststop.jpg

Section 5: Schemasheets

1-schemasheets.jpg 2-schemasheets.jpg 3-schemasheets.jpg 4-schemasheets.jpg 5-schemasheets.jpg 6-schemasheets.jpg

Website

Repository Structure

Developer Documentation

Use the make command to generate project artifacts:

  • make all: make everything
  • make deploy: deploys site

To validate, create a poetry virtual environment, install the dependencies of this tutorial, and then run the tests and/or linkml-validate.

poetry install
poetry run linkml-validate -s src/linkml_tutorial/schema/linkml_tutorial.yaml src/data/examples/Person-001.yaml --target-class PersonCollection
poetry run linkml-validate -s src/linkml_tutorial/schema/linkml_tutorial.yaml src/data/examples/Animal-001.yaml --target-class AnimalCollection
make test

To generate documentation locally (requires mkdocs):

make testdoc

and navigate to http://127.0.0.1:8000/linkml-tutorial/

To convert the test data from YAML to JSON, run:

poetry run linkml-convert -s src/linkml_tutorial/schema/linkml_tutorial.yaml -t json src/data/examples/Animal-001.yaml --target-class AnimalCollection
poetry run linkml-convert -s src/linkml_tutorial/schema/linkml_tutorial.yaml -t json src/data/examples/Person-001.yaml --target-class PersonCollection

To convert the test data from YAML to RDF, run:

poetry run linkml-convert -s src/linkml_tutorial/schema/linkml_tutorial.yaml -t rdf src/data/examples/Animal-001.yaml --target-class AnimalCollection
poetry run linkml-convert -s src/linkml_tutorial/schema/linkml_tutorial.yaml -t rdf src/data/examples/Person-001.yaml --target-class PersonCollection

To compile changed schemasheets, run:

make compile-sheets

For more information, please consult the online LinkML tutorial A link to a video tutorial is coming soon!

Credits

this project was made with linkml-project-cookiecutter