Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update for latest changes of the SSSOM schema #552

Merged
merged 2 commits into from
Aug 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/sssom/parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -914,6 +914,16 @@ def _ensure_valid_mapping_from_dict(mdict: Dict[str, Any]):

try:
m = Mapping(**mdict)
if m.subject_type == "rdfs literal":
if m.subject_label is None:
raise ValueError("Missing subject_label")
elif m.subject_id is None:
raise ValueError("Missing subject_id")
if m.object_type == "rdfs literal":
if m.object_label is None:
raise ValueError("Missing object_label")
elif m.object_id is None:
raise ValueError("Missing object_id")
except ValueError as e:
logging.warning(
f"One mapping in the mapping set is not well-formed, "
Expand Down
10 changes: 8 additions & 2 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import yaml
from curies import Converter, Record, chain
from sssom_schema import Mapping as SSSOM_Mapping
from sssom_schema import slots as SSSOM_Slots

from sssom.constants import (
CREATOR_ID,
Expand Down Expand Up @@ -409,14 +410,19 @@ def test_get_dict_from_mapping(self):
"match_string": "",
"subject_preprocessing": "",
"object_preprocessing": "",
"semantic_similarity_score": np.nan,
"semantic_similarity_measure": "",
"see_also": "",
"issue_tracker_item": "",
"other": "",
"comment": "",
}

if hasattr(SSSOM_Slots, "similarity_score"):
expected_result["similarity_score"] = np.nan
expected_result["similarity_measure"] = ""
else:
expected_result["semantic_similarity_score"] = np.nan
expected_result["semantic_similarity_measure"] = ""

result_with_mapping_object = get_dict_from_mapping(mapping_obj)
result_with_dict = get_dict_from_mapping(mapping_dict)
self.assertEqual(result_with_mapping_object, result_with_dict)
Expand Down
Loading