Skip to content

Commit f2ccaa2

Browse files
committed
Regenerate schema files
1 parent 7a8a88b commit f2ccaa2

2 files changed

Lines changed: 176 additions & 52 deletions

File tree

src/fair_mappings_schema/datamodel/fair_mappings_schema.py

Lines changed: 112 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Auto generated from fair_mappings_schema.yaml by pythongen.py version: 0.0.1
2-
# Generation date: 2025-10-06T00:35:53
2+
# Generation date: 2025-10-06T23:07:21
33
# Schema: fair-mappings-schema
44
#
55
# id: https://w3id.org/mapping-commons/fair-mappings-schema
@@ -91,8 +91,7 @@ class Agent(YAMLRoot):
9191

9292
id: Optional[str] = None
9393
name: Optional[str] = None
94-
version: Optional[str] = None
95-
type: Optional[Union[str, "AgentTypeEnum"]] = None
94+
type: Optional[str] = None
9695

9796
def __post_init__(self, *_: str, **kwargs: Any):
9897
if self.id is not None and not isinstance(self.id, str):
@@ -101,13 +100,105 @@ def __post_init__(self, *_: str, **kwargs: Any):
101100
if self.name is not None and not isinstance(self.name, str):
102101
self.name = str(self.name)
103102

103+
self.type = str(self.class_name)
104+
105+
super().__post_init__(**kwargs)
106+
self.type = str(self.class_name)
107+
108+
109+
def __new__(cls, *args, **kwargs):
110+
111+
type_designator = "type"
112+
if not type_designator in kwargs:
113+
return super().__new__(cls,*args,**kwargs)
114+
else:
115+
type_designator_value = kwargs[type_designator]
116+
target_cls = cls._class_for("class_name", type_designator_value)
117+
118+
119+
if target_cls is None:
120+
raise ValueError(f"Wrong type designator value: class {cls.__name__} "
121+
f"has no subclass with ['class_name']='{kwargs[type_designator]}'")
122+
return super().__new__(target_cls,*args,**kwargs)
123+
124+
125+
126+
@dataclass(repr=False)
127+
class Person(Agent):
128+
"""
129+
An individual person who contributes to a mapping specification
130+
"""
131+
_inherited_slots: ClassVar[list[str]] = []
132+
133+
class_class_uri: ClassVar[URIRef] = FAIR_MAPPINGS_SCHEMA["Person"]
134+
class_class_curie: ClassVar[str] = "fair_mappings_schema:Person"
135+
class_name: ClassVar[str] = "Person"
136+
class_model_uri: ClassVar[URIRef] = FAIR_MAPPINGS_SCHEMA.Person
137+
138+
orcid: Optional[str] = None
139+
affiliation: Optional[str] = None
140+
141+
def __post_init__(self, *_: str, **kwargs: Any):
142+
if self.orcid is not None and not isinstance(self.orcid, str):
143+
self.orcid = str(self.orcid)
144+
145+
if self.affiliation is not None and not isinstance(self.affiliation, str):
146+
self.affiliation = str(self.affiliation)
147+
148+
super().__post_init__(**kwargs)
149+
self.type = str(self.class_name)
150+
151+
152+
@dataclass(repr=False)
153+
class Organization(Agent):
154+
"""
155+
An organization or institution that contributes to a mapping specification
156+
"""
157+
_inherited_slots: ClassVar[list[str]] = []
158+
159+
class_class_uri: ClassVar[URIRef] = FAIR_MAPPINGS_SCHEMA["Organization"]
160+
class_class_curie: ClassVar[str] = "fair_mappings_schema:Organization"
161+
class_name: ClassVar[str] = "Organization"
162+
class_model_uri: ClassVar[URIRef] = FAIR_MAPPINGS_SCHEMA.Organization
163+
164+
ror_id: Optional[str] = None
165+
url: Optional[str] = None
166+
167+
def __post_init__(self, *_: str, **kwargs: Any):
168+
if self.ror_id is not None and not isinstance(self.ror_id, str):
169+
self.ror_id = str(self.ror_id)
170+
171+
if self.url is not None and not isinstance(self.url, str):
172+
self.url = str(self.url)
173+
174+
super().__post_init__(**kwargs)
175+
self.type = str(self.class_name)
176+
177+
178+
@dataclass(repr=False)
179+
class Software(Agent):
180+
"""
181+
A software tool or system used in creating mappings
182+
"""
183+
_inherited_slots: ClassVar[list[str]] = []
184+
185+
class_class_uri: ClassVar[URIRef] = FAIR_MAPPINGS_SCHEMA["Software"]
186+
class_class_curie: ClassVar[str] = "fair_mappings_schema:Software"
187+
class_name: ClassVar[str] = "Software"
188+
class_model_uri: ClassVar[URIRef] = FAIR_MAPPINGS_SCHEMA.Software
189+
190+
version: Optional[str] = None
191+
repository_url: Optional[str] = None
192+
193+
def __post_init__(self, *_: str, **kwargs: Any):
104194
if self.version is not None and not isinstance(self.version, str):
105195
self.version = str(self.version)
106196

107-
if self.type is not None and not isinstance(self.type, AgentTypeEnum):
108-
self.type = AgentTypeEnum(self.type)
197+
if self.repository_url is not None and not isinstance(self.repository_url, str):
198+
self.repository_url = str(self.repository_url)
109199

110200
super().__post_init__(**kwargs)
201+
self.type = str(self.class_name)
111202

112203

113204
@dataclass(repr=False)
@@ -234,25 +325,6 @@ def __post_init__(self, *_: str, **kwargs: Any):
234325

235326

236327
# Enumerations
237-
class AgentTypeEnum(EnumDefinitionImpl):
238-
"""
239-
Types of agents that can contribute to a mapping specification
240-
"""
241-
person = PermissibleValue(
242-
text="person",
243-
description="An individual person")
244-
organization = PermissibleValue(
245-
text="organization",
246-
description="An organization or institution")
247-
software = PermissibleValue(
248-
text="software",
249-
description="A software tool or system")
250-
251-
_defn = EnumDefinition(
252-
name="AgentTypeEnum",
253-
description="Types of agents that can contribute to a mapping specification",
254-
)
255-
256328
class SourceTypeEnum(EnumDefinitionImpl):
257329
"""
258330
Types of data sources
@@ -364,8 +436,23 @@ class slots:
364436
slots.object_source = Slot(uri=FAIR_MAPPINGS_SCHEMA.object_source, name="object_source", curie=FAIR_MAPPINGS_SCHEMA.curie('object_source'),
365437
model_uri=FAIR_MAPPINGS_SCHEMA.object_source, domain=None, range=Optional[Union[dict, Source]])
366438

439+
slots.orcid = Slot(uri=FAIR_MAPPINGS_SCHEMA.orcid, name="orcid", curie=FAIR_MAPPINGS_SCHEMA.curie('orcid'),
440+
model_uri=FAIR_MAPPINGS_SCHEMA.orcid, domain=None, range=Optional[str])
441+
442+
slots.affiliation = Slot(uri=FAIR_MAPPINGS_SCHEMA.affiliation, name="affiliation", curie=FAIR_MAPPINGS_SCHEMA.curie('affiliation'),
443+
model_uri=FAIR_MAPPINGS_SCHEMA.affiliation, domain=None, range=Optional[str])
444+
445+
slots.ror_id = Slot(uri=FAIR_MAPPINGS_SCHEMA.ror_id, name="ror_id", curie=FAIR_MAPPINGS_SCHEMA.curie('ror_id'),
446+
model_uri=FAIR_MAPPINGS_SCHEMA.ror_id, domain=None, range=Optional[str])
447+
448+
slots.url = Slot(uri=FAIR_MAPPINGS_SCHEMA.url, name="url", curie=FAIR_MAPPINGS_SCHEMA.curie('url'),
449+
model_uri=FAIR_MAPPINGS_SCHEMA.url, domain=None, range=Optional[str])
450+
451+
slots.repository_url = Slot(uri=FAIR_MAPPINGS_SCHEMA.repository_url, name="repository_url", curie=FAIR_MAPPINGS_SCHEMA.curie('repository_url'),
452+
model_uri=FAIR_MAPPINGS_SCHEMA.repository_url, domain=None, range=Optional[str])
453+
367454
slots.Agent_type = Slot(uri=FAIR_MAPPINGS_SCHEMA.type, name="Agent_type", curie=FAIR_MAPPINGS_SCHEMA.curie('type'),
368-
model_uri=FAIR_MAPPINGS_SCHEMA.Agent_type, domain=Agent, range=Optional[Union[str, "AgentTypeEnum"]])
455+
model_uri=FAIR_MAPPINGS_SCHEMA.Agent_type, domain=Agent, range=Optional[str])
369456

370457
slots.Source_type = Slot(uri=FAIR_MAPPINGS_SCHEMA.type, name="Source_type", curie=FAIR_MAPPINGS_SCHEMA.curie('type'),
371458
model_uri=FAIR_MAPPINGS_SCHEMA.Source_type, domain=Source, range=Optional[Union[str, "SourceTypeEnum"]])

src/fair_mappings_schema/datamodel/fair_mappings_schema_pydantic.py

Lines changed: 64 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -84,24 +84,6 @@ def __contains__(self, key:str) -> bool:
8484
'source_file': 'src/fair_mappings_schema/schema/fair_mappings_schema.yaml',
8585
'title': 'fair-mappings-schema'} )
8686

87-
class AgentTypeEnum(str, Enum):
88-
"""
89-
Types of agents that can contribute to a mapping specification
90-
"""
91-
person = "person"
92-
"""
93-
An individual person
94-
"""
95-
organization = "organization"
96-
"""
97-
An organization or institution
98-
"""
99-
software = "software"
100-
"""
101-
A software tool or system
102-
"""
103-
104-
10587
class SourceTypeEnum(str, Enum):
10688
"""
10789
Types of data sources
@@ -167,13 +149,63 @@ class Agent(ConfiguredBaseModel):
167149
"""
168150
An entity that can create or contribute to a digital object, such as an author or creator.
169151
"""
170-
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({'from_schema': 'https://w3id.org/mapping-commons/fair-mappings-schema',
171-
'slot_usage': {'type': {'name': 'type', 'range': 'AgentTypeEnum'}}})
152+
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({'abstract': True,
153+
'from_schema': 'https://w3id.org/mapping-commons/fair-mappings-schema',
154+
'slot_usage': {'type': {'designates_type': True,
155+
'name': 'type',
156+
'range': 'string'}}})
157+
158+
id: Optional[str] = Field(default=None, description="""Identifier for the information entity""", json_schema_extra = { "linkml_meta": {'alias': 'id', 'domain_of': ['Agent', 'Source', 'MappingSpecification']} })
159+
name: Optional[str] = Field(default=None, description="""Name of the information entity""", json_schema_extra = { "linkml_meta": {'alias': 'name', 'domain_of': ['Agent', 'Source', 'MappingSpecification']} })
160+
type: Literal["Agent"] = Field(default="Agent", description="""Type of the information entity""", json_schema_extra = { "linkml_meta": {'alias': 'type',
161+
'designates_type': True,
162+
'domain_of': ['Agent', 'Source', 'MappingSpecification']} })
163+
164+
165+
class Person(Agent):
166+
"""
167+
An individual person who contributes to a mapping specification
168+
"""
169+
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({'from_schema': 'https://w3id.org/mapping-commons/fair-mappings-schema'})
170+
171+
orcid: Optional[str] = Field(default=None, description="""ORCID identifier for a person""", json_schema_extra = { "linkml_meta": {'alias': 'orcid', 'domain_of': ['Person']} })
172+
affiliation: Optional[str] = Field(default=None, description="""Institutional affiliation of a person""", json_schema_extra = { "linkml_meta": {'alias': 'affiliation', 'domain_of': ['Person']} })
173+
id: Optional[str] = Field(default=None, description="""Identifier for the information entity""", json_schema_extra = { "linkml_meta": {'alias': 'id', 'domain_of': ['Agent', 'Source', 'MappingSpecification']} })
174+
name: Optional[str] = Field(default=None, description="""Name of the information entity""", json_schema_extra = { "linkml_meta": {'alias': 'name', 'domain_of': ['Agent', 'Source', 'MappingSpecification']} })
175+
type: Literal["Person"] = Field(default="Person", description="""Type of the information entity""", json_schema_extra = { "linkml_meta": {'alias': 'type',
176+
'designates_type': True,
177+
'domain_of': ['Agent', 'Source', 'MappingSpecification']} })
178+
179+
180+
class Organization(Agent):
181+
"""
182+
An organization or institution that contributes to a mapping specification
183+
"""
184+
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({'from_schema': 'https://w3id.org/mapping-commons/fair-mappings-schema'})
185+
186+
ror_id: Optional[str] = Field(default=None, description="""ROR (Research Organization Registry) identifier""", json_schema_extra = { "linkml_meta": {'alias': 'ror_id', 'domain_of': ['Organization']} })
187+
url: Optional[str] = Field(default=None, description="""URL or web address""", json_schema_extra = { "linkml_meta": {'alias': 'url', 'domain_of': ['Organization']} })
188+
id: Optional[str] = Field(default=None, description="""Identifier for the information entity""", json_schema_extra = { "linkml_meta": {'alias': 'id', 'domain_of': ['Agent', 'Source', 'MappingSpecification']} })
189+
name: Optional[str] = Field(default=None, description="""Name of the information entity""", json_schema_extra = { "linkml_meta": {'alias': 'name', 'domain_of': ['Agent', 'Source', 'MappingSpecification']} })
190+
type: Literal["Organization"] = Field(default="Organization", description="""Type of the information entity""", json_schema_extra = { "linkml_meta": {'alias': 'type',
191+
'designates_type': True,
192+
'domain_of': ['Agent', 'Source', 'MappingSpecification']} })
193+
194+
195+
class Software(Agent):
196+
"""
197+
A software tool or system used in creating mappings
198+
"""
199+
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({'from_schema': 'https://w3id.org/mapping-commons/fair-mappings-schema'})
172200

201+
version: Optional[str] = Field(default=None, description="""Version of the digital object""", json_schema_extra = { "linkml_meta": {'alias': 'version',
202+
'domain_of': ['Software', 'Source', 'MappingSpecification']} })
203+
repository_url: Optional[str] = Field(default=None, description="""URL to a code repository""", json_schema_extra = { "linkml_meta": {'alias': 'repository_url', 'domain_of': ['Software']} })
173204
id: Optional[str] = Field(default=None, description="""Identifier for the information entity""", json_schema_extra = { "linkml_meta": {'alias': 'id', 'domain_of': ['Agent', 'Source', 'MappingSpecification']} })
174205
name: Optional[str] = Field(default=None, description="""Name of the information entity""", json_schema_extra = { "linkml_meta": {'alias': 'name', 'domain_of': ['Agent', 'Source', 'MappingSpecification']} })
175-
version: Optional[str] = Field(default=None, description="""Version of the digital object""", json_schema_extra = { "linkml_meta": {'alias': 'version', 'domain_of': ['Agent', 'Source', 'MappingSpecification']} })
176-
type: Optional[AgentTypeEnum] = Field(default=None, description="""Type of the information entity""", json_schema_extra = { "linkml_meta": {'alias': 'type', 'domain_of': ['Agent', 'Source', 'MappingSpecification']} })
206+
type: Literal["Software"] = Field(default="Software", description="""Type of the information entity""", json_schema_extra = { "linkml_meta": {'alias': 'type',
207+
'designates_type': True,
208+
'domain_of': ['Agent', 'Source', 'MappingSpecification']} })
177209

178210

179211
class Source(ConfiguredBaseModel):
@@ -185,7 +217,8 @@ class Source(ConfiguredBaseModel):
185217

186218
id: Optional[str] = Field(default=None, description="""Identifier for the information entity""", json_schema_extra = { "linkml_meta": {'alias': 'id', 'domain_of': ['Agent', 'Source', 'MappingSpecification']} })
187219
name: Optional[str] = Field(default=None, description="""Name of the information entity""", json_schema_extra = { "linkml_meta": {'alias': 'name', 'domain_of': ['Agent', 'Source', 'MappingSpecification']} })
188-
version: Optional[str] = Field(default=None, description="""Version of the digital object""", json_schema_extra = { "linkml_meta": {'alias': 'version', 'domain_of': ['Agent', 'Source', 'MappingSpecification']} })
220+
version: Optional[str] = Field(default=None, description="""Version of the digital object""", json_schema_extra = { "linkml_meta": {'alias': 'version',
221+
'domain_of': ['Software', 'Source', 'MappingSpecification']} })
189222
type: Optional[SourceTypeEnum] = Field(default=None, description="""Type of the information entity""", json_schema_extra = { "linkml_meta": {'alias': 'type', 'domain_of': ['Agent', 'Source', 'MappingSpecification']} })
190223
documentation: Optional[str] = Field(default=None, description="""URL or reference to documentation for the mapping specification""", json_schema_extra = { "linkml_meta": {'alias': 'documentation', 'domain_of': ['Source', 'MappingSpecification']} })
191224
content: Optional[str] = Field(default=None, description="""Reference to the actual content of the digital object""", json_schema_extra = { "linkml_meta": {'alias': 'content', 'domain_of': ['Source', 'MappingSpecification']} })
@@ -204,12 +237,13 @@ class MappingSpecification(ConfiguredBaseModel):
204237
id: Optional[str] = Field(default=None, description="""Identifier for the information entity""", json_schema_extra = { "linkml_meta": {'alias': 'id', 'domain_of': ['Agent', 'Source', 'MappingSpecification']} })
205238
name: Optional[str] = Field(default=None, description="""Name of the information entity""", json_schema_extra = { "linkml_meta": {'alias': 'name', 'domain_of': ['Agent', 'Source', 'MappingSpecification']} })
206239
description: Optional[str] = Field(default=None, description="""A brief description of the mapping specification""", json_schema_extra = { "linkml_meta": {'alias': 'description', 'domain_of': ['MappingSpecification']} })
207-
author: Optional[Agent] = Field(default=None, description="""Author of the mapping specification""", json_schema_extra = { "linkml_meta": {'alias': 'author', 'domain_of': ['MappingSpecification']} })
208-
creator: Optional[Agent] = Field(default=None, description="""Creator of the mapping specification""", json_schema_extra = { "linkml_meta": {'alias': 'creator', 'domain_of': ['MappingSpecification']} })
209-
reviewer: Optional[Agent] = Field(default=None, description="""Reviewer of the mapping specification""", json_schema_extra = { "linkml_meta": {'alias': 'reviewer', 'domain_of': ['MappingSpecification']} })
240+
author: Optional[Union[Agent,Person,Organization,Software]] = Field(default=None, description="""Author of the mapping specification""", json_schema_extra = { "linkml_meta": {'alias': 'author', 'domain_of': ['MappingSpecification']} })
241+
creator: Optional[Union[Agent,Person,Organization,Software]] = Field(default=None, description="""Creator of the mapping specification""", json_schema_extra = { "linkml_meta": {'alias': 'creator', 'domain_of': ['MappingSpecification']} })
242+
reviewer: Optional[Union[Agent,Person,Organization,Software]] = Field(default=None, description="""Reviewer of the mapping specification""", json_schema_extra = { "linkml_meta": {'alias': 'reviewer', 'domain_of': ['MappingSpecification']} })
210243
publication_date: Optional[str] = Field(default=None, description="""Date of publication of the mapping specification""", json_schema_extra = { "linkml_meta": {'alias': 'publication_date', 'domain_of': ['MappingSpecification']} })
211244
license: Optional[str] = Field(default=None, description="""License under which the mapping specification is released""", json_schema_extra = { "linkml_meta": {'alias': 'license', 'domain_of': ['MappingSpecification']} })
212-
version: Optional[str] = Field(default=None, description="""Version of the digital object""", json_schema_extra = { "linkml_meta": {'alias': 'version', 'domain_of': ['Agent', 'Source', 'MappingSpecification']} })
245+
version: Optional[str] = Field(default=None, description="""Version of the digital object""", json_schema_extra = { "linkml_meta": {'alias': 'version',
246+
'domain_of': ['Software', 'Source', 'MappingSpecification']} })
213247
type: Optional[MappingSpecificationTypeEnum] = Field(default=None, description="""Type of the information entity""", json_schema_extra = { "linkml_meta": {'alias': 'type', 'domain_of': ['Agent', 'Source', 'MappingSpecification']} })
214248
mapping_method: Optional[str] = Field(default=None, description="""Method used to create the mapping specification""", json_schema_extra = { "linkml_meta": {'alias': 'mapping_method', 'domain_of': ['MappingSpecification']} })
215249
documentation: Optional[str] = Field(default=None, description="""URL or reference to documentation for the mapping specification""", json_schema_extra = { "linkml_meta": {'alias': 'documentation', 'domain_of': ['Source', 'MappingSpecification']} })
@@ -221,6 +255,9 @@ class MappingSpecification(ConfiguredBaseModel):
221255
# Model rebuild
222256
# see https://pydantic-docs.helpmanual.io/usage/models/#rebuilding-a-model
223257
Agent.model_rebuild()
258+
Person.model_rebuild()
259+
Organization.model_rebuild()
260+
Software.model_rebuild()
224261
Source.model_rebuild()
225262
MappingSpecification.model_rebuild()
226263

0 commit comments

Comments
 (0)