Ossie¶
Overview¶
Apache Ossie (formerly OSI – Open Semantic Interchange) is a vendor-neutral specification for exchanging semantic models between data analytics, AI and BI tools. This generator targets the Ossie ontology specification, which is used for domain models: concepts and the relationships between them.
gen-ossie personinfo.yaml
linkml generate ossie --format json personinfo.yaml
Maintained in ohi LinkML¶
Important
The generator itself is not implemented in this repository. This is a wrapper around the Ossie generator in ohi LinkML.
Please report any bug reports or feature requests at https://github.com/NeverBlink-OSS/ohi/issues
You can also try the generator without installing anything in the in-browser playground.
When reporting bugs, please include the versions of both linkml and ohi LinkML.
You can find them by running gen-ossie --version.
What gets generated¶
LinkML |
Ossie |
|---|---|
Class |
|
Enum |
|
Type |
|
Slot |
Relationship of each class that uses it |
|
|
|
|
Required slot |
|
|
|
The full mapping is described in the ohi LinkML documentation.
Limitations¶
The schema has to be a path to a local file. ohi LinkML reads it and resolves its imports
from disk itself, so a URL or an already-parsed SchemaDefinition is refused.
Docs¶
Command Line¶
gen-ossie¶
Generate an Apache Ossie ontology from a LinkML model.
Classes become EntityType concepts, enums and types become ValueType concepts, slots become relationships, and is_a and mixins become extends. Use –pruning-mode to leave out elements that are not reachable from the root schema or from the tree root class.
The generator is implemented in ohi LinkML, which is maintained separately. Please submit bug reports and feature requests to https://github.com/NeverBlink-OSS/ohi/issues
gen-ossie [OPTIONS] YAMLFILE
Options
- -V, --version¶
Show the linkml and ohi LinkML versions and exit.
- -o, --output <output>¶
Output file name. Writes to stdout if not given.
- --tree-root <tree_root>¶
Tree root class name to use instead of the schema-defined tree_root.
- --pruning-mode <pruning_mode>¶
Which unused elements (classes, types, enums) to remove. tree_root - remove all elements unreachable from the tree_root class. schema - remove all elements unreachable from any of the classes defined in the root schema. skip - do not remove unused elements.
- Default:
'skip'- Options:
skip | schema | tree_root
- -f, --format <format>¶
Output format
- Default:
'yaml'- Options:
yaml | json
- --metadata, --no-metadata¶
Include metadata in output
- Default:
True
- --generation-date, --no-generation-date¶
Stamp output with the generation_date timestamp. Off by default so output is reproducible across runs.
- Default:
False
- --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.ossiegen.OssieGenerator(schema: str | Path, format: str | None = None, metadata: bool = True, useuris: bool | None = None, include_generation_date: bool = False, log_level: int | None = 30, mergeimports: bool | None = True, source_file_date: str | None = None, source_file_size: int | None = None, logger: Logger | None = None, verbose: bool | None = None, output: str | None = None, directory_output: bool = False, base_dir: str | None = None, importmap: str | Mapping[str, str] | None = None, stacktrace: bool = False, include: str | Path | None = None, pruning_mode: str = 'skip', tree_root: str | None = None)[source]¶
Generates an Ossie ontology describing the schema’s classes, slots, enums and types.
>>> from linkml.generators.ossiegen import OssieGenerator >>> schema = ''' ... id: https://example.org/personinfo ... name: personinfo ... prefixes: ... linkml: https://w3id.org/linkml/ ... personinfo: https://example.org/personinfo/ ... default_prefix: personinfo ... default_range: string ... imports: ... - linkml:types ... classes: ... Person: ... description: A human being ... attributes: ... age: ... range: integer ... ''' >>> print(OssieGenerator(schema).serialize()) version: 0.2.0.dev0 name: personinfo prefixes: personinfo: https://example.org/personinfo/ ontology: - concept: Person type: EntityType iri: personinfo:Person description: A human being relationships: - name: age iri: personinfo:age roles: - concept: Integer multiplicity: ManyToOne verbalizes: - "{Person} age {Integer}"
- class linkml.generators.common.ohi.OhiBackedGenerator(schema: str | Path, format: str | None = None, metadata: bool = True, useuris: bool | None = None, include_generation_date: bool = False, log_level: int | None = 30, mergeimports: bool | None = True, source_file_date: str | None = None, source_file_size: int | None = None, logger: Logger | None = None, verbose: bool | None = None, output: str | None = None, directory_output: bool = False, base_dir: str | None = None, importmap: str | Mapping[str, str] | None = None, stacktrace: bool = False, include: str | Path | None = None)[source]¶
Base class for generators that use ohi LinkML.
Subclasses set
valid_formatsand implementserialize()by calling one method onohi_schema.Loading a schema is the expensive part and every generator call on a loaded schema is cheap, so
ohi_schemais built on first use and then reused. Release it withclose(), or use the generator as a context manager:with SomeGenerator("schema.yaml") as generator: print(generator.serialize())
Dropping the last reference will release it too, but only when the garbage collector gets to it.
Unlike
Generatorthis takes a path and nothing else, and nothing here parses the schema: ohi LinkML reads it, resolves its imports, and is the only thing that has an opinion about it. That is also why the options inUNSUPPORTED_OPTIONSare refused rather than emulated.- property ohi_schema¶
The schema as ohi LinkML sees it, loaded on first use and then reused.
- Returns:
a
ohi_linkml.Schema, owned by this generator. Do not close it; callclose()instead.- Raises:
ImportError – if the ohi LinkML bindings are not installed.
ohi_linkml.SchemaLoadError – if ohi LinkML cannot load the schema.