From 3a66099e9f782242cb0a74bca1a8a050f1d9677f Mon Sep 17 00:00:00 2001 From: Chris Mungall Date: Fri, 23 Aug 2024 19:01:02 -0700 Subject: [PATCH 1/3] Adding target_definition to model. This allows for convenient specification of linkml schema elements as part of transformation. --- src/linkml_map/datamodel/transformer_model.py | 108 +++++++++++---- .../datamodel/transformer_model.yaml | 113 ++++++++++++++- src/linkml_map/inference/schema_mapper.py | 14 ++ .../test_schema_mapper/test_schema_mapper.py | 129 +++++++++++++++++- 4 files changed, 329 insertions(+), 35 deletions(-) diff --git a/src/linkml_map/datamodel/transformer_model.py b/src/linkml_map/datamodel/transformer_model.py index 02ff601..6391fa9 100644 --- a/src/linkml_map/datamodel/transformer_model.py +++ b/src/linkml_map/datamodel/transformer_model.py @@ -63,11 +63,8 @@ def __getitem__(self, key:str): def __setitem__(self, key:str, value): self.root[key] = value - def __contains__(self, key:str) -> bool: - return key in self.root - -linkml_meta = LinkMLMeta({'default_prefix': 'linkmltr', +linkml_meta = LinkMLMeta({'default_prefix': 'https://w3id.org/linkml/transformer/', 'description': 'Datamodel for LinkML schema mappings and transformations.\n' '\n' 'A mapper generates instances of a *target* data model from\n' @@ -87,31 +84,7 @@ def __contains__(self, key:str) -> bool: '- translation into another specification language, such as ' 'R2RML', 'id': 'https://w3id.org/linkml/transformer', - 'imports': ['linkml:types'], - 'name': 'linkml-map', - 'prefixes': {'dcterms': {'prefix_prefix': 'dcterms', - 'prefix_reference': 'http://purl.org/dc/terms/'}, - 'linkml': {'prefix_prefix': 'linkml', - 'prefix_reference': 'https://w3id.org/linkml/'}, - 'linkmltr': {'prefix_prefix': 'linkmltr', - 'prefix_reference': 'https://w3id.org/linkml/transformer/'}, - 'rdfs': {'prefix_prefix': 'rdfs', - 'prefix_reference': 'http://www.w3.org/2000/01/rdf-schema#'}, - 'schema': {'prefix_prefix': 'schema', - 'prefix_reference': 'http://schema.org/'}, - 'sh': {'prefix_prefix': 'sh', - 'prefix_reference': 'http://www.w3.org/ns/shacl#'}}, - 'source_file': 'src/linkml_map/datamodel/transformer_model.yaml', - 'title': 'LinkML Map Data Model', - 'types': {'ClassReference': {'from_schema': 'https://w3id.org/linkml/transformer', - 'name': 'ClassReference', - 'typeof': 'string'}, - 'EnumReference': {'from_schema': 'https://w3id.org/linkml/transformer', - 'name': 'EnumReference', - 'typeof': 'string'}, - 'SlotReference': {'from_schema': 'https://w3id.org/linkml/transformer', - 'name': 'SlotReference', - 'typeof': 'string'}}} ) + 'name': 'linkml-map'} ) class CollectionType(str, Enum): SingleValued = "SingleValued" @@ -126,6 +99,33 @@ class SerializationSyntaxType(str, Enum): TURTLE = "TURTLE" +class AggregationType(str, Enum): + SUM = "SUM" + AVERAGE = "AVERAGE" + COUNT = "COUNT" + MIN = "MIN" + MAX = "MAX" + STD_DEV = "STD_DEV" + VARIANCE = "VARIANCE" + MEDIAN = "MEDIAN" + MODE = "MODE" + CUSTOM = "CUSTOM" + SET = "SET" + LIST = "LIST" + ARRAY = "ARRAY" + + +class InvalidValueHandlingStrategy(str, Enum): + IGNORE = "IGNORE" + TREAT_AS_ZERO = "TREAT_AS_ZERO" + ERROR_OUT = "ERROR_OUT" + + +class PivotDirectionType(str, Enum): + MELT = "MELT" + UNMELT = "UNMELT" + + class SpecificationComponent(ConfiguredBaseModel): linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({'abstract': True, 'from_schema': 'https://w3id.org/linkml/transformer'}) @@ -221,6 +221,9 @@ class ClassDerivation(ElementDerivation): 'domain_of': ['ClassDerivation']} }) slot_derivations: Optional[Dict[str, SlotDerivation]] = Field(default_factory=dict, json_schema_extra = { "linkml_meta": {'alias': 'slot_derivations', 'domain_of': ['TransformationSpecification', 'ClassDerivation']} }) + target_definition: Optional[Any] = Field(None, description="""LinkML class definition object for this slot.""", json_schema_extra = { "linkml_meta": {'alias': 'target_definition', + 'comments': ['currently defined as Any to avoid coupling with metamodel'], + 'domain_of': ['ClassDerivation', 'SlotDerivation']} }) name: str = Field(..., description="""Name of the element in the target schema""", json_schema_extra = { "linkml_meta": {'alias': 'name', 'domain_of': ['ElementDerivation', 'SlotDerivation', @@ -290,9 +293,13 @@ class SlotDerivation(ElementDerivation): 'EnumDerivation', 'PermissibleValueDerivation']} }) type_designator: Optional[bool] = Field(None, json_schema_extra = { "linkml_meta": {'alias': 'type_designator', 'domain_of': ['SlotDerivation']} }) + target_definition: Optional[Any] = Field(None, description="""LinkML definition object for this slot.""", json_schema_extra = { "linkml_meta": {'alias': 'target_definition', + 'comments': ['currently defined as Any to avoid coupling with metamodel'], + 'domain_of': ['ClassDerivation', 'SlotDerivation']} }) cast_collection_as: Optional[CollectionType] = Field(None, json_schema_extra = { "linkml_meta": {'alias': 'cast_collection_as', 'domain_of': ['SlotDerivation']} }) dictionary_key: Optional[str] = Field(None, json_schema_extra = { "linkml_meta": {'alias': 'dictionary_key', 'domain_of': ['SlotDerivation']} }) stringification: Optional[StringificationConfiguration] = Field(None, json_schema_extra = { "linkml_meta": {'alias': 'stringification', 'domain_of': ['SlotDerivation']} }) + aggregation_operation: Optional[AggregationOperation] = Field(None, json_schema_extra = { "linkml_meta": {'alias': 'aggregation_operation', 'domain_of': ['SlotDerivation']} }) copy_directives: Optional[Dict[str, CopyDirective]] = Field(default_factory=dict, json_schema_extra = { "linkml_meta": {'alias': 'copy_directives', 'domain_of': ['ElementDerivation']} }) overrides: Optional[Any] = Field(None, description="""overrides source schema slots""", json_schema_extra = { "linkml_meta": {'alias': 'overrides', 'domain_of': ['ElementDerivation']} }) is_a: Optional[str] = Field(None, json_schema_extra = { "linkml_meta": {'alias': 'is_a', 'domain_of': ['ElementDerivation'], 'slot_uri': 'linkml:is_a'} }) @@ -483,6 +490,45 @@ class Inverse(ConfiguredBaseModel): class_name: Optional[str] = Field(None, json_schema_extra = { "linkml_meta": {'alias': 'class_name', 'domain_of': ['Inverse']} }) +class TransformationOperation(ConfiguredBaseModel): + linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({'abstract': True, 'from_schema': 'https://w3id.org/linkml/transformer'}) + + pass + + +class AggregationOperation(TransformationOperation): + linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({'from_schema': 'https://w3id.org/linkml/transformer'}) + + operator: AggregationType = Field(..., json_schema_extra = { "linkml_meta": {'alias': 'operator', 'domain_of': ['AggregationOperation']} }) + null_handling: Optional[InvalidValueHandlingStrategy] = Field(None, json_schema_extra = { "linkml_meta": {'alias': 'null_handling', + 'domain_of': ['AggregationOperation', 'GroupingOperation']} }) + invalid_value_handling: Optional[InvalidValueHandlingStrategy] = Field(None, json_schema_extra = { "linkml_meta": {'alias': 'invalid_value_handling', 'domain_of': ['AggregationOperation']} }) + + +class GroupingOperation(TransformationOperation): + linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({'from_schema': 'https://w3id.org/linkml/transformer'}) + + null_handling: Optional[InvalidValueHandlingStrategy] = Field(None, json_schema_extra = { "linkml_meta": {'alias': 'null_handling', + 'domain_of': ['AggregationOperation', 'GroupingOperation']} }) + + +class PivotOperation(TransformationOperation): + linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({'aliases': ['melt/unmelt', 'reification/dereification'], + 'from_schema': 'https://w3id.org/linkml/transformer'}) + + direction: PivotDirectionType = Field(..., json_schema_extra = { "linkml_meta": {'alias': 'direction', 'domain_of': ['PivotOperation']} }) + variable_slot: Optional[str] = Field("variable", description="""Slot to use for the variable column in the melted/long representation. In EAV this is the name of the 'A' variable""", json_schema_extra = { "linkml_meta": {'alias': 'variable_slot', + 'aliases': ['var_name'], + 'domain_of': ['PivotOperation'], + 'ifabsent': 'string(variable)'} }) + value_slot: Optional[str] = Field("value", description="""Slot to use for the value column in the melted/long representation. In EAV this is the name of the 'V' variable""", json_schema_extra = { "linkml_meta": {'alias': 'value_slot', + 'aliases': ['value_name'], + 'domain_of': ['PivotOperation'], + 'ifabsent': 'string(value)'} }) + unmelt_to_class: Optional[str] = Field(None, description="""In an unmelt operation, attributes (which are values in the long/melted/EAV representation) must conform to valid attributes in this class""", json_schema_extra = { "linkml_meta": {'alias': 'unmelt_to_class', 'domain_of': ['PivotOperation']} }) + unmelt_to_slots: Optional[List[str]] = Field(default_factory=list, json_schema_extra = { "linkml_meta": {'alias': 'unmelt_to_slots', 'domain_of': ['PivotOperation']} }) + + class KeyVal(ConfiguredBaseModel): linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({'from_schema': 'https://w3id.org/linkml/transformer'}) @@ -524,6 +570,10 @@ class CopyDirective(ConfiguredBaseModel): UnitConversionConfiguration.model_rebuild() StringificationConfiguration.model_rebuild() Inverse.model_rebuild() +TransformationOperation.model_rebuild() +AggregationOperation.model_rebuild() +GroupingOperation.model_rebuild() +PivotOperation.model_rebuild() KeyVal.model_rebuild() CopyDirective.model_rebuild() diff --git a/src/linkml_map/datamodel/transformer_model.yaml b/src/linkml_map/datamodel/transformer_model.yaml index badc38e..d573cb6 100644 --- a/src/linkml_map/datamodel/transformer_model.yaml +++ b/src/linkml_map/datamodel/transformer_model.yaml @@ -17,12 +17,13 @@ description: |- - translation into another specification language, such as R2RML prefixes: linkml: https://w3id.org/linkml/ - linkmltr: https://w3id.org/linkml/transformer/ + linkmlmap: https://w3id.org/linkml/transformer/ dcterms: http://purl.org/dc/terms/ schema: http://schema.org/ rdfs: http://www.w3.org/2000/01/rdf-schema# sh: http://www.w3.org/ns/shacl# -default_prefix: linkmltr + STATO: http://purl.obolibrary.org/obo/STATO_ +default_prefix: linkmlmap imports: - linkml:types @@ -178,6 +179,12 @@ classes: range: SlotDerivation multivalued: true inlined: true + target_definition: + range: Any + description: >- + LinkML class definition object for this slot. + comments: + - currently defined as Any to avoid coupling with metamodel AliasedClass: description: alias-class key value pairs for classes @@ -228,12 +235,20 @@ classes: description: True if this is suppressed type_designator: range: boolean + target_definition: + range: Any + description: >- + LinkML definition object for this slot. + comments: + - currently defined as Any to avoid coupling with metamodel cast_collection_as: range: CollectionType dictionary_key: range: string stringification: range: StringificationConfiguration + aggregation_operation: + range: AggregationOperation EnumDerivation: is_a: ElementDerivation @@ -330,6 +345,57 @@ classes: slot_name: class_name: + TransformationOperation: + abstract: true + + AggregationOperation: + is_a: TransformationOperation + attributes: + operator: + range: AggregationType + required: true + null_handling: + range: InvalidValueHandlingStrategy + invalid_value_handling: + range: InvalidValueHandlingStrategy + + GroupingOperation: + is_a: TransformationOperation + attributes: + null_handling: + range: InvalidValueHandlingStrategy + + PivotOperation: + aliases: + - melt/unmelt + - reification/dereification + is_a: TransformationOperation + attributes: + direction: + range: PivotDirectionType + required: true + variable_slot: + aliases: + - var_name + range: SlotReference + ifabsent: string(variable) + description: Slot to use for the variable column in the melted/long representation. + In EAV this is the name of the 'A' variable + value_slot: + aliases: + - value_name + range: SlotReference + ifabsent: string(value) + description: Slot to use for the value column in the melted/long representation. + In EAV this is the name of the 'V' variable + unmelt_to_class: + description: In an unmelt operation, attributes (which are values in the long/melted/EAV + representation) must conform to valid attributes in this class + range: ClassReference + unmelt_to_slots: + range: SlotReference + multivalued: true + KeyVal: attributes: key: @@ -394,3 +460,46 @@ enums: JSON: YAML: TURTLE: + AggregationType: + permissible_values: + SUM: + AVERAGE: + aliases: + - mean + - avg + exact_mappings: + - STATO:0000230 + COUNT: + exact_mappings: + - STATO:0000047 + MIN: + MAX: + STD_DEV: + exact_mappings: + - STATO:0000237 + VARIANCE: + MEDIAN: + exact_mappings: + - STATO:0000674 + MODE: + exact_mappings: + - STATO:0000033 + CUSTOM: + SET: + LIST: + ARRAY: + InvalidValueHandlingStrategy: + permissible_values: + IGNORE: + TREAT_AS_ZERO: + ERROR_OUT: + PivotDirectionType: + permissible_values: + MELT: + aliases: + - unpivot + - wide to long + UNMELT: + aliases: + - pivot + - long to wide diff --git a/src/linkml_map/inference/schema_mapper.py b/src/linkml_map/inference/schema_mapper.py index e554d97..a6fc56e 100644 --- a/src/linkml_map/inference/schema_mapper.py +++ b/src/linkml_map/inference/schema_mapper.py @@ -115,6 +115,16 @@ def _derive_class(self, class_derivation: ClassDerivation) -> ClassDefinition: for slot_derivation in class_derivation.slot_derivations.values(): slot_definition = self._derive_slot(slot_derivation) target_class.attributes[slot_definition.name] = slot_definition + if class_derivation.is_a: + target_class.is_a = class_derivation.is_a + if class_derivation.mixins: + target_class.mixins = class_derivation.mixins + if class_derivation.target_definition: + spec_defn = ClassDefinition(**{"name": target_class.name}, **class_derivation.target_definition) + for k, v in vars(spec_defn).items(): + curr_v = getattr(target_class, k, None) + if curr_v is None or curr_v == [] or curr_v == {}: + setattr(target_class, k, v) self.source_to_target_class_mappings[populated_from].append(target_class.name) if class_derivation.overrides: curr = json_dumper.to_dict(target_class) @@ -178,6 +188,10 @@ def _derive_slot(self, slot_derivation) -> SlotDefinition: target_slot.name = slot_derivation.name if slot_derivation.range: target_slot.range = slot_derivation.range + if slot_derivation.target_definition: + spec_defn = SlotDefinition(**{"name": target_slot.name}, **slot_derivation.target_definition) + for k, v in vars(spec_defn).items(): + setattr(target_slot, k, v) if slot_derivation.unit_conversion: target_slot.unit = UnitOfMeasure(ucum_code=slot_derivation.unit_conversion.target_unit) if slot_derivation.stringification: diff --git a/tests/test_schema_mapper/test_schema_mapper.py b/tests/test_schema_mapper/test_schema_mapper.py index adc8beb..984c470 100644 --- a/tests/test_schema_mapper/test_schema_mapper.py +++ b/tests/test_schema_mapper/test_schema_mapper.py @@ -2,14 +2,16 @@ from linkml_runtime import SchemaView from linkml_runtime.dumpers import yaml_dumper +from linkml_runtime.utils.schema_builder import SchemaBuilder from linkml_map.datamodel.transformer_model import ( ClassDerivation, - TransformationSpecification, + TransformationSpecification, SlotDerivation, ) from linkml_map.inference.schema_mapper import SchemaMapper from linkml_map.transformer.object_transformer import ObjectTransformer from tests import SCHEMA1, SPECIFICATION +from tests.input.examples.personinfo_basic.model.personinfo_model import slots class SchemaMapperTestCase(unittest.TestCase): @@ -54,16 +56,85 @@ def test_derive_schema(self): for s in slots: self.assertIn(s, atts) # self.assertCountEqual(slots, list(atts)) + agent = target_schema.classes["Agent"] + self.assertEqual(agent.is_a, "Entity") - def test_derive_null(self): - """tests empty spec limit case""" + def test_null_specification(self): + """ + tests empty spec limit case. + + An empty spec should return an empty schema. + """ tr = self.mapper specification = TransformationSpecification(id="test") target_schema = tr.derive_schema(specification) self.assertEqual([], list(target_schema.classes.values())) + def test_null_specification_and_source(self): + """ + tests empty spec and source schema limit case. + + An empty spec and source schema should return an empty schema. + """ + tr = SchemaMapper() + tr.source_schemaview = SchemaView(SCHEMA1) + specification = TransformationSpecification(id="test") + target_schema = tr.derive_schema(specification) + self.assertEqual([], list(target_schema.classes.values())) + + def test_definition_in_derivation(self): + """ + test where the derived schema is entirely specified by the spec. + """ + tr = SchemaMapper() + tr.source_schemaview = SchemaView(SCHEMA1) + specification = TransformationSpecification( + id="test", + class_derivations={ + "Thing": ClassDerivation( + name="Thing", + slot_derivations={ + "id": SlotDerivation(name="id", + target_definition={ + "identifier": "true", + "range": "uriorcurie" + }, + ), + }, + ), + "Agent": ClassDerivation( + name="Agent", + slot_derivations={ + "age": SlotDerivation(name="role", + target_definition={ + "range": "integer" + } + ), + }, + target_definition={ + "description": "A person or organization.", + "is_a": "Thing", + } + ) + + }, + ) + target_schema = tr.derive_schema(specification) + self.assertEqual({"Agent", "Thing"}, set(target_schema.classes.keys())) + + thing = target_schema.classes["Thing"] + atts = thing.attributes + self.assertEqual(["id"], list(atts.keys())) + id_att = atts["id"] + self.assertEqual("uriorcurie", id_att.range) + self.assertEqual(True, id_att.identifier) + agent = target_schema.classes["Agent"] + assert agent.is_a == "Thing" + def test_derive_partial(self): - """tests empty spec limit case""" + """ + tests partial spec limit case. + """ tr = self.mapper specification = TransformationSpecification(id="test") derivations = [ @@ -73,6 +144,56 @@ def test_derive_partial(self): specification.class_derivations[derivation.name] = derivation target_schema = tr.derive_schema(specification) print(yaml_dumper.dumps(target_schema)) + self.assertEqual(["Agent"], list(target_schema.classes.keys())) + + def test_rewire(self): + """ + tests rewire + + An empty spec and source schema should return an empty schema. + """ + tr = SchemaMapper() + sb = SchemaBuilder() + sb.add_slot("id", range="string", identifier=True) + sb.add_slot("name", range="string") + sb.add_slot("pets", range="Pet", multivalued=True) + sb.add_slot("salary", range="integer") + sb.add_class("Thing", slots=["id", "name"]) + sb.add_class("Person", is_a="Thing", slots=["pets"]) + sb.add_class("Employee", is_a="Person", slots=["salary"]) + sb.add_class("Pet", is_a="Thing", slots=["pets"]) + tr.source_schemaview = SchemaView(sb.schema) + specification = TransformationSpecification( + id="test", + ) + target_schema = tr.derive_schema(specification) + self.assertEqual([], list(target_schema.classes.values())) + specification = TransformationSpecification( + id="test", + class_derivations={ + "TrEmployee": ClassDerivation( + name="TrEmployee", + slot_derivations={ + "tr_salary": SlotDerivation( + name="tr_salary", + range="decimal", + ) + }, + ) + }, + ) + target_schema = tr.derive_schema(specification) + self.assertEqual(["TrEmployee"], list(target_schema.classes.keys())) + emp = target_schema.classes["TrEmployee"] + self.assertEqual(["tr_salary"], list(emp.attributes.keys())) + specification.class_derivations["TrEmployee"].is_a = "Person" + target_schema = tr.derive_schema(specification) + self.assertEqual(["TrEmployee"], list(target_schema.classes.keys())) + emp = target_schema.classes["TrEmployee"] + self.assertEqual(["tr_salary"], list(emp.attributes.keys())) + # self.assertEqual("Person", emp.is_a) + + if __name__ == "__main__": From f168673e65712be8593a59f15effc60c6fec7959 Mon Sep 17 00:00:00 2001 From: Chris Mungall Date: Fri, 23 Aug 2024 19:08:41 -0700 Subject: [PATCH 2/3] format --- src/linkml_map/datamodel/transformer_model.py | 1837 +++++++++++++---- src/linkml_map/inference/schema_mapper.py | 8 +- .../flattening/model/denormalized_model.py | 4 +- .../flattening/model/normalized_model.py | 5 +- .../personinfo_basic/model/agent_model.py | 17 +- .../model/personinfo_model.py | 17 +- .../test_schema_mapper/test_schema_mapper.py | 26 +- 7 files changed, 1461 insertions(+), 453 deletions(-) diff --git a/src/linkml_map/datamodel/transformer_model.py b/src/linkml_map/datamodel/transformer_model.py index 6391fa9..159a391 100644 --- a/src/linkml_map/datamodel/transformer_model.py +++ b/src/linkml_map/datamodel/transformer_model.py @@ -1,36 +1,18 @@ -from __future__ import annotations -from datetime import ( - datetime, - date -) -from decimal import Decimal -from enum import Enum +from __future__ import annotations + import re import sys -from typing import ( - Any, - ClassVar, - List, - Literal, - Dict, - Optional, - Union -) -from pydantic.version import VERSION as PYDANTIC_VERSION -if int(PYDANTIC_VERSION[0])>=2: - from pydantic import ( - BaseModel, - ConfigDict, - Field, - RootModel, - field_validator - ) +from datetime import date, datetime +from decimal import Decimal +from enum import Enum +from typing import Any, ClassVar, Dict, List, Literal, Optional, Union + +from pydantic.version import VERSION as PYDANTIC_VERSION + +if int(PYDANTIC_VERSION[0]) >= 2: + from pydantic import BaseModel, ConfigDict, Field, RootModel, field_validator else: - from pydantic import ( - BaseModel, - Field, - validator - ) + from pydantic import BaseModel, Field, validator metamodel_version = "None" version = "None" @@ -38,53 +20,56 @@ class ConfiguredBaseModel(BaseModel): model_config = ConfigDict( - validate_assignment = True, - validate_default = True, - extra = "forbid", - arbitrary_types_allowed = True, - use_enum_values = True, - strict = False, + validate_assignment=True, + validate_default=True, + extra="forbid", + arbitrary_types_allowed=True, + use_enum_values=True, + strict=False, ) pass - - class LinkMLMeta(RootModel): root: Dict[str, Any] = {} model_config = ConfigDict(frozen=True) - def __getattr__(self, key:str): + def __getattr__(self, key: str): return getattr(self.root, key) - def __getitem__(self, key:str): + def __getitem__(self, key: str): return self.root[key] - def __setitem__(self, key:str, value): + def __setitem__(self, key: str, value): self.root[key] = value -linkml_meta = LinkMLMeta({'default_prefix': 'https://w3id.org/linkml/transformer/', - 'description': 'Datamodel for LinkML schema mappings and transformations.\n' - '\n' - 'A mapper generates instances of a *target* data model from\n' - 'instances of a *source* data model. This transformation ' - 'process\n' - 'is guided by a *TransformationSpecification*.\n' - '\n' - 'The specification is independent of any one method for ' - 'transforming\n' - 'data. It allows different approaches, including:\n' - '\n' - '- direct implementation, transforming python or json objects\n' - '- translation of the specification into SQL commands, to ' - 'operate on relations\n' - '- translation of the specification into SPARQL CONSTRUCTs, to ' - 'operate on triples\n' - '- translation into another specification language, such as ' - 'R2RML', - 'id': 'https://w3id.org/linkml/transformer', - 'name': 'linkml-map'} ) +linkml_meta = LinkMLMeta( + { + "default_prefix": "https://w3id.org/linkml/transformer/", + "description": "Datamodel for LinkML schema mappings and transformations.\n" + "\n" + "A mapper generates instances of a *target* data model from\n" + "instances of a *source* data model. This transformation " + "process\n" + "is guided by a *TransformationSpecification*.\n" + "\n" + "The specification is independent of any one method for " + "transforming\n" + "data. It allows different approaches, including:\n" + "\n" + "- direct implementation, transforming python or json objects\n" + "- translation of the specification into SQL commands, to " + "operate on relations\n" + "- translation of the specification into SPARQL CONSTRUCTs, to " + "operate on triples\n" + "- translation into another specification language, such as " + "R2RML", + "id": "https://w3id.org/linkml/transformer", + "name": "linkml-map", + } +) + class CollectionType(str, Enum): SingleValued = "SingleValued" @@ -126,434 +111,1489 @@ class PivotDirectionType(str, Enum): UNMELT = "UNMELT" - class SpecificationComponent(ConfiguredBaseModel): - linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({'abstract': True, 'from_schema': 'https://w3id.org/linkml/transformer'}) + linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta( + {"abstract": True, "from_schema": "https://w3id.org/linkml/transformer"} + ) - description: Optional[str] = Field(None, description="""description of the specification component""", json_schema_extra = { "linkml_meta": {'alias': 'description', - 'domain_of': ['SpecificationComponent'], - 'slot_uri': 'dcterms:description'} }) - implements: Optional[List[str]] = Field(default_factory=list, description="""A reference to a specification that this component implements.""", json_schema_extra = { "linkml_meta": {'alias': 'implements', 'domain_of': ['SpecificationComponent']} }) - comments: Optional[List[str]] = Field(default_factory=list, description="""A list of comments about this component. Comments are free text, and may be used to provide additional information about the component, including instructions for its use.""", json_schema_extra = { "linkml_meta": {'alias': 'comments', - 'domain_of': ['SpecificationComponent'], - 'slot_uri': 'rdfs:comment'} }) + description: Optional[str] = Field( + None, + description="""description of the specification component""", + json_schema_extra={ + "linkml_meta": { + "alias": "description", + "domain_of": ["SpecificationComponent"], + "slot_uri": "dcterms:description", + } + }, + ) + implements: Optional[List[str]] = Field( + default_factory=list, + description="""A reference to a specification that this component implements.""", + json_schema_extra={ + "linkml_meta": {"alias": "implements", "domain_of": ["SpecificationComponent"]} + }, + ) + comments: Optional[List[str]] = Field( + default_factory=list, + description="""A list of comments about this component. Comments are free text, and may be used to provide additional information about the component, including instructions for its use.""", + json_schema_extra={ + "linkml_meta": { + "alias": "comments", + "domain_of": ["SpecificationComponent"], + "slot_uri": "rdfs:comment", + } + }, + ) class TransformationSpecification(SpecificationComponent): """ A collection of mappings between source and target classes """ - linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({'from_schema': 'https://w3id.org/linkml/transformer', 'tree_root': True}) - - id: Optional[str] = Field(None, description="""Unique identifier for this transformation specification""", json_schema_extra = { "linkml_meta": {'alias': 'id', - 'domain_of': ['TransformationSpecification'], - 'slot_uri': 'schema:identifier'} }) - title: Optional[str] = Field(None, description="""human readable title for this transformation specification""", json_schema_extra = { "linkml_meta": {'alias': 'title', - 'domain_of': ['TransformationSpecification'], - 'slot_uri': 'dcterms:title'} }) - prefixes: Optional[Dict[str, KeyVal]] = Field(default_factory=dict, description="""maps prefixes to URL expansions""", json_schema_extra = { "linkml_meta": {'alias': 'prefixes', - 'domain_of': ['TransformationSpecification'], - 'slot_uri': 'sh:declare'} }) - source_schema: Optional[str] = Field(None, description="""name of the schema that describes the source (input) objects""", json_schema_extra = { "linkml_meta": {'alias': 'source_schema', 'domain_of': ['TransformationSpecification']} }) - target_schema: Optional[str] = Field(None, description="""name of the schema that describes the target (output) objects""", json_schema_extra = { "linkml_meta": {'alias': 'target_schema', 'domain_of': ['TransformationSpecification']} }) - class_derivations: Optional[Dict[str, ClassDerivation]] = Field(default_factory=dict, description="""Instructions on how to derive a set of classes in the target schema from classes in the source schema.""", json_schema_extra = { "linkml_meta": {'alias': 'class_derivations', 'domain_of': ['TransformationSpecification']} }) - enum_derivations: Optional[Dict[str, EnumDerivation]] = Field(default_factory=dict, description="""Instructions on how to derive a set of enums in the target schema""", json_schema_extra = { "linkml_meta": {'alias': 'enum_derivations', 'domain_of': ['TransformationSpecification']} }) - slot_derivations: Optional[Dict[str, SlotDerivation]] = Field(default_factory=dict, description="""Instructions on how to derive a set of top level slots in the target schema""", json_schema_extra = { "linkml_meta": {'alias': 'slot_derivations', - 'domain_of': ['TransformationSpecification', 'ClassDerivation']} }) - description: Optional[str] = Field(None, description="""description of the specification component""", json_schema_extra = { "linkml_meta": {'alias': 'description', - 'domain_of': ['SpecificationComponent'], - 'slot_uri': 'dcterms:description'} }) - implements: Optional[List[str]] = Field(default_factory=list, description="""A reference to a specification that this component implements.""", json_schema_extra = { "linkml_meta": {'alias': 'implements', 'domain_of': ['SpecificationComponent']} }) - comments: Optional[List[str]] = Field(default_factory=list, description="""A list of comments about this component. Comments are free text, and may be used to provide additional information about the component, including instructions for its use.""", json_schema_extra = { "linkml_meta": {'alias': 'comments', - 'domain_of': ['SpecificationComponent'], - 'slot_uri': 'rdfs:comment'} }) + + linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta( + {"from_schema": "https://w3id.org/linkml/transformer", "tree_root": True} + ) + + id: Optional[str] = Field( + None, + description="""Unique identifier for this transformation specification""", + json_schema_extra={ + "linkml_meta": { + "alias": "id", + "domain_of": ["TransformationSpecification"], + "slot_uri": "schema:identifier", + } + }, + ) + title: Optional[str] = Field( + None, + description="""human readable title for this transformation specification""", + json_schema_extra={ + "linkml_meta": { + "alias": "title", + "domain_of": ["TransformationSpecification"], + "slot_uri": "dcterms:title", + } + }, + ) + prefixes: Optional[Dict[str, KeyVal]] = Field( + default_factory=dict, + description="""maps prefixes to URL expansions""", + json_schema_extra={ + "linkml_meta": { + "alias": "prefixes", + "domain_of": ["TransformationSpecification"], + "slot_uri": "sh:declare", + } + }, + ) + source_schema: Optional[str] = Field( + None, + description="""name of the schema that describes the source (input) objects""", + json_schema_extra={ + "linkml_meta": {"alias": "source_schema", "domain_of": ["TransformationSpecification"]} + }, + ) + target_schema: Optional[str] = Field( + None, + description="""name of the schema that describes the target (output) objects""", + json_schema_extra={ + "linkml_meta": {"alias": "target_schema", "domain_of": ["TransformationSpecification"]} + }, + ) + class_derivations: Optional[Dict[str, ClassDerivation]] = Field( + default_factory=dict, + description="""Instructions on how to derive a set of classes in the target schema from classes in the source schema.""", + json_schema_extra={ + "linkml_meta": { + "alias": "class_derivations", + "domain_of": ["TransformationSpecification"], + } + }, + ) + enum_derivations: Optional[Dict[str, EnumDerivation]] = Field( + default_factory=dict, + description="""Instructions on how to derive a set of enums in the target schema""", + json_schema_extra={ + "linkml_meta": { + "alias": "enum_derivations", + "domain_of": ["TransformationSpecification"], + } + }, + ) + slot_derivations: Optional[Dict[str, SlotDerivation]] = Field( + default_factory=dict, + description="""Instructions on how to derive a set of top level slots in the target schema""", + json_schema_extra={ + "linkml_meta": { + "alias": "slot_derivations", + "domain_of": ["TransformationSpecification", "ClassDerivation"], + } + }, + ) + description: Optional[str] = Field( + None, + description="""description of the specification component""", + json_schema_extra={ + "linkml_meta": { + "alias": "description", + "domain_of": ["SpecificationComponent"], + "slot_uri": "dcterms:description", + } + }, + ) + implements: Optional[List[str]] = Field( + default_factory=list, + description="""A reference to a specification that this component implements.""", + json_schema_extra={ + "linkml_meta": {"alias": "implements", "domain_of": ["SpecificationComponent"]} + }, + ) + comments: Optional[List[str]] = Field( + default_factory=list, + description="""A list of comments about this component. Comments are free text, and may be used to provide additional information about the component, including instructions for its use.""", + json_schema_extra={ + "linkml_meta": { + "alias": "comments", + "domain_of": ["SpecificationComponent"], + "slot_uri": "rdfs:comment", + } + }, + ) class ElementDerivation(SpecificationComponent): """ An abstract grouping for classes that provide a specification of how to derive a target element from a source element. """ - linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({'abstract': True, 'from_schema': 'https://w3id.org/linkml/transformer'}) - - name: str = Field(..., description="""Name of the element in the target schema""", json_schema_extra = { "linkml_meta": {'alias': 'name', - 'domain_of': ['ElementDerivation', - 'SlotDerivation', - 'EnumDerivation', - 'PermissibleValueDerivation']} }) - copy_directives: Optional[Dict[str, CopyDirective]] = Field(default_factory=dict, json_schema_extra = { "linkml_meta": {'alias': 'copy_directives', 'domain_of': ['ElementDerivation']} }) - overrides: Optional[Any] = Field(None, description="""overrides source schema slots""", json_schema_extra = { "linkml_meta": {'alias': 'overrides', 'domain_of': ['ElementDerivation']} }) - is_a: Optional[str] = Field(None, json_schema_extra = { "linkml_meta": {'alias': 'is_a', 'domain_of': ['ElementDerivation'], 'slot_uri': 'linkml:is_a'} }) - mixins: Optional[List[str]] = Field(default_factory=list, json_schema_extra = { "linkml_meta": {'alias': 'mixins', - 'domain_of': ['ElementDerivation'], - 'slot_uri': 'linkml:mixins'} }) - value_mappings: Optional[Dict[str, KeyVal]] = Field(default_factory=dict, description="""A mapping table that is applied directly to mappings, in order of precedence""", json_schema_extra = { "linkml_meta": {'alias': 'value_mappings', 'domain_of': ['ElementDerivation']} }) - expression_to_value_mappings: Optional[Dict[str, KeyVal]] = Field(default_factory=dict, description="""A mapping table in which the keys are expressions""", json_schema_extra = { "linkml_meta": {'alias': 'expression_to_value_mappings', 'domain_of': ['ElementDerivation']} }) - expression_to_expression_mappings: Optional[Dict[str, KeyVal]] = Field(default_factory=dict, description="""A mapping table in which the keys and values are expressions""", json_schema_extra = { "linkml_meta": {'alias': 'expression_to_expression_mappings', - 'domain_of': ['ElementDerivation']} }) - mirror_source: Optional[bool] = Field(None, json_schema_extra = { "linkml_meta": {'alias': 'mirror_source', 'domain_of': ['ElementDerivation']} }) - description: Optional[str] = Field(None, description="""description of the specification component""", json_schema_extra = { "linkml_meta": {'alias': 'description', - 'domain_of': ['SpecificationComponent'], - 'slot_uri': 'dcterms:description'} }) - implements: Optional[List[str]] = Field(default_factory=list, description="""A reference to a specification that this component implements.""", json_schema_extra = { "linkml_meta": {'alias': 'implements', 'domain_of': ['SpecificationComponent']} }) - comments: Optional[List[str]] = Field(default_factory=list, description="""A list of comments about this component. Comments are free text, and may be used to provide additional information about the component, including instructions for its use.""", json_schema_extra = { "linkml_meta": {'alias': 'comments', - 'domain_of': ['SpecificationComponent'], - 'slot_uri': 'rdfs:comment'} }) + + linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta( + {"abstract": True, "from_schema": "https://w3id.org/linkml/transformer"} + ) + + name: str = Field( + ..., + description="""Name of the element in the target schema""", + json_schema_extra={ + "linkml_meta": { + "alias": "name", + "domain_of": [ + "ElementDerivation", + "SlotDerivation", + "EnumDerivation", + "PermissibleValueDerivation", + ], + } + }, + ) + copy_directives: Optional[Dict[str, CopyDirective]] = Field( + default_factory=dict, + json_schema_extra={ + "linkml_meta": {"alias": "copy_directives", "domain_of": ["ElementDerivation"]} + }, + ) + overrides: Optional[Any] = Field( + None, + description="""overrides source schema slots""", + json_schema_extra={ + "linkml_meta": {"alias": "overrides", "domain_of": ["ElementDerivation"]} + }, + ) + is_a: Optional[str] = Field( + None, + json_schema_extra={ + "linkml_meta": { + "alias": "is_a", + "domain_of": ["ElementDerivation"], + "slot_uri": "linkml:is_a", + } + }, + ) + mixins: Optional[List[str]] = Field( + default_factory=list, + json_schema_extra={ + "linkml_meta": { + "alias": "mixins", + "domain_of": ["ElementDerivation"], + "slot_uri": "linkml:mixins", + } + }, + ) + value_mappings: Optional[Dict[str, KeyVal]] = Field( + default_factory=dict, + description="""A mapping table that is applied directly to mappings, in order of precedence""", + json_schema_extra={ + "linkml_meta": {"alias": "value_mappings", "domain_of": ["ElementDerivation"]} + }, + ) + expression_to_value_mappings: Optional[Dict[str, KeyVal]] = Field( + default_factory=dict, + description="""A mapping table in which the keys are expressions""", + json_schema_extra={ + "linkml_meta": { + "alias": "expression_to_value_mappings", + "domain_of": ["ElementDerivation"], + } + }, + ) + expression_to_expression_mappings: Optional[Dict[str, KeyVal]] = Field( + default_factory=dict, + description="""A mapping table in which the keys and values are expressions""", + json_schema_extra={ + "linkml_meta": { + "alias": "expression_to_expression_mappings", + "domain_of": ["ElementDerivation"], + } + }, + ) + mirror_source: Optional[bool] = Field( + None, + json_schema_extra={ + "linkml_meta": {"alias": "mirror_source", "domain_of": ["ElementDerivation"]} + }, + ) + description: Optional[str] = Field( + None, + description="""description of the specification component""", + json_schema_extra={ + "linkml_meta": { + "alias": "description", + "domain_of": ["SpecificationComponent"], + "slot_uri": "dcterms:description", + } + }, + ) + implements: Optional[List[str]] = Field( + default_factory=list, + description="""A reference to a specification that this component implements.""", + json_schema_extra={ + "linkml_meta": {"alias": "implements", "domain_of": ["SpecificationComponent"]} + }, + ) + comments: Optional[List[str]] = Field( + default_factory=list, + description="""A list of comments about this component. Comments are free text, and may be used to provide additional information about the component, including instructions for its use.""", + json_schema_extra={ + "linkml_meta": { + "alias": "comments", + "domain_of": ["SpecificationComponent"], + "slot_uri": "rdfs:comment", + } + }, + ) class ClassDerivation(ElementDerivation): """ A specification of how to derive a target class from a source class. """ - linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({'from_schema': 'https://w3id.org/linkml/transformer'}) - - populated_from: Optional[str] = Field(None, description="""Name of the class in the source schema""", json_schema_extra = { "linkml_meta": {'alias': 'populated_from', - 'domain_of': ['ClassDerivation', - 'SlotDerivation', - 'EnumDerivation', - 'PermissibleValueDerivation']} }) - sources: Optional[List[str]] = Field(default_factory=list, json_schema_extra = { "linkml_meta": {'alias': 'sources', - 'domain_of': ['ClassDerivation', - 'SlotDerivation', - 'EnumDerivation', - 'PermissibleValueDerivation']} }) - joins: Optional[Dict[str, AliasedClass]] = Field(default_factory=dict, description="""Additional classes to be joined to derive instances of the target class""", json_schema_extra = { "linkml_meta": {'alias': 'joins', - 'comments': ['not yet implemented'], - 'domain_of': ['ClassDerivation']} }) - slot_derivations: Optional[Dict[str, SlotDerivation]] = Field(default_factory=dict, json_schema_extra = { "linkml_meta": {'alias': 'slot_derivations', - 'domain_of': ['TransformationSpecification', 'ClassDerivation']} }) - target_definition: Optional[Any] = Field(None, description="""LinkML class definition object for this slot.""", json_schema_extra = { "linkml_meta": {'alias': 'target_definition', - 'comments': ['currently defined as Any to avoid coupling with metamodel'], - 'domain_of': ['ClassDerivation', 'SlotDerivation']} }) - name: str = Field(..., description="""Name of the element in the target schema""", json_schema_extra = { "linkml_meta": {'alias': 'name', - 'domain_of': ['ElementDerivation', - 'SlotDerivation', - 'EnumDerivation', - 'PermissibleValueDerivation']} }) - copy_directives: Optional[Dict[str, CopyDirective]] = Field(default_factory=dict, json_schema_extra = { "linkml_meta": {'alias': 'copy_directives', 'domain_of': ['ElementDerivation']} }) - overrides: Optional[Any] = Field(None, description="""overrides source schema slots""", json_schema_extra = { "linkml_meta": {'alias': 'overrides', 'domain_of': ['ElementDerivation']} }) - is_a: Optional[str] = Field(None, json_schema_extra = { "linkml_meta": {'alias': 'is_a', 'domain_of': ['ElementDerivation'], 'slot_uri': 'linkml:is_a'} }) - mixins: Optional[List[str]] = Field(default_factory=list, json_schema_extra = { "linkml_meta": {'alias': 'mixins', - 'domain_of': ['ElementDerivation'], - 'slot_uri': 'linkml:mixins'} }) - value_mappings: Optional[Dict[str, KeyVal]] = Field(default_factory=dict, description="""A mapping table that is applied directly to mappings, in order of precedence""", json_schema_extra = { "linkml_meta": {'alias': 'value_mappings', 'domain_of': ['ElementDerivation']} }) - expression_to_value_mappings: Optional[Dict[str, KeyVal]] = Field(default_factory=dict, description="""A mapping table in which the keys are expressions""", json_schema_extra = { "linkml_meta": {'alias': 'expression_to_value_mappings', 'domain_of': ['ElementDerivation']} }) - expression_to_expression_mappings: Optional[Dict[str, KeyVal]] = Field(default_factory=dict, description="""A mapping table in which the keys and values are expressions""", json_schema_extra = { "linkml_meta": {'alias': 'expression_to_expression_mappings', - 'domain_of': ['ElementDerivation']} }) - mirror_source: Optional[bool] = Field(None, json_schema_extra = { "linkml_meta": {'alias': 'mirror_source', 'domain_of': ['ElementDerivation']} }) - description: Optional[str] = Field(None, description="""description of the specification component""", json_schema_extra = { "linkml_meta": {'alias': 'description', - 'domain_of': ['SpecificationComponent'], - 'slot_uri': 'dcterms:description'} }) - implements: Optional[List[str]] = Field(default_factory=list, description="""A reference to a specification that this component implements.""", json_schema_extra = { "linkml_meta": {'alias': 'implements', 'domain_of': ['SpecificationComponent']} }) - comments: Optional[List[str]] = Field(default_factory=list, description="""A list of comments about this component. Comments are free text, and may be used to provide additional information about the component, including instructions for its use.""", json_schema_extra = { "linkml_meta": {'alias': 'comments', - 'domain_of': ['SpecificationComponent'], - 'slot_uri': 'rdfs:comment'} }) + + linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta( + {"from_schema": "https://w3id.org/linkml/transformer"} + ) + + populated_from: Optional[str] = Field( + None, + description="""Name of the class in the source schema""", + json_schema_extra={ + "linkml_meta": { + "alias": "populated_from", + "domain_of": [ + "ClassDerivation", + "SlotDerivation", + "EnumDerivation", + "PermissibleValueDerivation", + ], + } + }, + ) + sources: Optional[List[str]] = Field( + default_factory=list, + json_schema_extra={ + "linkml_meta": { + "alias": "sources", + "domain_of": [ + "ClassDerivation", + "SlotDerivation", + "EnumDerivation", + "PermissibleValueDerivation", + ], + } + }, + ) + joins: Optional[Dict[str, AliasedClass]] = Field( + default_factory=dict, + description="""Additional classes to be joined to derive instances of the target class""", + json_schema_extra={ + "linkml_meta": { + "alias": "joins", + "comments": ["not yet implemented"], + "domain_of": ["ClassDerivation"], + } + }, + ) + slot_derivations: Optional[Dict[str, SlotDerivation]] = Field( + default_factory=dict, + json_schema_extra={ + "linkml_meta": { + "alias": "slot_derivations", + "domain_of": ["TransformationSpecification", "ClassDerivation"], + } + }, + ) + target_definition: Optional[Any] = Field( + None, + description="""LinkML class definition object for this slot.""", + json_schema_extra={ + "linkml_meta": { + "alias": "target_definition", + "comments": ["currently defined as Any to avoid coupling with metamodel"], + "domain_of": ["ClassDerivation", "SlotDerivation"], + } + }, + ) + name: str = Field( + ..., + description="""Name of the element in the target schema""", + json_schema_extra={ + "linkml_meta": { + "alias": "name", + "domain_of": [ + "ElementDerivation", + "SlotDerivation", + "EnumDerivation", + "PermissibleValueDerivation", + ], + } + }, + ) + copy_directives: Optional[Dict[str, CopyDirective]] = Field( + default_factory=dict, + json_schema_extra={ + "linkml_meta": {"alias": "copy_directives", "domain_of": ["ElementDerivation"]} + }, + ) + overrides: Optional[Any] = Field( + None, + description="""overrides source schema slots""", + json_schema_extra={ + "linkml_meta": {"alias": "overrides", "domain_of": ["ElementDerivation"]} + }, + ) + is_a: Optional[str] = Field( + None, + json_schema_extra={ + "linkml_meta": { + "alias": "is_a", + "domain_of": ["ElementDerivation"], + "slot_uri": "linkml:is_a", + } + }, + ) + mixins: Optional[List[str]] = Field( + default_factory=list, + json_schema_extra={ + "linkml_meta": { + "alias": "mixins", + "domain_of": ["ElementDerivation"], + "slot_uri": "linkml:mixins", + } + }, + ) + value_mappings: Optional[Dict[str, KeyVal]] = Field( + default_factory=dict, + description="""A mapping table that is applied directly to mappings, in order of precedence""", + json_schema_extra={ + "linkml_meta": {"alias": "value_mappings", "domain_of": ["ElementDerivation"]} + }, + ) + expression_to_value_mappings: Optional[Dict[str, KeyVal]] = Field( + default_factory=dict, + description="""A mapping table in which the keys are expressions""", + json_schema_extra={ + "linkml_meta": { + "alias": "expression_to_value_mappings", + "domain_of": ["ElementDerivation"], + } + }, + ) + expression_to_expression_mappings: Optional[Dict[str, KeyVal]] = Field( + default_factory=dict, + description="""A mapping table in which the keys and values are expressions""", + json_schema_extra={ + "linkml_meta": { + "alias": "expression_to_expression_mappings", + "domain_of": ["ElementDerivation"], + } + }, + ) + mirror_source: Optional[bool] = Field( + None, + json_schema_extra={ + "linkml_meta": {"alias": "mirror_source", "domain_of": ["ElementDerivation"]} + }, + ) + description: Optional[str] = Field( + None, + description="""description of the specification component""", + json_schema_extra={ + "linkml_meta": { + "alias": "description", + "domain_of": ["SpecificationComponent"], + "slot_uri": "dcterms:description", + } + }, + ) + implements: Optional[List[str]] = Field( + default_factory=list, + description="""A reference to a specification that this component implements.""", + json_schema_extra={ + "linkml_meta": {"alias": "implements", "domain_of": ["SpecificationComponent"]} + }, + ) + comments: Optional[List[str]] = Field( + default_factory=list, + description="""A list of comments about this component. Comments are free text, and may be used to provide additional information about the component, including instructions for its use.""", + json_schema_extra={ + "linkml_meta": { + "alias": "comments", + "domain_of": ["SpecificationComponent"], + "slot_uri": "rdfs:comment", + } + }, + ) class AliasedClass(ConfiguredBaseModel): """ alias-class key value pairs for classes """ - linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({'from_schema': 'https://w3id.org/linkml/transformer'}) - alias: str = Field(..., description="""name of the class to be aliased""", json_schema_extra = { "linkml_meta": {'alias': 'alias', 'domain_of': ['AliasedClass']} }) - class_named: Optional[str] = Field(None, description="""local alias for the class""", json_schema_extra = { "linkml_meta": {'alias': 'class_named', 'domain_of': ['AliasedClass']} }) + linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta( + {"from_schema": "https://w3id.org/linkml/transformer"} + ) + + alias: str = Field( + ..., + description="""name of the class to be aliased""", + json_schema_extra={"linkml_meta": {"alias": "alias", "domain_of": ["AliasedClass"]}}, + ) + class_named: Optional[str] = Field( + None, + description="""local alias for the class""", + json_schema_extra={"linkml_meta": {"alias": "class_named", "domain_of": ["AliasedClass"]}}, + ) class SlotDerivation(ElementDerivation): """ A specification of how to derive the value of a target slot from a source slot """ - linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({'from_schema': 'https://w3id.org/linkml/transformer'}) - - name: str = Field(..., description="""Target slot name""", json_schema_extra = { "linkml_meta": {'alias': 'name', - 'domain_of': ['ElementDerivation', - 'SlotDerivation', - 'EnumDerivation', - 'PermissibleValueDerivation']} }) - populated_from: Optional[str] = Field(None, description="""Source slot name""", json_schema_extra = { "linkml_meta": {'alias': 'populated_from', - 'domain_of': ['ClassDerivation', - 'SlotDerivation', - 'EnumDerivation', - 'PermissibleValueDerivation']} }) - sources: Optional[List[str]] = Field(default_factory=list, json_schema_extra = { "linkml_meta": {'alias': 'sources', - 'domain_of': ['ClassDerivation', - 'SlotDerivation', - 'EnumDerivation', - 'PermissibleValueDerivation']} }) - derived_from: Optional[List[str]] = Field(default_factory=list, description="""Source slots that are used to derive this slot. This can be computed from the expr, if the expr is declarative.""", json_schema_extra = { "linkml_meta": {'alias': 'derived_from', 'domain_of': ['SlotDerivation']} }) - expr: Optional[str] = Field(None, description="""An expression to be evaluated on the source object to derive the target slot. Should be specified using the LinkML expression language.""", json_schema_extra = { "linkml_meta": {'alias': 'expr', - 'domain_of': ['SlotDerivation', - 'EnumDerivation', - 'PermissibleValueDerivation']} }) - range: Optional[str] = Field(None, json_schema_extra = { "linkml_meta": {'alias': 'range', 'domain_of': ['SlotDerivation'], 'slot_uri': 'linkml:range'} }) - unit_conversion: Optional[UnitConversionConfiguration] = Field(None, json_schema_extra = { "linkml_meta": {'alias': 'unit_conversion', 'domain_of': ['SlotDerivation']} }) - inverse_of: Optional[Inverse] = Field(None, description="""Used to specify a class-slot tuple that is the inverse of the derived/target slot. This is used primarily for mapping to relational databases or formalisms that do not allow multiple values. The class representing the repeated element has a foreign key slot inserted in that 'back references' the original multivalued slot.""", json_schema_extra = { "linkml_meta": {'alias': 'inverse_of', 'domain_of': ['SlotDerivation']} }) - hide: Optional[bool] = Field(None, description="""True if this is suppressed""", json_schema_extra = { "linkml_meta": {'alias': 'hide', - 'domain_of': ['SlotDerivation', - 'EnumDerivation', - 'PermissibleValueDerivation']} }) - type_designator: Optional[bool] = Field(None, json_schema_extra = { "linkml_meta": {'alias': 'type_designator', 'domain_of': ['SlotDerivation']} }) - target_definition: Optional[Any] = Field(None, description="""LinkML definition object for this slot.""", json_schema_extra = { "linkml_meta": {'alias': 'target_definition', - 'comments': ['currently defined as Any to avoid coupling with metamodel'], - 'domain_of': ['ClassDerivation', 'SlotDerivation']} }) - cast_collection_as: Optional[CollectionType] = Field(None, json_schema_extra = { "linkml_meta": {'alias': 'cast_collection_as', 'domain_of': ['SlotDerivation']} }) - dictionary_key: Optional[str] = Field(None, json_schema_extra = { "linkml_meta": {'alias': 'dictionary_key', 'domain_of': ['SlotDerivation']} }) - stringification: Optional[StringificationConfiguration] = Field(None, json_schema_extra = { "linkml_meta": {'alias': 'stringification', 'domain_of': ['SlotDerivation']} }) - aggregation_operation: Optional[AggregationOperation] = Field(None, json_schema_extra = { "linkml_meta": {'alias': 'aggregation_operation', 'domain_of': ['SlotDerivation']} }) - copy_directives: Optional[Dict[str, CopyDirective]] = Field(default_factory=dict, json_schema_extra = { "linkml_meta": {'alias': 'copy_directives', 'domain_of': ['ElementDerivation']} }) - overrides: Optional[Any] = Field(None, description="""overrides source schema slots""", json_schema_extra = { "linkml_meta": {'alias': 'overrides', 'domain_of': ['ElementDerivation']} }) - is_a: Optional[str] = Field(None, json_schema_extra = { "linkml_meta": {'alias': 'is_a', 'domain_of': ['ElementDerivation'], 'slot_uri': 'linkml:is_a'} }) - mixins: Optional[List[str]] = Field(default_factory=list, json_schema_extra = { "linkml_meta": {'alias': 'mixins', - 'domain_of': ['ElementDerivation'], - 'slot_uri': 'linkml:mixins'} }) - value_mappings: Optional[Dict[str, KeyVal]] = Field(default_factory=dict, description="""A mapping table that is applied directly to mappings, in order of precedence""", json_schema_extra = { "linkml_meta": {'alias': 'value_mappings', 'domain_of': ['ElementDerivation']} }) - expression_to_value_mappings: Optional[Dict[str, KeyVal]] = Field(default_factory=dict, description="""A mapping table in which the keys are expressions""", json_schema_extra = { "linkml_meta": {'alias': 'expression_to_value_mappings', 'domain_of': ['ElementDerivation']} }) - expression_to_expression_mappings: Optional[Dict[str, KeyVal]] = Field(default_factory=dict, description="""A mapping table in which the keys and values are expressions""", json_schema_extra = { "linkml_meta": {'alias': 'expression_to_expression_mappings', - 'domain_of': ['ElementDerivation']} }) - mirror_source: Optional[bool] = Field(None, json_schema_extra = { "linkml_meta": {'alias': 'mirror_source', 'domain_of': ['ElementDerivation']} }) - description: Optional[str] = Field(None, description="""description of the specification component""", json_schema_extra = { "linkml_meta": {'alias': 'description', - 'domain_of': ['SpecificationComponent'], - 'slot_uri': 'dcterms:description'} }) - implements: Optional[List[str]] = Field(default_factory=list, description="""A reference to a specification that this component implements.""", json_schema_extra = { "linkml_meta": {'alias': 'implements', 'domain_of': ['SpecificationComponent']} }) - comments: Optional[List[str]] = Field(default_factory=list, description="""A list of comments about this component. Comments are free text, and may be used to provide additional information about the component, including instructions for its use.""", json_schema_extra = { "linkml_meta": {'alias': 'comments', - 'domain_of': ['SpecificationComponent'], - 'slot_uri': 'rdfs:comment'} }) + + linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta( + {"from_schema": "https://w3id.org/linkml/transformer"} + ) + + name: str = Field( + ..., + description="""Target slot name""", + json_schema_extra={ + "linkml_meta": { + "alias": "name", + "domain_of": [ + "ElementDerivation", + "SlotDerivation", + "EnumDerivation", + "PermissibleValueDerivation", + ], + } + }, + ) + populated_from: Optional[str] = Field( + None, + description="""Source slot name""", + json_schema_extra={ + "linkml_meta": { + "alias": "populated_from", + "domain_of": [ + "ClassDerivation", + "SlotDerivation", + "EnumDerivation", + "PermissibleValueDerivation", + ], + } + }, + ) + sources: Optional[List[str]] = Field( + default_factory=list, + json_schema_extra={ + "linkml_meta": { + "alias": "sources", + "domain_of": [ + "ClassDerivation", + "SlotDerivation", + "EnumDerivation", + "PermissibleValueDerivation", + ], + } + }, + ) + derived_from: Optional[List[str]] = Field( + default_factory=list, + description="""Source slots that are used to derive this slot. This can be computed from the expr, if the expr is declarative.""", + json_schema_extra={ + "linkml_meta": {"alias": "derived_from", "domain_of": ["SlotDerivation"]} + }, + ) + expr: Optional[str] = Field( + None, + description="""An expression to be evaluated on the source object to derive the target slot. Should be specified using the LinkML expression language.""", + json_schema_extra={ + "linkml_meta": { + "alias": "expr", + "domain_of": ["SlotDerivation", "EnumDerivation", "PermissibleValueDerivation"], + } + }, + ) + range: Optional[str] = Field( + None, + json_schema_extra={ + "linkml_meta": { + "alias": "range", + "domain_of": ["SlotDerivation"], + "slot_uri": "linkml:range", + } + }, + ) + unit_conversion: Optional[UnitConversionConfiguration] = Field( + None, + json_schema_extra={ + "linkml_meta": {"alias": "unit_conversion", "domain_of": ["SlotDerivation"]} + }, + ) + inverse_of: Optional[Inverse] = Field( + None, + description="""Used to specify a class-slot tuple that is the inverse of the derived/target slot. This is used primarily for mapping to relational databases or formalisms that do not allow multiple values. The class representing the repeated element has a foreign key slot inserted in that 'back references' the original multivalued slot.""", + json_schema_extra={"linkml_meta": {"alias": "inverse_of", "domain_of": ["SlotDerivation"]}}, + ) + hide: Optional[bool] = Field( + None, + description="""True if this is suppressed""", + json_schema_extra={ + "linkml_meta": { + "alias": "hide", + "domain_of": ["SlotDerivation", "EnumDerivation", "PermissibleValueDerivation"], + } + }, + ) + type_designator: Optional[bool] = Field( + None, + json_schema_extra={ + "linkml_meta": {"alias": "type_designator", "domain_of": ["SlotDerivation"]} + }, + ) + target_definition: Optional[Any] = Field( + None, + description="""LinkML definition object for this slot.""", + json_schema_extra={ + "linkml_meta": { + "alias": "target_definition", + "comments": ["currently defined as Any to avoid coupling with metamodel"], + "domain_of": ["ClassDerivation", "SlotDerivation"], + } + }, + ) + cast_collection_as: Optional[CollectionType] = Field( + None, + json_schema_extra={ + "linkml_meta": {"alias": "cast_collection_as", "domain_of": ["SlotDerivation"]} + }, + ) + dictionary_key: Optional[str] = Field( + None, + json_schema_extra={ + "linkml_meta": {"alias": "dictionary_key", "domain_of": ["SlotDerivation"]} + }, + ) + stringification: Optional[StringificationConfiguration] = Field( + None, + json_schema_extra={ + "linkml_meta": {"alias": "stringification", "domain_of": ["SlotDerivation"]} + }, + ) + aggregation_operation: Optional[AggregationOperation] = Field( + None, + json_schema_extra={ + "linkml_meta": {"alias": "aggregation_operation", "domain_of": ["SlotDerivation"]} + }, + ) + copy_directives: Optional[Dict[str, CopyDirective]] = Field( + default_factory=dict, + json_schema_extra={ + "linkml_meta": {"alias": "copy_directives", "domain_of": ["ElementDerivation"]} + }, + ) + overrides: Optional[Any] = Field( + None, + description="""overrides source schema slots""", + json_schema_extra={ + "linkml_meta": {"alias": "overrides", "domain_of": ["ElementDerivation"]} + }, + ) + is_a: Optional[str] = Field( + None, + json_schema_extra={ + "linkml_meta": { + "alias": "is_a", + "domain_of": ["ElementDerivation"], + "slot_uri": "linkml:is_a", + } + }, + ) + mixins: Optional[List[str]] = Field( + default_factory=list, + json_schema_extra={ + "linkml_meta": { + "alias": "mixins", + "domain_of": ["ElementDerivation"], + "slot_uri": "linkml:mixins", + } + }, + ) + value_mappings: Optional[Dict[str, KeyVal]] = Field( + default_factory=dict, + description="""A mapping table that is applied directly to mappings, in order of precedence""", + json_schema_extra={ + "linkml_meta": {"alias": "value_mappings", "domain_of": ["ElementDerivation"]} + }, + ) + expression_to_value_mappings: Optional[Dict[str, KeyVal]] = Field( + default_factory=dict, + description="""A mapping table in which the keys are expressions""", + json_schema_extra={ + "linkml_meta": { + "alias": "expression_to_value_mappings", + "domain_of": ["ElementDerivation"], + } + }, + ) + expression_to_expression_mappings: Optional[Dict[str, KeyVal]] = Field( + default_factory=dict, + description="""A mapping table in which the keys and values are expressions""", + json_schema_extra={ + "linkml_meta": { + "alias": "expression_to_expression_mappings", + "domain_of": ["ElementDerivation"], + } + }, + ) + mirror_source: Optional[bool] = Field( + None, + json_schema_extra={ + "linkml_meta": {"alias": "mirror_source", "domain_of": ["ElementDerivation"]} + }, + ) + description: Optional[str] = Field( + None, + description="""description of the specification component""", + json_schema_extra={ + "linkml_meta": { + "alias": "description", + "domain_of": ["SpecificationComponent"], + "slot_uri": "dcterms:description", + } + }, + ) + implements: Optional[List[str]] = Field( + default_factory=list, + description="""A reference to a specification that this component implements.""", + json_schema_extra={ + "linkml_meta": {"alias": "implements", "domain_of": ["SpecificationComponent"]} + }, + ) + comments: Optional[List[str]] = Field( + default_factory=list, + description="""A list of comments about this component. Comments are free text, and may be used to provide additional information about the component, including instructions for its use.""", + json_schema_extra={ + "linkml_meta": { + "alias": "comments", + "domain_of": ["SpecificationComponent"], + "slot_uri": "rdfs:comment", + } + }, + ) class EnumDerivation(ElementDerivation): """ A specification of how to derive the value of a target enum from a source enum """ - linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({'from_schema': 'https://w3id.org/linkml/transformer'}) - - name: str = Field(..., description="""Target enum name""", json_schema_extra = { "linkml_meta": {'alias': 'name', - 'domain_of': ['ElementDerivation', - 'SlotDerivation', - 'EnumDerivation', - 'PermissibleValueDerivation']} }) - populated_from: Optional[str] = Field(None, description="""Source enum name""", json_schema_extra = { "linkml_meta": {'alias': 'populated_from', - 'domain_of': ['ClassDerivation', - 'SlotDerivation', - 'EnumDerivation', - 'PermissibleValueDerivation']} }) - sources: Optional[List[str]] = Field(default_factory=list, json_schema_extra = { "linkml_meta": {'alias': 'sources', - 'domain_of': ['ClassDerivation', - 'SlotDerivation', - 'EnumDerivation', - 'PermissibleValueDerivation']} }) - expr: Optional[str] = Field(None, description="""An expression to be evaluated on the source object to derive the target slot. Should be specified using the LinkML expression language.""", json_schema_extra = { "linkml_meta": {'alias': 'expr', - 'domain_of': ['SlotDerivation', - 'EnumDerivation', - 'PermissibleValueDerivation']} }) - hide: Optional[bool] = Field(None, description="""True if this is suppressed""", json_schema_extra = { "linkml_meta": {'alias': 'hide', - 'domain_of': ['SlotDerivation', - 'EnumDerivation', - 'PermissibleValueDerivation']} }) - permissible_value_derivations: Optional[Dict[str, PermissibleValueDerivation]] = Field(default_factory=dict, description="""Instructions on how to derive a set of PVs in the target schema""", json_schema_extra = { "linkml_meta": {'alias': 'permissible_value_derivations', 'domain_of': ['EnumDerivation']} }) - copy_directives: Optional[Dict[str, CopyDirective]] = Field(default_factory=dict, json_schema_extra = { "linkml_meta": {'alias': 'copy_directives', 'domain_of': ['ElementDerivation']} }) - overrides: Optional[Any] = Field(None, description="""overrides source schema slots""", json_schema_extra = { "linkml_meta": {'alias': 'overrides', 'domain_of': ['ElementDerivation']} }) - is_a: Optional[str] = Field(None, json_schema_extra = { "linkml_meta": {'alias': 'is_a', 'domain_of': ['ElementDerivation'], 'slot_uri': 'linkml:is_a'} }) - mixins: Optional[List[str]] = Field(default_factory=list, json_schema_extra = { "linkml_meta": {'alias': 'mixins', - 'domain_of': ['ElementDerivation'], - 'slot_uri': 'linkml:mixins'} }) - value_mappings: Optional[Dict[str, KeyVal]] = Field(default_factory=dict, description="""A mapping table that is applied directly to mappings, in order of precedence""", json_schema_extra = { "linkml_meta": {'alias': 'value_mappings', 'domain_of': ['ElementDerivation']} }) - expression_to_value_mappings: Optional[Dict[str, KeyVal]] = Field(default_factory=dict, description="""A mapping table in which the keys are expressions""", json_schema_extra = { "linkml_meta": {'alias': 'expression_to_value_mappings', 'domain_of': ['ElementDerivation']} }) - expression_to_expression_mappings: Optional[Dict[str, KeyVal]] = Field(default_factory=dict, description="""A mapping table in which the keys and values are expressions""", json_schema_extra = { "linkml_meta": {'alias': 'expression_to_expression_mappings', - 'domain_of': ['ElementDerivation']} }) - mirror_source: Optional[bool] = Field(None, json_schema_extra = { "linkml_meta": {'alias': 'mirror_source', 'domain_of': ['ElementDerivation']} }) - description: Optional[str] = Field(None, description="""description of the specification component""", json_schema_extra = { "linkml_meta": {'alias': 'description', - 'domain_of': ['SpecificationComponent'], - 'slot_uri': 'dcterms:description'} }) - implements: Optional[List[str]] = Field(default_factory=list, description="""A reference to a specification that this component implements.""", json_schema_extra = { "linkml_meta": {'alias': 'implements', 'domain_of': ['SpecificationComponent']} }) - comments: Optional[List[str]] = Field(default_factory=list, description="""A list of comments about this component. Comments are free text, and may be used to provide additional information about the component, including instructions for its use.""", json_schema_extra = { "linkml_meta": {'alias': 'comments', - 'domain_of': ['SpecificationComponent'], - 'slot_uri': 'rdfs:comment'} }) + + linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta( + {"from_schema": "https://w3id.org/linkml/transformer"} + ) + + name: str = Field( + ..., + description="""Target enum name""", + json_schema_extra={ + "linkml_meta": { + "alias": "name", + "domain_of": [ + "ElementDerivation", + "SlotDerivation", + "EnumDerivation", + "PermissibleValueDerivation", + ], + } + }, + ) + populated_from: Optional[str] = Field( + None, + description="""Source enum name""", + json_schema_extra={ + "linkml_meta": { + "alias": "populated_from", + "domain_of": [ + "ClassDerivation", + "SlotDerivation", + "EnumDerivation", + "PermissibleValueDerivation", + ], + } + }, + ) + sources: Optional[List[str]] = Field( + default_factory=list, + json_schema_extra={ + "linkml_meta": { + "alias": "sources", + "domain_of": [ + "ClassDerivation", + "SlotDerivation", + "EnumDerivation", + "PermissibleValueDerivation", + ], + } + }, + ) + expr: Optional[str] = Field( + None, + description="""An expression to be evaluated on the source object to derive the target slot. Should be specified using the LinkML expression language.""", + json_schema_extra={ + "linkml_meta": { + "alias": "expr", + "domain_of": ["SlotDerivation", "EnumDerivation", "PermissibleValueDerivation"], + } + }, + ) + hide: Optional[bool] = Field( + None, + description="""True if this is suppressed""", + json_schema_extra={ + "linkml_meta": { + "alias": "hide", + "domain_of": ["SlotDerivation", "EnumDerivation", "PermissibleValueDerivation"], + } + }, + ) + permissible_value_derivations: Optional[Dict[str, PermissibleValueDerivation]] = Field( + default_factory=dict, + description="""Instructions on how to derive a set of PVs in the target schema""", + json_schema_extra={ + "linkml_meta": { + "alias": "permissible_value_derivations", + "domain_of": ["EnumDerivation"], + } + }, + ) + copy_directives: Optional[Dict[str, CopyDirective]] = Field( + default_factory=dict, + json_schema_extra={ + "linkml_meta": {"alias": "copy_directives", "domain_of": ["ElementDerivation"]} + }, + ) + overrides: Optional[Any] = Field( + None, + description="""overrides source schema slots""", + json_schema_extra={ + "linkml_meta": {"alias": "overrides", "domain_of": ["ElementDerivation"]} + }, + ) + is_a: Optional[str] = Field( + None, + json_schema_extra={ + "linkml_meta": { + "alias": "is_a", + "domain_of": ["ElementDerivation"], + "slot_uri": "linkml:is_a", + } + }, + ) + mixins: Optional[List[str]] = Field( + default_factory=list, + json_schema_extra={ + "linkml_meta": { + "alias": "mixins", + "domain_of": ["ElementDerivation"], + "slot_uri": "linkml:mixins", + } + }, + ) + value_mappings: Optional[Dict[str, KeyVal]] = Field( + default_factory=dict, + description="""A mapping table that is applied directly to mappings, in order of precedence""", + json_schema_extra={ + "linkml_meta": {"alias": "value_mappings", "domain_of": ["ElementDerivation"]} + }, + ) + expression_to_value_mappings: Optional[Dict[str, KeyVal]] = Field( + default_factory=dict, + description="""A mapping table in which the keys are expressions""", + json_schema_extra={ + "linkml_meta": { + "alias": "expression_to_value_mappings", + "domain_of": ["ElementDerivation"], + } + }, + ) + expression_to_expression_mappings: Optional[Dict[str, KeyVal]] = Field( + default_factory=dict, + description="""A mapping table in which the keys and values are expressions""", + json_schema_extra={ + "linkml_meta": { + "alias": "expression_to_expression_mappings", + "domain_of": ["ElementDerivation"], + } + }, + ) + mirror_source: Optional[bool] = Field( + None, + json_schema_extra={ + "linkml_meta": {"alias": "mirror_source", "domain_of": ["ElementDerivation"]} + }, + ) + description: Optional[str] = Field( + None, + description="""description of the specification component""", + json_schema_extra={ + "linkml_meta": { + "alias": "description", + "domain_of": ["SpecificationComponent"], + "slot_uri": "dcterms:description", + } + }, + ) + implements: Optional[List[str]] = Field( + default_factory=list, + description="""A reference to a specification that this component implements.""", + json_schema_extra={ + "linkml_meta": {"alias": "implements", "domain_of": ["SpecificationComponent"]} + }, + ) + comments: Optional[List[str]] = Field( + default_factory=list, + description="""A list of comments about this component. Comments are free text, and may be used to provide additional information about the component, including instructions for its use.""", + json_schema_extra={ + "linkml_meta": { + "alias": "comments", + "domain_of": ["SpecificationComponent"], + "slot_uri": "rdfs:comment", + } + }, + ) class PermissibleValueDerivation(ElementDerivation): """ A specification of how to derive the value of a PV from a source enum """ - linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({'from_schema': 'https://w3id.org/linkml/transformer', - 'todos': ['this is currently under-specified. We will need boolean ' - 'combinators to express if-then-else']}) - - name: str = Field(..., description="""Target permissible value text""", json_schema_extra = { "linkml_meta": {'alias': 'name', - 'domain_of': ['ElementDerivation', - 'SlotDerivation', - 'EnumDerivation', - 'PermissibleValueDerivation']} }) - expr: Optional[str] = Field(None, json_schema_extra = { "linkml_meta": {'alias': 'expr', - 'domain_of': ['SlotDerivation', - 'EnumDerivation', - 'PermissibleValueDerivation']} }) - populated_from: Optional[str] = Field(None, description="""Source permissible value""", json_schema_extra = { "linkml_meta": {'alias': 'populated_from', - 'domain_of': ['ClassDerivation', - 'SlotDerivation', - 'EnumDerivation', - 'PermissibleValueDerivation']} }) - sources: Optional[List[str]] = Field(default_factory=list, json_schema_extra = { "linkml_meta": {'alias': 'sources', - 'domain_of': ['ClassDerivation', - 'SlotDerivation', - 'EnumDerivation', - 'PermissibleValueDerivation']} }) - hide: Optional[bool] = Field(None, json_schema_extra = { "linkml_meta": {'alias': 'hide', - 'domain_of': ['SlotDerivation', - 'EnumDerivation', - 'PermissibleValueDerivation']} }) - copy_directives: Optional[Dict[str, CopyDirective]] = Field(default_factory=dict, json_schema_extra = { "linkml_meta": {'alias': 'copy_directives', 'domain_of': ['ElementDerivation']} }) - overrides: Optional[Any] = Field(None, description="""overrides source schema slots""", json_schema_extra = { "linkml_meta": {'alias': 'overrides', 'domain_of': ['ElementDerivation']} }) - is_a: Optional[str] = Field(None, json_schema_extra = { "linkml_meta": {'alias': 'is_a', 'domain_of': ['ElementDerivation'], 'slot_uri': 'linkml:is_a'} }) - mixins: Optional[List[str]] = Field(default_factory=list, json_schema_extra = { "linkml_meta": {'alias': 'mixins', - 'domain_of': ['ElementDerivation'], - 'slot_uri': 'linkml:mixins'} }) - value_mappings: Optional[Dict[str, KeyVal]] = Field(default_factory=dict, description="""A mapping table that is applied directly to mappings, in order of precedence""", json_schema_extra = { "linkml_meta": {'alias': 'value_mappings', 'domain_of': ['ElementDerivation']} }) - expression_to_value_mappings: Optional[Dict[str, KeyVal]] = Field(default_factory=dict, description="""A mapping table in which the keys are expressions""", json_schema_extra = { "linkml_meta": {'alias': 'expression_to_value_mappings', 'domain_of': ['ElementDerivation']} }) - expression_to_expression_mappings: Optional[Dict[str, KeyVal]] = Field(default_factory=dict, description="""A mapping table in which the keys and values are expressions""", json_schema_extra = { "linkml_meta": {'alias': 'expression_to_expression_mappings', - 'domain_of': ['ElementDerivation']} }) - mirror_source: Optional[bool] = Field(None, json_schema_extra = { "linkml_meta": {'alias': 'mirror_source', 'domain_of': ['ElementDerivation']} }) - description: Optional[str] = Field(None, description="""description of the specification component""", json_schema_extra = { "linkml_meta": {'alias': 'description', - 'domain_of': ['SpecificationComponent'], - 'slot_uri': 'dcterms:description'} }) - implements: Optional[List[str]] = Field(default_factory=list, description="""A reference to a specification that this component implements.""", json_schema_extra = { "linkml_meta": {'alias': 'implements', 'domain_of': ['SpecificationComponent']} }) - comments: Optional[List[str]] = Field(default_factory=list, description="""A list of comments about this component. Comments are free text, and may be used to provide additional information about the component, including instructions for its use.""", json_schema_extra = { "linkml_meta": {'alias': 'comments', - 'domain_of': ['SpecificationComponent'], - 'slot_uri': 'rdfs:comment'} }) + + linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta( + { + "from_schema": "https://w3id.org/linkml/transformer", + "todos": [ + "this is currently under-specified. We will need boolean " + "combinators to express if-then-else" + ], + } + ) + + name: str = Field( + ..., + description="""Target permissible value text""", + json_schema_extra={ + "linkml_meta": { + "alias": "name", + "domain_of": [ + "ElementDerivation", + "SlotDerivation", + "EnumDerivation", + "PermissibleValueDerivation", + ], + } + }, + ) + expr: Optional[str] = Field( + None, + json_schema_extra={ + "linkml_meta": { + "alias": "expr", + "domain_of": ["SlotDerivation", "EnumDerivation", "PermissibleValueDerivation"], + } + }, + ) + populated_from: Optional[str] = Field( + None, + description="""Source permissible value""", + json_schema_extra={ + "linkml_meta": { + "alias": "populated_from", + "domain_of": [ + "ClassDerivation", + "SlotDerivation", + "EnumDerivation", + "PermissibleValueDerivation", + ], + } + }, + ) + sources: Optional[List[str]] = Field( + default_factory=list, + json_schema_extra={ + "linkml_meta": { + "alias": "sources", + "domain_of": [ + "ClassDerivation", + "SlotDerivation", + "EnumDerivation", + "PermissibleValueDerivation", + ], + } + }, + ) + hide: Optional[bool] = Field( + None, + json_schema_extra={ + "linkml_meta": { + "alias": "hide", + "domain_of": ["SlotDerivation", "EnumDerivation", "PermissibleValueDerivation"], + } + }, + ) + copy_directives: Optional[Dict[str, CopyDirective]] = Field( + default_factory=dict, + json_schema_extra={ + "linkml_meta": {"alias": "copy_directives", "domain_of": ["ElementDerivation"]} + }, + ) + overrides: Optional[Any] = Field( + None, + description="""overrides source schema slots""", + json_schema_extra={ + "linkml_meta": {"alias": "overrides", "domain_of": ["ElementDerivation"]} + }, + ) + is_a: Optional[str] = Field( + None, + json_schema_extra={ + "linkml_meta": { + "alias": "is_a", + "domain_of": ["ElementDerivation"], + "slot_uri": "linkml:is_a", + } + }, + ) + mixins: Optional[List[str]] = Field( + default_factory=list, + json_schema_extra={ + "linkml_meta": { + "alias": "mixins", + "domain_of": ["ElementDerivation"], + "slot_uri": "linkml:mixins", + } + }, + ) + value_mappings: Optional[Dict[str, KeyVal]] = Field( + default_factory=dict, + description="""A mapping table that is applied directly to mappings, in order of precedence""", + json_schema_extra={ + "linkml_meta": {"alias": "value_mappings", "domain_of": ["ElementDerivation"]} + }, + ) + expression_to_value_mappings: Optional[Dict[str, KeyVal]] = Field( + default_factory=dict, + description="""A mapping table in which the keys are expressions""", + json_schema_extra={ + "linkml_meta": { + "alias": "expression_to_value_mappings", + "domain_of": ["ElementDerivation"], + } + }, + ) + expression_to_expression_mappings: Optional[Dict[str, KeyVal]] = Field( + default_factory=dict, + description="""A mapping table in which the keys and values are expressions""", + json_schema_extra={ + "linkml_meta": { + "alias": "expression_to_expression_mappings", + "domain_of": ["ElementDerivation"], + } + }, + ) + mirror_source: Optional[bool] = Field( + None, + json_schema_extra={ + "linkml_meta": {"alias": "mirror_source", "domain_of": ["ElementDerivation"]} + }, + ) + description: Optional[str] = Field( + None, + description="""description of the specification component""", + json_schema_extra={ + "linkml_meta": { + "alias": "description", + "domain_of": ["SpecificationComponent"], + "slot_uri": "dcterms:description", + } + }, + ) + implements: Optional[List[str]] = Field( + default_factory=list, + description="""A reference to a specification that this component implements.""", + json_schema_extra={ + "linkml_meta": {"alias": "implements", "domain_of": ["SpecificationComponent"]} + }, + ) + comments: Optional[List[str]] = Field( + default_factory=list, + description="""A list of comments about this component. Comments are free text, and may be used to provide additional information about the component, including instructions for its use.""", + json_schema_extra={ + "linkml_meta": { + "alias": "comments", + "domain_of": ["SpecificationComponent"], + "slot_uri": "rdfs:comment", + } + }, + ) class PrefixDerivation(ElementDerivation): - linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({'from_schema': 'https://w3id.org/linkml/transformer'}) - - name: str = Field(..., description="""Name of the element in the target schema""", json_schema_extra = { "linkml_meta": {'alias': 'name', - 'domain_of': ['ElementDerivation', - 'SlotDerivation', - 'EnumDerivation', - 'PermissibleValueDerivation']} }) - copy_directives: Optional[Dict[str, CopyDirective]] = Field(default_factory=dict, json_schema_extra = { "linkml_meta": {'alias': 'copy_directives', 'domain_of': ['ElementDerivation']} }) - overrides: Optional[Any] = Field(None, description="""overrides source schema slots""", json_schema_extra = { "linkml_meta": {'alias': 'overrides', 'domain_of': ['ElementDerivation']} }) - is_a: Optional[str] = Field(None, json_schema_extra = { "linkml_meta": {'alias': 'is_a', 'domain_of': ['ElementDerivation'], 'slot_uri': 'linkml:is_a'} }) - mixins: Optional[List[str]] = Field(default_factory=list, json_schema_extra = { "linkml_meta": {'alias': 'mixins', - 'domain_of': ['ElementDerivation'], - 'slot_uri': 'linkml:mixins'} }) - value_mappings: Optional[Dict[str, KeyVal]] = Field(default_factory=dict, description="""A mapping table that is applied directly to mappings, in order of precedence""", json_schema_extra = { "linkml_meta": {'alias': 'value_mappings', 'domain_of': ['ElementDerivation']} }) - expression_to_value_mappings: Optional[Dict[str, KeyVal]] = Field(default_factory=dict, description="""A mapping table in which the keys are expressions""", json_schema_extra = { "linkml_meta": {'alias': 'expression_to_value_mappings', 'domain_of': ['ElementDerivation']} }) - expression_to_expression_mappings: Optional[Dict[str, KeyVal]] = Field(default_factory=dict, description="""A mapping table in which the keys and values are expressions""", json_schema_extra = { "linkml_meta": {'alias': 'expression_to_expression_mappings', - 'domain_of': ['ElementDerivation']} }) - mirror_source: Optional[bool] = Field(None, json_schema_extra = { "linkml_meta": {'alias': 'mirror_source', 'domain_of': ['ElementDerivation']} }) - description: Optional[str] = Field(None, description="""description of the specification component""", json_schema_extra = { "linkml_meta": {'alias': 'description', - 'domain_of': ['SpecificationComponent'], - 'slot_uri': 'dcterms:description'} }) - implements: Optional[List[str]] = Field(default_factory=list, description="""A reference to a specification that this component implements.""", json_schema_extra = { "linkml_meta": {'alias': 'implements', 'domain_of': ['SpecificationComponent']} }) - comments: Optional[List[str]] = Field(default_factory=list, description="""A list of comments about this component. Comments are free text, and may be used to provide additional information about the component, including instructions for its use.""", json_schema_extra = { "linkml_meta": {'alias': 'comments', - 'domain_of': ['SpecificationComponent'], - 'slot_uri': 'rdfs:comment'} }) + linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta( + {"from_schema": "https://w3id.org/linkml/transformer"} + ) + + name: str = Field( + ..., + description="""Name of the element in the target schema""", + json_schema_extra={ + "linkml_meta": { + "alias": "name", + "domain_of": [ + "ElementDerivation", + "SlotDerivation", + "EnumDerivation", + "PermissibleValueDerivation", + ], + } + }, + ) + copy_directives: Optional[Dict[str, CopyDirective]] = Field( + default_factory=dict, + json_schema_extra={ + "linkml_meta": {"alias": "copy_directives", "domain_of": ["ElementDerivation"]} + }, + ) + overrides: Optional[Any] = Field( + None, + description="""overrides source schema slots""", + json_schema_extra={ + "linkml_meta": {"alias": "overrides", "domain_of": ["ElementDerivation"]} + }, + ) + is_a: Optional[str] = Field( + None, + json_schema_extra={ + "linkml_meta": { + "alias": "is_a", + "domain_of": ["ElementDerivation"], + "slot_uri": "linkml:is_a", + } + }, + ) + mixins: Optional[List[str]] = Field( + default_factory=list, + json_schema_extra={ + "linkml_meta": { + "alias": "mixins", + "domain_of": ["ElementDerivation"], + "slot_uri": "linkml:mixins", + } + }, + ) + value_mappings: Optional[Dict[str, KeyVal]] = Field( + default_factory=dict, + description="""A mapping table that is applied directly to mappings, in order of precedence""", + json_schema_extra={ + "linkml_meta": {"alias": "value_mappings", "domain_of": ["ElementDerivation"]} + }, + ) + expression_to_value_mappings: Optional[Dict[str, KeyVal]] = Field( + default_factory=dict, + description="""A mapping table in which the keys are expressions""", + json_schema_extra={ + "linkml_meta": { + "alias": "expression_to_value_mappings", + "domain_of": ["ElementDerivation"], + } + }, + ) + expression_to_expression_mappings: Optional[Dict[str, KeyVal]] = Field( + default_factory=dict, + description="""A mapping table in which the keys and values are expressions""", + json_schema_extra={ + "linkml_meta": { + "alias": "expression_to_expression_mappings", + "domain_of": ["ElementDerivation"], + } + }, + ) + mirror_source: Optional[bool] = Field( + None, + json_schema_extra={ + "linkml_meta": {"alias": "mirror_source", "domain_of": ["ElementDerivation"]} + }, + ) + description: Optional[str] = Field( + None, + description="""description of the specification component""", + json_schema_extra={ + "linkml_meta": { + "alias": "description", + "domain_of": ["SpecificationComponent"], + "slot_uri": "dcterms:description", + } + }, + ) + implements: Optional[List[str]] = Field( + default_factory=list, + description="""A reference to a specification that this component implements.""", + json_schema_extra={ + "linkml_meta": {"alias": "implements", "domain_of": ["SpecificationComponent"]} + }, + ) + comments: Optional[List[str]] = Field( + default_factory=list, + description="""A list of comments about this component. Comments are free text, and may be used to provide additional information about the component, including instructions for its use.""", + json_schema_extra={ + "linkml_meta": { + "alias": "comments", + "domain_of": ["SpecificationComponent"], + "slot_uri": "rdfs:comment", + } + }, + ) class UnitConversionConfiguration(ConfiguredBaseModel): - linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({'from_schema': 'https://w3id.org/linkml/transformer'}) - - target_unit: Optional[str] = Field(None, json_schema_extra = { "linkml_meta": {'alias': 'target_unit', 'domain_of': ['UnitConversionConfiguration']} }) - target_unit_scheme: Optional[str] = Field(None, json_schema_extra = { "linkml_meta": {'alias': 'target_unit_scheme', - 'domain_of': ['UnitConversionConfiguration'], - 'examples': [{'value': 'ucum'}]} }) - source_unit: Optional[str] = Field(None, json_schema_extra = { "linkml_meta": {'alias': 'source_unit', 'domain_of': ['UnitConversionConfiguration']} }) - source_unit_scheme: Optional[str] = Field(None, json_schema_extra = { "linkml_meta": {'alias': 'source_unit_scheme', - 'domain_of': ['UnitConversionConfiguration'], - 'examples': [{'value': 'ucum'}]} }) - source_unit_slot: Optional[str] = Field(None, json_schema_extra = { "linkml_meta": {'alias': 'source_unit_slot', 'domain_of': ['UnitConversionConfiguration']} }) - source_magnitude_slot: Optional[str] = Field(None, json_schema_extra = { "linkml_meta": {'alias': 'source_magnitude_slot', 'domain_of': ['UnitConversionConfiguration']} }) - target_unit_slot: Optional[str] = Field(None, json_schema_extra = { "linkml_meta": {'alias': 'target_unit_slot', 'domain_of': ['UnitConversionConfiguration']} }) - target_magnitude_slot: Optional[str] = Field(None, json_schema_extra = { "linkml_meta": {'alias': 'target_magnitude_slot', 'domain_of': ['UnitConversionConfiguration']} }) + linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta( + {"from_schema": "https://w3id.org/linkml/transformer"} + ) + + target_unit: Optional[str] = Field( + None, + json_schema_extra={ + "linkml_meta": {"alias": "target_unit", "domain_of": ["UnitConversionConfiguration"]} + }, + ) + target_unit_scheme: Optional[str] = Field( + None, + json_schema_extra={ + "linkml_meta": { + "alias": "target_unit_scheme", + "domain_of": ["UnitConversionConfiguration"], + "examples": [{"value": "ucum"}], + } + }, + ) + source_unit: Optional[str] = Field( + None, + json_schema_extra={ + "linkml_meta": {"alias": "source_unit", "domain_of": ["UnitConversionConfiguration"]} + }, + ) + source_unit_scheme: Optional[str] = Field( + None, + json_schema_extra={ + "linkml_meta": { + "alias": "source_unit_scheme", + "domain_of": ["UnitConversionConfiguration"], + "examples": [{"value": "ucum"}], + } + }, + ) + source_unit_slot: Optional[str] = Field( + None, + json_schema_extra={ + "linkml_meta": { + "alias": "source_unit_slot", + "domain_of": ["UnitConversionConfiguration"], + } + }, + ) + source_magnitude_slot: Optional[str] = Field( + None, + json_schema_extra={ + "linkml_meta": { + "alias": "source_magnitude_slot", + "domain_of": ["UnitConversionConfiguration"], + } + }, + ) + target_unit_slot: Optional[str] = Field( + None, + json_schema_extra={ + "linkml_meta": { + "alias": "target_unit_slot", + "domain_of": ["UnitConversionConfiguration"], + } + }, + ) + target_magnitude_slot: Optional[str] = Field( + None, + json_schema_extra={ + "linkml_meta": { + "alias": "target_magnitude_slot", + "domain_of": ["UnitConversionConfiguration"], + } + }, + ) class StringificationConfiguration(ConfiguredBaseModel): - linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({'from_schema': 'https://w3id.org/linkml/transformer'}) + linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta( + {"from_schema": "https://w3id.org/linkml/transformer"} + ) - delimiter: Optional[str] = Field(None, json_schema_extra = { "linkml_meta": {'alias': 'delimiter', - 'domain_of': ['StringificationConfiguration'], - 'examples': [{'value': ','}, {'value': '|'}, {'value': ';'}]} }) - reversed: Optional[bool] = Field(None, json_schema_extra = { "linkml_meta": {'alias': 'reversed', 'domain_of': ['StringificationConfiguration']} }) - over_slots: Optional[List[str]] = Field(default_factory=list, json_schema_extra = { "linkml_meta": {'alias': 'over_slots', 'domain_of': ['StringificationConfiguration']} }) - syntax: Optional[SerializationSyntaxType] = Field(None, json_schema_extra = { "linkml_meta": {'alias': 'syntax', - 'domain_of': ['StringificationConfiguration'], - 'examples': [{'value': 'json'}, {'value': 'yaml'}]} }) + delimiter: Optional[str] = Field( + None, + json_schema_extra={ + "linkml_meta": { + "alias": "delimiter", + "domain_of": ["StringificationConfiguration"], + "examples": [{"value": ","}, {"value": "|"}, {"value": ";"}], + } + }, + ) + reversed: Optional[bool] = Field( + None, + json_schema_extra={ + "linkml_meta": {"alias": "reversed", "domain_of": ["StringificationConfiguration"]} + }, + ) + over_slots: Optional[List[str]] = Field( + default_factory=list, + json_schema_extra={ + "linkml_meta": {"alias": "over_slots", "domain_of": ["StringificationConfiguration"]} + }, + ) + syntax: Optional[SerializationSyntaxType] = Field( + None, + json_schema_extra={ + "linkml_meta": { + "alias": "syntax", + "domain_of": ["StringificationConfiguration"], + "examples": [{"value": "json"}, {"value": "yaml"}], + } + }, + ) class Inverse(ConfiguredBaseModel): """ Used for back references in mapping to relational model """ - linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({'aliases': ['backref', 'back_references'], - 'from_schema': 'https://w3id.org/linkml/transformer'}) - slot_name: Optional[str] = Field(None, json_schema_extra = { "linkml_meta": {'alias': 'slot_name', 'domain_of': ['Inverse']} }) - class_name: Optional[str] = Field(None, json_schema_extra = { "linkml_meta": {'alias': 'class_name', 'domain_of': ['Inverse']} }) + linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta( + { + "aliases": ["backref", "back_references"], + "from_schema": "https://w3id.org/linkml/transformer", + } + ) + + slot_name: Optional[str] = Field( + None, json_schema_extra={"linkml_meta": {"alias": "slot_name", "domain_of": ["Inverse"]}} + ) + class_name: Optional[str] = Field( + None, json_schema_extra={"linkml_meta": {"alias": "class_name", "domain_of": ["Inverse"]}} + ) class TransformationOperation(ConfiguredBaseModel): - linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({'abstract': True, 'from_schema': 'https://w3id.org/linkml/transformer'}) + linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta( + {"abstract": True, "from_schema": "https://w3id.org/linkml/transformer"} + ) pass class AggregationOperation(TransformationOperation): - linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({'from_schema': 'https://w3id.org/linkml/transformer'}) + linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta( + {"from_schema": "https://w3id.org/linkml/transformer"} + ) - operator: AggregationType = Field(..., json_schema_extra = { "linkml_meta": {'alias': 'operator', 'domain_of': ['AggregationOperation']} }) - null_handling: Optional[InvalidValueHandlingStrategy] = Field(None, json_schema_extra = { "linkml_meta": {'alias': 'null_handling', - 'domain_of': ['AggregationOperation', 'GroupingOperation']} }) - invalid_value_handling: Optional[InvalidValueHandlingStrategy] = Field(None, json_schema_extra = { "linkml_meta": {'alias': 'invalid_value_handling', 'domain_of': ['AggregationOperation']} }) + operator: AggregationType = Field( + ..., + json_schema_extra={ + "linkml_meta": {"alias": "operator", "domain_of": ["AggregationOperation"]} + }, + ) + null_handling: Optional[InvalidValueHandlingStrategy] = Field( + None, + json_schema_extra={ + "linkml_meta": { + "alias": "null_handling", + "domain_of": ["AggregationOperation", "GroupingOperation"], + } + }, + ) + invalid_value_handling: Optional[InvalidValueHandlingStrategy] = Field( + None, + json_schema_extra={ + "linkml_meta": { + "alias": "invalid_value_handling", + "domain_of": ["AggregationOperation"], + } + }, + ) class GroupingOperation(TransformationOperation): - linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({'from_schema': 'https://w3id.org/linkml/transformer'}) + linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta( + {"from_schema": "https://w3id.org/linkml/transformer"} + ) - null_handling: Optional[InvalidValueHandlingStrategy] = Field(None, json_schema_extra = { "linkml_meta": {'alias': 'null_handling', - 'domain_of': ['AggregationOperation', 'GroupingOperation']} }) + null_handling: Optional[InvalidValueHandlingStrategy] = Field( + None, + json_schema_extra={ + "linkml_meta": { + "alias": "null_handling", + "domain_of": ["AggregationOperation", "GroupingOperation"], + } + }, + ) class PivotOperation(TransformationOperation): - linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({'aliases': ['melt/unmelt', 'reification/dereification'], - 'from_schema': 'https://w3id.org/linkml/transformer'}) - - direction: PivotDirectionType = Field(..., json_schema_extra = { "linkml_meta": {'alias': 'direction', 'domain_of': ['PivotOperation']} }) - variable_slot: Optional[str] = Field("variable", description="""Slot to use for the variable column in the melted/long representation. In EAV this is the name of the 'A' variable""", json_schema_extra = { "linkml_meta": {'alias': 'variable_slot', - 'aliases': ['var_name'], - 'domain_of': ['PivotOperation'], - 'ifabsent': 'string(variable)'} }) - value_slot: Optional[str] = Field("value", description="""Slot to use for the value column in the melted/long representation. In EAV this is the name of the 'V' variable""", json_schema_extra = { "linkml_meta": {'alias': 'value_slot', - 'aliases': ['value_name'], - 'domain_of': ['PivotOperation'], - 'ifabsent': 'string(value)'} }) - unmelt_to_class: Optional[str] = Field(None, description="""In an unmelt operation, attributes (which are values in the long/melted/EAV representation) must conform to valid attributes in this class""", json_schema_extra = { "linkml_meta": {'alias': 'unmelt_to_class', 'domain_of': ['PivotOperation']} }) - unmelt_to_slots: Optional[List[str]] = Field(default_factory=list, json_schema_extra = { "linkml_meta": {'alias': 'unmelt_to_slots', 'domain_of': ['PivotOperation']} }) + linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta( + { + "aliases": ["melt/unmelt", "reification/dereification"], + "from_schema": "https://w3id.org/linkml/transformer", + } + ) + + direction: PivotDirectionType = Field( + ..., + json_schema_extra={"linkml_meta": {"alias": "direction", "domain_of": ["PivotOperation"]}}, + ) + variable_slot: Optional[str] = Field( + "variable", + description="""Slot to use for the variable column in the melted/long representation. In EAV this is the name of the 'A' variable""", + json_schema_extra={ + "linkml_meta": { + "alias": "variable_slot", + "aliases": ["var_name"], + "domain_of": ["PivotOperation"], + "ifabsent": "string(variable)", + } + }, + ) + value_slot: Optional[str] = Field( + "value", + description="""Slot to use for the value column in the melted/long representation. In EAV this is the name of the 'V' variable""", + json_schema_extra={ + "linkml_meta": { + "alias": "value_slot", + "aliases": ["value_name"], + "domain_of": ["PivotOperation"], + "ifabsent": "string(value)", + } + }, + ) + unmelt_to_class: Optional[str] = Field( + None, + description="""In an unmelt operation, attributes (which are values in the long/melted/EAV representation) must conform to valid attributes in this class""", + json_schema_extra={ + "linkml_meta": {"alias": "unmelt_to_class", "domain_of": ["PivotOperation"]} + }, + ) + unmelt_to_slots: Optional[List[str]] = Field( + default_factory=list, + json_schema_extra={ + "linkml_meta": {"alias": "unmelt_to_slots", "domain_of": ["PivotOperation"]} + }, + ) class KeyVal(ConfiguredBaseModel): - linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({'from_schema': 'https://w3id.org/linkml/transformer'}) + linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta( + {"from_schema": "https://w3id.org/linkml/transformer"} + ) - key: str = Field(..., json_schema_extra = { "linkml_meta": {'alias': 'key', 'domain_of': ['KeyVal']} }) - value: Optional[Any] = Field(None, json_schema_extra = { "linkml_meta": {'alias': 'value', 'domain_of': ['KeyVal']} }) + key: str = Field( + ..., json_schema_extra={"linkml_meta": {"alias": "key", "domain_of": ["KeyVal"]}} + ) + value: Optional[Any] = Field( + None, json_schema_extra={"linkml_meta": {"alias": "value", "domain_of": ["KeyVal"]}} + ) class CopyDirective(ConfiguredBaseModel): """ Instructs a Schema Mapper in how to map to a target schema. Not used for data transformation. This is the process to process a directive: 1. If `copy_all`, add all sub-elements to the list of sub-elements to be copied. 2. If `exclude`, remove the specified sub-elements from the above list. 3. If `exclude_all`, clean-up the above list. Effectively making previous steps useless. 4. If `include`, add the specified sub-elements from the list result of previous steps. - Implementations might decide to somehow report (error, warning,...) meaningless combinations (like specifying `copy_all` and `exclude_all`). + Implementations might decide to somehow report (error, warning,...) meaningless combinations (like specifying `copy_all` and `exclude_all`). Validation on the correctness of the resulting derived schema might be done optionally by the implementation. For example, removing a slot but keeping a class that requires it would invalidate the derived-schema. It is always possible to validate the schema with the LinkML linter after derivation. What are the considered sub-elements depends on the calls of Element to be transformed. For example, for a class they are `slots` and `attributes`. """ - linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({'from_schema': 'https://w3id.org/linkml/transformer', 'status': 'testing'}) - element_name: str = Field(..., json_schema_extra = { "linkml_meta": {'alias': 'element_name', 'domain_of': ['CopyDirective']} }) - copy_all: Optional[bool] = Field(None, description="""Copy all sub-elements of the Element being derived.""", json_schema_extra = { "linkml_meta": {'alias': 'copy_all', 'domain_of': ['CopyDirective']} }) - exclude_all: Optional[bool] = Field(None, description="""Do not copy any of the sub-elements of the Element being derived.""", json_schema_extra = { "linkml_meta": {'alias': 'exclude_all', 'domain_of': ['CopyDirective']} }) - exclude: Optional[Any] = Field(None, description="""Remove certain sub-elements from the list of sub-elements to be copied. -As of now there it is under-specified, how to specify the sub-elements to exclude. One possible implementation would be a list where all element types can be mixed, since there might not be name conflicts across element types.""", json_schema_extra = { "linkml_meta": {'alias': 'exclude', 'domain_of': ['CopyDirective']} }) - include: Optional[Any] = Field(None, description="""Add certain sub-elements to the list of sub-elements to be copied. -As of now there it is under-specified, how to specify the sub-elements to include. One possible implementation would be a list where all element types can be mixed, since there might not be name conflicts across element types.""", json_schema_extra = { "linkml_meta": {'alias': 'include', 'domain_of': ['CopyDirective']} }) - add: Optional[Any] = Field(None, json_schema_extra = { "linkml_meta": {'alias': 'add', 'domain_of': ['CopyDirective']} }) + linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta( + {"from_schema": "https://w3id.org/linkml/transformer", "status": "testing"} + ) + + element_name: str = Field( + ..., + json_schema_extra={ + "linkml_meta": {"alias": "element_name", "domain_of": ["CopyDirective"]} + }, + ) + copy_all: Optional[bool] = Field( + None, + description="""Copy all sub-elements of the Element being derived.""", + json_schema_extra={"linkml_meta": {"alias": "copy_all", "domain_of": ["CopyDirective"]}}, + ) + exclude_all: Optional[bool] = Field( + None, + description="""Do not copy any of the sub-elements of the Element being derived.""", + json_schema_extra={"linkml_meta": {"alias": "exclude_all", "domain_of": ["CopyDirective"]}}, + ) + exclude: Optional[Any] = Field( + None, + description="""Remove certain sub-elements from the list of sub-elements to be copied. +As of now there it is under-specified, how to specify the sub-elements to exclude. One possible implementation would be a list where all element types can be mixed, since there might not be name conflicts across element types.""", + json_schema_extra={"linkml_meta": {"alias": "exclude", "domain_of": ["CopyDirective"]}}, + ) + include: Optional[Any] = Field( + None, + description="""Add certain sub-elements to the list of sub-elements to be copied. +As of now there it is under-specified, how to specify the sub-elements to include. One possible implementation would be a list where all element types can be mixed, since there might not be name conflicts across element types.""", + json_schema_extra={"linkml_meta": {"alias": "include", "domain_of": ["CopyDirective"]}}, + ) + add: Optional[Any] = Field( + None, json_schema_extra={"linkml_meta": {"alias": "add", "domain_of": ["CopyDirective"]}} + ) # Model rebuild @@ -576,4 +1616,3 @@ class CopyDirective(ConfiguredBaseModel): PivotOperation.model_rebuild() KeyVal.model_rebuild() CopyDirective.model_rebuild() - diff --git a/src/linkml_map/inference/schema_mapper.py b/src/linkml_map/inference/schema_mapper.py index a6fc56e..966baab 100644 --- a/src/linkml_map/inference/schema_mapper.py +++ b/src/linkml_map/inference/schema_mapper.py @@ -120,7 +120,9 @@ def _derive_class(self, class_derivation: ClassDerivation) -> ClassDefinition: if class_derivation.mixins: target_class.mixins = class_derivation.mixins if class_derivation.target_definition: - spec_defn = ClassDefinition(**{"name": target_class.name}, **class_derivation.target_definition) + spec_defn = ClassDefinition( + **{"name": target_class.name}, **class_derivation.target_definition + ) for k, v in vars(spec_defn).items(): curr_v = getattr(target_class, k, None) if curr_v is None or curr_v == [] or curr_v == {}: @@ -189,7 +191,9 @@ def _derive_slot(self, slot_derivation) -> SlotDefinition: if slot_derivation.range: target_slot.range = slot_derivation.range if slot_derivation.target_definition: - spec_defn = SlotDefinition(**{"name": target_slot.name}, **slot_derivation.target_definition) + spec_defn = SlotDefinition( + **{"name": target_slot.name}, **slot_derivation.target_definition + ) for k, v in vars(spec_defn).items(): setattr(target_slot, k, v) if slot_derivation.unit_conversion: diff --git a/tests/input/examples/flattening/model/denormalized_model.py b/tests/input/examples/flattening/model/denormalized_model.py index d3bc417..104294a 100644 --- a/tests/input/examples/flattening/model/denormalized_model.py +++ b/tests/input/examples/flattening/model/denormalized_model.py @@ -17,9 +17,7 @@ ) from linkml_runtime.utils.metamodelcore import empty_list from linkml_runtime.utils.slot import Slot -from linkml_runtime.utils.yamlutils import ( - YAMLRoot, -) +from linkml_runtime.utils.yamlutils import YAMLRoot from rdflib import URIRef metamodel_version = "1.7.0" diff --git a/tests/input/examples/flattening/model/normalized_model.py b/tests/input/examples/flattening/model/normalized_model.py index ba90e2b..efd3896 100644 --- a/tests/input/examples/flattening/model/normalized_model.py +++ b/tests/input/examples/flattening/model/normalized_model.py @@ -17,10 +17,7 @@ ) from linkml_runtime.utils.metamodelcore import empty_dict, empty_list from linkml_runtime.utils.slot import Slot -from linkml_runtime.utils.yamlutils import ( - YAMLRoot, - extended_str, -) +from linkml_runtime.utils.yamlutils import YAMLRoot, extended_str from rdflib import URIRef metamodel_version = "1.7.0" diff --git a/tests/input/examples/personinfo_basic/model/agent_model.py b/tests/input/examples/personinfo_basic/model/agent_model.py index b688b0c..2575d33 100644 --- a/tests/input/examples/personinfo_basic/model/agent_model.py +++ b/tests/input/examples/personinfo_basic/model/agent_model.py @@ -12,26 +12,15 @@ from typing import Any, ClassVar, Dict, List, Optional, Union from jsonasobj2 import as_dict -from linkml_runtime.linkml_model.meta import ( - EnumDefinition, - PermissibleValue, -) +from linkml_runtime.linkml_model.meta import EnumDefinition, PermissibleValue from linkml_runtime.utils.curienamespace import CurieNamespace from linkml_runtime.utils.dataclass_extensions_376 import ( dataclasses_init_fn_with_kwargs, ) from linkml_runtime.utils.enumerations import EnumDefinitionImpl -from linkml_runtime.utils.metamodelcore import ( - Bool, - XSDDate, - empty_dict, - empty_list, -) +from linkml_runtime.utils.metamodelcore import Bool, XSDDate, empty_dict, empty_list from linkml_runtime.utils.slot import Slot -from linkml_runtime.utils.yamlutils import ( - YAMLRoot, - extended_str, -) +from linkml_runtime.utils.yamlutils import YAMLRoot, extended_str from rdflib import URIRef metamodel_version = "1.7.0" diff --git a/tests/input/examples/personinfo_basic/model/personinfo_model.py b/tests/input/examples/personinfo_basic/model/personinfo_model.py index d22fdb1..fd09c3a 100644 --- a/tests/input/examples/personinfo_basic/model/personinfo_model.py +++ b/tests/input/examples/personinfo_basic/model/personinfo_model.py @@ -12,26 +12,15 @@ from typing import Any, ClassVar, Dict, List, Optional, Union from jsonasobj2 import as_dict -from linkml_runtime.linkml_model.meta import ( - EnumDefinition, - PermissibleValue, -) +from linkml_runtime.linkml_model.meta import EnumDefinition, PermissibleValue from linkml_runtime.utils.curienamespace import CurieNamespace from linkml_runtime.utils.dataclass_extensions_376 import ( dataclasses_init_fn_with_kwargs, ) from linkml_runtime.utils.enumerations import EnumDefinitionImpl -from linkml_runtime.utils.metamodelcore import ( - Bool, - XSDDate, - empty_dict, - empty_list, -) +from linkml_runtime.utils.metamodelcore import Bool, XSDDate, empty_dict, empty_list from linkml_runtime.utils.slot import Slot -from linkml_runtime.utils.yamlutils import ( - YAMLRoot, - extended_str, -) +from linkml_runtime.utils.yamlutils import YAMLRoot, extended_str from rdflib import URIRef metamodel_version = "1.7.0" diff --git a/tests/test_schema_mapper/test_schema_mapper.py b/tests/test_schema_mapper/test_schema_mapper.py index 984c470..e0c7ef9 100644 --- a/tests/test_schema_mapper/test_schema_mapper.py +++ b/tests/test_schema_mapper/test_schema_mapper.py @@ -6,7 +6,8 @@ from linkml_map.datamodel.transformer_model import ( ClassDerivation, - TransformationSpecification, SlotDerivation, + SlotDerivation, + TransformationSpecification, ) from linkml_map.inference.schema_mapper import SchemaMapper from linkml_map.transformer.object_transformer import ObjectTransformer @@ -94,29 +95,22 @@ def test_definition_in_derivation(self): "Thing": ClassDerivation( name="Thing", slot_derivations={ - "id": SlotDerivation(name="id", - target_definition={ - "identifier": "true", - "range": "uriorcurie" - }, - ), + "id": SlotDerivation( + name="id", + target_definition={"identifier": "true", "range": "uriorcurie"}, + ), }, ), "Agent": ClassDerivation( name="Agent", slot_derivations={ - "age": SlotDerivation(name="role", - target_definition={ - "range": "integer" - } - ), + "age": SlotDerivation(name="role", target_definition={"range": "integer"}), }, target_definition={ "description": "A person or organization.", "is_a": "Thing", - } - ) - + }, + ), }, ) target_schema = tr.derive_schema(specification) @@ -194,7 +188,5 @@ def test_rewire(self): # self.assertEqual("Person", emp.is_a) - - if __name__ == "__main__": unittest.main() From 6a9c68343d4f5709c046d28eae60ed0b435fe0ba Mon Sep 17 00:00:00 2001 From: Chris Mungall Date: Fri, 23 Aug 2024 19:11:11 -0700 Subject: [PATCH 3/3] format --- tests/test_schema_mapper/test_schema_mapper.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/tests/test_schema_mapper/test_schema_mapper.py b/tests/test_schema_mapper/test_schema_mapper.py index e0c7ef9..000314d 100644 --- a/tests/test_schema_mapper/test_schema_mapper.py +++ b/tests/test_schema_mapper/test_schema_mapper.py @@ -12,7 +12,6 @@ from linkml_map.inference.schema_mapper import SchemaMapper from linkml_map.transformer.object_transformer import ObjectTransformer from tests import SCHEMA1, SPECIFICATION -from tests.input.examples.personinfo_basic.model.personinfo_model import slots class SchemaMapperTestCase(unittest.TestCase): @@ -50,13 +49,13 @@ def test_derive_schema(self): ), ("FamilialRelationship", ["related_to", "type"]), ] - for cn, slots in cases: + for cn, ex_slots in cases: self.assertIn(cn, target_schema.classes) c = target_schema.classes[cn] atts = c.attributes - for s in slots: + for s in ex_slots: self.assertIn(s, atts) - # self.assertCountEqual(slots, list(atts)) + # self.assertCountEqual(ex_slots, list(atts)) agent = target_schema.classes["Agent"] self.assertEqual(agent.is_a, "Entity")