Skip to content

Commit 467c62e

Browse files
authored
Use latest pre-release of the SSSOM schema. (#625)
* Use latest pre-release of the SSSOM schema. Update the sssom_schema dependency to use the latest 1.1.0 pre-release, so that we can start using the new slots and enum values in the upcoming version of the specification and ensure that SSSOM-Py is ready to work with them. * Use SSSOMSchemaView() when needing to get the list of mapping slots. The `inject_metadata_into_df` function (whose entire purpose is very dubious but that is another matter) needs a list of the slots available in the mapping class. It gets that list by doing its own loading of the SSSOM schema. It does so without specifying any encoding for the schema file, and apparently the default YAML parser, when not provided with an explicit encoding on Windows, assumes the encoding is CP-1252. This results in a failure to load the schema if it happens to contain UTF-8-encoded non-ASCII characters (which in version 1.1.0a2 it does, because we are no longer in the 1980s). This commit updates the `inject_metadata_into_df` function so that it reuses the SSSOMSchemaView class, which is precisely intended to give access to the contents of the schema.
1 parent 0c05ff1 commit 467c62e

File tree

3 files changed

+63
-37
lines changed

3 files changed

+63
-37
lines changed

poetry.lock

Lines changed: 61 additions & 31 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ dependencies = [
1818
"linkml-runtime>=1.7.5",
1919
"linkml>1.7.10",
2020
"pandas>1.0.3",
21-
"sssom-schema==1.0.0",
21+
"sssom-schema==1.1.0a2",
2222
"sparqlwrapper>=2.0.0",
2323
"validators>=0.20.0",
2424
"deprecation>=2.1.0",

src/sssom/util.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
import numpy as np
3131
import pandas as pd
3232
import validators
33-
import yaml
3433
from curies import Converter, ReferenceTuple
3534
from jsonschema import ValidationError
3635
from linkml_runtime.linkml_model.types import Uriorcurie
@@ -61,7 +60,6 @@
6160
PREDICATE_MODIFIER,
6261
PREDICATE_MODIFIER_NOT,
6362
RDFS_SUBCLASS_OF,
64-
SCHEMA_YAML,
6563
SEMAPV,
6664
SKOS_BROAD_MATCH,
6765
SKOS_CLOSE_MATCH,
@@ -1209,9 +1207,7 @@ def inject_metadata_into_df(msdf: MappingSetDataFrame) -> MappingSetDataFrame:
12091207
# TODO add this into the "standardize" function introduced in
12101208
# https://github.com/mapping-commons/sssom-py/pull/438
12111209
# TODO Check if 'k' is a valid 'slot' for 'mapping' [sssom.yaml]
1212-
with SCHEMA_YAML.open() as file:
1213-
schema = yaml.safe_load(file)
1214-
slots = schema["classes"]["mapping"]["slots"]
1210+
slots = SSSOMSchemaView().mapping_slots
12151211
for k, v in msdf.metadata.items():
12161212
if k not in msdf.df.columns and k in slots:
12171213
if k == MAPPING_SET_ID:

0 commit comments

Comments
 (0)