{"id":7372,"library":"linkml","title":"Linked Open Data Modeling Language (LinkML)","description":"LinkML is a powerful framework for defining data models, particularly for linked open data and semantic web applications. It allows users to define schemas using a YAML-based language, and then generate artifacts such as dataclasses, JSON schemas, ShEx schemas, and more, for various programming languages and data formats. It supports schema validation, data transformation, and integration with existing ontologies. The current version is 1.10.0, and it has an active development and release cadence, with major versions often introducing significant changes.","status":"active","version":"1.10.0","language":"en","source_language":"en","source_url":"https://github.com/linkml/linkml","tags":["schema","data modeling","linked data","semantic web","ontology","codegen","yaml"],"install":[{"cmd":"pip install linkml","lang":"bash","label":"Install core LinkML library"}],"dependencies":[{"reason":"Provides core data structures, utilities, and the LinkML metamodel. It is a fundamental dependency for LinkML.","package":"linkml-runtime","optional":false},{"reason":"Used by PythonGenerator for generating Pydantic-compatible classes, which offers robust data validation and serialization features.","package":"pydantic","optional":true}],"imports":[{"note":"The 'linkml-model' package was deprecated and its functionality absorbed into 'linkml-runtime' from version 1.0.0.","wrong":"from linkml_model.meta import SchemaDefinition","symbol":"SchemaDefinition","correct":"from linkml_runtime.linkml_model.meta import SchemaDefinition"},{"symbol":"PythonGenerator","correct":"from linkml.generators.pythongen import PythonGenerator"},{"symbol":"YAMLLoader","correct":"from linkml_runtime.loaders import YAMLLoader"},{"symbol":"dump_yaml","correct":"from linkml_runtime.utils.datautils import dump_yaml"}],"quickstart":{"code":"import os\nfrom linkml_runtime.linkml_model.meta import SchemaDefinition\nfrom linkml.generators.pythongen import PythonGenerator\nfrom linkml_runtime.loaders import YAMLLoader\nfrom linkml_runtime.utils.datautils import dump_yaml\n\n# Define a simple LinkML schema in YAML string\nschema_content = \"\"\"\nid: http://example.org/my_schema\nname: my_schema\ndescription: A simple LinkML schema example\n\nprefixes:\n  ex: http://example.org/my_schema/\n\ndefault_prefix: ex\n\nclasses:\n  Person:\n    slots:\n      - id\n      - name\n      - age\n\nslots:\n  id:\n    identifier: true\n    range: string\n  name:\n    range: string\n  age:\n    range: integer\n    minimum_value: 0\n\"\"\"\n\n# 1. Load the schema definition\nloader = YAMLLoader()\nschema = loader.loads(schema_content, target_class=SchemaDefinition)\nprint(f\"Successfully loaded schema: {schema.name}\")\n\n# 2. Generate Python dataclasses from the schema\ngen = PythonGenerator(schema=schema)\npython_code = gen.serialize()\n\n# For quickstart, execute generated code in current namespace\n# In a real application, you'd write this to a file and import it.\nnamespace = {}\nexec(python_code, namespace)\n\n# Get the generated 'Person' class\nPerson = namespace['Person']\n\n# 3. Create an instance of the generated class\np = Person(id=\"P001\", name=\"Alice Smith\", age=30)\nprint(f\"Created person instance: {p.name}\")\n\n# 4. Dump the instance to YAML\nyaml_output = dump_yaml(p)\nprint(\"\\n--- Generated YAML output ---\")\nprint(yaml_output)\n","lang":"python","description":"This quickstart demonstrates how to define a simple LinkML schema as a string, load it, generate Python dataclasses from it, create an instance of a generated class, and then serialize that instance back into YAML. This showcases the core model definition, code generation, and data handling capabilities."},"warnings":[{"fix":"Refer to the official LinkML migration guides and release notes for version 1.0.0. Carefully check import paths (e.g., `linkml_runtime` vs `linkml-model`) and update CLI commands.","message":"LinkML underwent a significant rewrite with version 1.0.0. The previous `linkml-model` package was absorbed, and many internal APIs, command-line interface, and generator outputs changed. This is a major breaking change for users upgrading from pre-1.0.0 versions.","severity":"breaking","affected_versions":"<1.0.0 to >=1.0.0"},{"fix":"Ensure you are importing from the correct package: `linkml_runtime.linkml_model.meta` for schema definitions and `linkml.generators` for generators, `linkml_runtime.loaders` for loaders, etc.","message":"The separation of `linkml-runtime` and `linkml` can be confusing. `linkml-runtime` contains core metamodel definitions (like `SchemaDefinition`) and utilities (loaders, dumpers, validators), while `linkml` contains generators and the CLI. Incorrect imports are common.","severity":"gotcha","affected_versions":"All versions >=1.0.0"},{"fix":"Always validate your LinkML schema using `linkml validate your_schema.yaml` after upgrading LinkML. Consult release notes for specific schema syntax changes.","message":"Schema definition syntax, while generally stable, can have minor evolutions (e.g., new keywords, changes in range handling) between releases. Older schemas might require slight adjustments to work with newer LinkML versions.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Pin your LinkML version if strict consistency of generated output is critical for your project. After upgrading, always regenerate artifacts and perform regression testing on consuming applications.","message":"The output of generators (e.g., `PythonGenerator`, `JSONGenerator`) can change across versions, particularly around how inheritance, types, defaults, and prefixes are represented. This can break downstream code or systems that rely on the exact structure of generated artifacts.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Update your import statements. For example, `from linkml_model.meta import SchemaDefinition` should become `from linkml_runtime.linkml_model.meta import SchemaDefinition`.","cause":"Attempting to import from the deprecated 'linkml-model' package, which was removed in LinkML 1.0.0 and integrated into 'linkml-runtime'.","error":"ModuleNotFoundError: No module named 'linkml_model'"},{"fix":"Review your data and the corresponding LinkML schema definition. Ensure data types match the `range` definitions and that values respect any specified constraints. Use `linkml validate` on your data against your schema for detailed error messages.","cause":"Data being processed does not conform to the types or constraints (e.g., range, minimum_value, pattern) defined in your LinkML schema.","error":"linkml_runtime.utils.validation.ValidationError: Value '...' is not of type '...'"},{"fix":"Verify that 'MyClassName' is correctly spelled and defined in your LinkML schema. Check the schema's `id`, `name`, `prefixes`, and `default_prefix` to ensure correct resolution of class names.","cause":"The PythonGenerator (or other generators) cannot locate a class named 'MyClassName' within the loaded schema. This can happen due to typos, incorrect prefix resolution, or if the class is not properly defined.","error":"linkml_runtime.utils.generator.GeneratorException: Cannot find target class for generation: 'MyClassName'"}]}