Importers¶
Importers take either a representation of a schema in a different language or example data and bootstraps a schema.
Importers are the opposite of Generators in the core LinkML framework
Warning
Generally importers take a less expressive language than LinkML and attempts to create the corresponding
LinkML schema. This may be less optimal than a hand-crafted schema. For example, when converting to a
representation that lacks inheritance, no is_a
slots
will be created.
Importing from JSON-Schema¶
The import-json-schema
command can be used:
schemauto import-json-schema tests/resources/model_card.schema.json
Importing from Kwalify¶
The import-kwalify
command can be used:
schemauto import-kwalify tests/resources/test.kwalify.yaml
Importing from OWL¶
You can import from a schema-style OWL ontology. This must be in functional syntax
Use robot to convert ahead of time:
robot convert -i schemaorg.ttl -o schemaorg.ofn
schemauto import-owl schemaorg.ofn
Importing from SQL¶
You can import a schema from a SQL database
The default is to assume a SQLite database:
schemauto import-sql path/to/my.db
You can also connect to any database server provided you have the necessary client software installed, using a SQL Alchemy connection path.
For example, for the RNA Central public database
schemauto import-sql postgresql+psycopg2://reader:NWDMCE5xdipIjRrp@hh-pgsql-public.ebi.ac.uk:5432/pfmegrnargs
Packages¶
- class schema_automator.importers.JsonSchemaImportEngine(use_attributes: bool = False, is_openapi: bool = False)[source]¶
A ImportEngine that imports a JSON-Schema representation to a LinkML Schema
- class schema_automator.importers.OwlImportEngine(mappings: dict | None = None)[source]¶
An ImportEngine that takes schema-style OWL and converts it to a LinkML schema
- class schema_automator.importers.FrictionlessImportEngine[source]¶
An ImportEngine that imports Frictionless data packages with schema information
See:
- class schema_automator.importers.DOSDPImportEngine(mappings: dict | None = None)[source]¶
An ImportEngine that imports Ontology Design Patterns specified as DOSDP Yaml into a LinkML schema
See DOSDPs
Every template maps to a LinkML class, the default name for a template Foo as FooTemplate
- convert(files: str, range_as_enums=True, **kwargs) SchemaDefinition [source]¶
Converts one or more YAML files into a Schema
- Parameters:
files –
range_as_enums – if True, then class ranges are mapped to Enums
kwargs –
- Returns:
- create_class(pattern: Pattern, range_as_enums: bool = True, denormalize_labels: bool = True) ClassDefinition [source]¶
Create a LinkML class from a template/pattern
The class will have name FooTemplate, and will mixin TemplateClass, and will have one slot per var (slots will also be inherited from TemplateClass)
by default, the range of each var will be a class RangeClass, unless treated as enums
- Parameters:
pattern – DOSDP template
range_as_enums – if true, ranges will be enums
denoramlized – if true, create an optional label for each var
- Returns: