|
4 | 4 | import uuid
|
5 | 5 | from enum import Enum
|
6 | 6 | from functools import cached_property, lru_cache
|
7 |
| -from typing import Any, Dict, List, Literal, Set, TextIO, Union |
| 7 | +from typing import Any, Dict, List, Literal, Optional, Set, TextIO, Tuple, Union |
8 | 8 |
|
9 | 9 | import importlib_resources
|
10 | 10 | import yaml
|
11 | 11 | from linkml_runtime.utils.schema_as_dict import schema_as_dict
|
12 | 12 | from linkml_runtime.utils.schemaview import SchemaView
|
13 |
| -from sssom_schema.datamodel.sssom_schema import SssomVersionEnum |
14 | 13 |
|
15 | 14 | HERE = pathlib.Path(__file__).parent.resolve()
|
16 | 15 |
|
@@ -284,24 +283,30 @@ def propagatable_slots(self) -> List[str]:
|
284 | 283 | slots.append(slot_name)
|
285 | 284 | return slots
|
286 | 285 |
|
287 |
| - def get_minimum_version(self, slot_name: str, class_name: str = "mapping") -> SssomVersionEnum: |
| 286 | + def get_minimum_version( |
| 287 | + self, slot_name: str, class_name: str = "mapping" |
| 288 | + ) -> Optional[Tuple[int, int]]: |
288 | 289 | """Get the minimum version of SSSOM required for a given slot.
|
289 | 290 |
|
290 | 291 | :param slot_name: The queried slot.
|
291 | 292 | :param class_name: The class the slot belongs to. This is needed
|
292 | 293 | because a slot may have been added to a class
|
293 | 294 | in a later version than the version in which
|
294 | 295 | it was first introduced in the schema.
|
295 |
| - :return: A SssomVersionEnum value representing the earliest |
296 |
| - version of SSSOM that defines the given slot in the |
297 |
| - given class. May be None if the requested slot name |
298 |
| - is not a valid slot name. |
| 296 | + :return: A tuple containing the major and minor numbers of the |
| 297 | + earliest version of SSSOM that defines the given slot |
| 298 | + in the given class. May be None if the requested slot |
| 299 | + name is not a valid slot name. |
299 | 300 | """
|
300 | 301 | try:
|
301 | 302 | slot = self.view.induced_slot(slot_name, class_name)
|
302 |
| - return SssomVersionEnum(slot.annotations.added_in.value) |
| 303 | + version = [int(s) for s in slot.annotations.added_in.value.split(".")] |
| 304 | + if len(version) != 2: |
| 305 | + # Should never happen, schema is incorrect |
| 306 | + return None |
| 307 | + return (version[0], version[1]) |
303 | 308 | except AttributeError: # No added_in annotation, defaults to 1.0
|
304 |
| - return SssomVersionEnum("1.0") |
| 309 | + return (1, 0) |
305 | 310 | except ValueError: # No such slot
|
306 | 311 | return None
|
307 | 312 |
|
|
0 commit comments