LinkML Generators#
The LinkML generator will “generate” LinkML schemas from LinkML.
While this may sound redundant, it can be useful to perform transformations as a part of generation
Docs#
Command Line#
gen-linkml#
gen-linkml [OPTIONS] YAMLFILE
Options
- -V, --version#
Show the version and exit.
- -o, --output <output>#
Name of JSON or YAML file to be created
- --materialize-patterns, --no-materialize-patterns#
Materialize structured patterns as patterns
- Default:
True
- --materialize-attributes, --no-materialize-attributes#
Materialize induced slots as attributes
- Default:
True
- --materialize, --no-materialize#
Materialize both, induced slots as attributes and structured patterns as patterns
- Default:
True
- -f, --format <format>#
Output format
- Default:
'json'
- Options:
json | yaml
- --metadata, --no-metadata#
Include metadata in output
- Default:
True
- --useuris, --metauris#
Use class and slot URIs over model uris
- 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. Takes precedence over –log_level.
- --mergeimports, --no-mergeimports#
Merge imports into source file (default=mergeimports)
- --stacktrace, --no-stacktrace#
Print a stack trace when an error occurs
- Default:
False
Arguments
- YAMLFILE#
Required argument
Code#
- class linkml.generators.linkmlgen.LinkmlGenerator(schema: str | ~typing.TextIO | ~linkml_runtime.linkml_model.meta.SchemaDefinition | ~linkml.utils.generator.Generator | ~pathlib.Path, schemaview: ~linkml_runtime.utils.schemaview.SchemaView | None = None, format: str | None = None, metadata: bool = True, useuris: bool | None = None, log_level: int | None = 30, mergeimports: bool | None = True, source_file_date: str | None = None, source_file_size: int | None = None, logger: ~logging.Logger | None = None, verbose: bool | None = None, output: str | None = None, namespaces: ~linkml_runtime.utils.namespaces.Namespaces | None = None, directory_output: bool = False, base_dir: str | None = None, metamodel_name_map: ~typing.Dict[str, str] | None = None, importmap: str | ~typing.Mapping[str, str] | None = None, emit_prefixes: ~typing.Set[str] = <factory>, metamodel: ~linkml.utils.schemaloader.SchemaLoader | None = None, stacktrace: bool = False, include: str | ~pathlib.Path | ~linkml_runtime.linkml_model.meta.SchemaDefinition | None = None, materialize_attributes: bool = False, materialize_patterns: bool = False, **_kwargs)[source]#
This generator provides a direct conversion of a LinkML schema into json, optionally merging imports and unrolling induced slots into attributes
- generatorname: ClassVar[str] = 'linkmlgen.py'#
Name of the generator. Override with os.path.basename(__file__)
- generatorversion: ClassVar[str] = '1.0.0'#
Version of the generator. Consider deprecating and instead use overall linkml version
- serialize(output: str | None = None, **kwargs) str [source]#
Generate output in the required format
- Parameters:
kwargs – Generator specific parameters
- Returns:
Generated output