LinkML Generator
Overview
gen-linkml --format json personinfo.yaml > personinfo.linkml.json
While the output is semantically consistent with the input, there may be additional transformations applied dependening on the command line options.
Use Case
When developing applications that are schema-driven, it can be useful to provide a pre-packaged linkml file in JSON that has various operations performed:
imports merged
all inferred/induced slot properties materialized as attributes
This frees the application from the need to implement logic for either import resolution or inheritance logic, everything is pre-materialized in one place.
For more details, see the developers guide
Docs
Command Line
gen-linkml
gen-linkml [OPTIONS] YAMLFILE
Options
- --materialize-attributes, --no-materialize-attributes
Materialize induced slots as attributes
- Default
True
- -f, --format <format>
Output format
- Default
json
- Options
json | yaml
- --metadata, --no-metadata
Include metadata in output
- Default
True
- --useuris, --metauris
Include metadata in output
- Default
True
- -im, --importmap <importmap>
Import mapping file
- --log_level <log_level>
Logging level
- Default
WARNING
- Options
CRITICAL | ERROR | WARNING | INFO | DEBUG
- -v, --verbose
verbosity
- --mergeimports, --no-mergeimports
Merge imports into source file (default=mergeimports)
Arguments
- YAMLFILE
Required argument
Code
- class linkml.generators.linkmlgen.LinkmlGenerator(schema: Union[str, TextIO, linkml_runtime.linkml_model.meta.SchemaDefinition], materialize_attributes: bool, mergeimports: bool, format: str, **kwargs)[source]
This generator provides a direct conversion of a LinkML schema into json, optionally merging imports and unrolling induced slots into attributes