From 046576a890784c8daf4c6d83a7831bbe293540cd Mon Sep 17 00:00:00 2001 From: Corey Cox <69321580+amc-corey-cox@users.noreply.github.com> Date: Mon, 6 Mar 2023 15:51:55 -0800 Subject: [PATCH 1/3] Fix get_classes_modifying_slot --- linkml_runtime/utils/schemaview.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/linkml_runtime/utils/schemaview.py b/linkml_runtime/utils/schemaview.py index 495b36a4..d65af31c 100644 --- a/linkml_runtime/utils/schemaview.py +++ b/linkml_runtime/utils/schemaview.py @@ -1453,21 +1453,20 @@ def get_slots_by_enum(self, enum_name: ENUM_NAME = None) -> List[SlotDefinition] enum_slots.append(slot_definition) return enum_slots - def get_classes_modifying_slot(self, slot_name: SLOT_NAME = None) -> List[ClassDefinition]: + def get_classes_modifying_slot(self, slot: SlotDefinition) -> List[ClassDefinition]: """Get all ClassDefinitions that modify a given slot. :param slot_name: slot in consideration :return: list of ClassDefinitions modifying the slot of interest """ - # slot_classes = [c for c in self.all_classes().values() if c.slot_usage == slot_name] - # slot_classes = [c for c in self.all_classes().values()] - slot_classes = [] + modifying_classes = [] for class_definition in self.all_classes().values(): if class_definition.slot_usage: for slot_definition in class_definition.slot_usage.values(): - if slot_definition.name == slot_name: - slot_classes.append(class_definition) - return slot_classes + if slot_definition.name == slot.name: + modifying_classes.append(class_definition.name) + + return modifying_classes def is_slot_percent_encoded(self, slot: SlotDefinitionName) -> bool: """ From 8a64cf9caef2d4a82cb0c89ec7a3c9c0155a03eb Mon Sep 17 00:00:00 2001 From: Corey Cox <69321580+amc-corey-cox@users.noreply.github.com> Date: Tue, 7 Mar 2023 09:15:49 -0800 Subject: [PATCH 2/3] Fix tests for classes_modifying_slot --- tests/test_issues/test_linkml_issue_1126.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/test_issues/test_linkml_issue_1126.py b/tests/test_issues/test_linkml_issue_1126.py index bb1cfb5c..fd69c1dd 100644 --- a/tests/test_issues/test_linkml_issue_1126.py +++ b/tests/test_issues/test_linkml_issue_1126.py @@ -2,7 +2,7 @@ import unittest from unittest import TestCase from linkml_runtime.utils.schemaview import SchemaView -from linkml_runtime.linkml_model import ClassDefinition +from linkml_runtime.linkml_model import ClassDefinitionName from tests.test_issues.environment import env @@ -16,13 +16,13 @@ class Issue998TestCase(TestCase): def test_issue_1126_slot_classes(self): view = SchemaView(env.input_path('linkml_issue_1126.yaml')) - slot_classes = view.get_classes_modifying_slot("type") + slot_definition = view.get_slot("type") + slot_classes = view.get_classes_modifying_slot(slot_definition) assert len(slot_classes) == 2 for element in slot_classes: - assert type(element) is ClassDefinition - assert slot_classes[0].name == "Programmer" - assert slot_classes[1].name == "Administrator" - + assert type(element) is ClassDefinitionName + assert slot_classes[0] == ClassDefinitionName("Programmer") + assert slot_classes[1] == ClassDefinitionName("Administrator") if __name__ == "__main__": unittest.main() From 862e760569b7494e89579893ed307c62343863db Mon Sep 17 00:00:00 2001 From: Patrick Kalita Date: Fri, 17 Mar 2023 09:56:00 -0700 Subject: [PATCH 3/3] Pin poetry version in test workflow --- .github/workflows/main.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 45a5af05..7a92c1a0 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -27,7 +27,8 @@ jobs: # install poetry #---------------------------------------------- - name: Install Poetry - run: pipx install poetry + # Pin to 1.3.2 to workaround https://github.com/python-poetry/poetry/issues/7611 + run: pipx install poetry==1.3.2 #---------------------------------------------- # check-out repo and set-up python