From 393cdb6957e5df6992496d1d13f8fb6c56eb9a88 Mon Sep 17 00:00:00 2001 From: Harshad Date: Wed, 8 May 2024 11:53:47 -0700 Subject: [PATCH] Refactored `mappings` to more generic `relationships` in diff markdown output (#750) * Refactor diff markdown title * code clean-up * formatted * reverted relationships to mappings * `mappings` => `relationships` * addressed B024 error --- poetry.lock | 3 +++ pyproject.toml | 1 + src/oaklib/datamodels/vocabulary.py | 1 - .../utilities/writers/change_handler.py | 19 ++----------------- 4 files changed, 6 insertions(+), 18 deletions(-) diff --git a/poetry.lock b/poetry.lock index 371df1ded..971c10b10 100644 --- a/poetry.lock +++ b/poetry.lock @@ -2787,6 +2787,7 @@ files = [ {file = "lxml-5.2.1-cp36-cp36m-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:c38d7b9a690b090de999835f0443d8aa93ce5f2064035dfc48f27f02b4afc3d0"}, {file = "lxml-5.2.1-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:5670fb70a828663cc37552a2a85bf2ac38475572b0e9b91283dc09efb52c41d1"}, {file = "lxml-5.2.1-cp36-cp36m-manylinux_2_28_x86_64.whl", hash = "sha256:958244ad566c3ffc385f47dddde4145088a0ab893504b54b52c041987a8c1863"}, + {file = "lxml-5.2.1-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.whl", hash = "sha256:b6241d4eee5f89453307c2f2bfa03b50362052ca0af1efecf9fef9a41a22bb4f"}, {file = "lxml-5.2.1-cp36-cp36m-musllinux_1_1_aarch64.whl", hash = "sha256:2a66bf12fbd4666dd023b6f51223aed3d9f3b40fef06ce404cb75bafd3d89536"}, {file = "lxml-5.2.1-cp36-cp36m-musllinux_1_1_ppc64le.whl", hash = "sha256:9123716666e25b7b71c4e1789ec829ed18663152008b58544d95b008ed9e21e9"}, {file = "lxml-5.2.1-cp36-cp36m-musllinux_1_1_s390x.whl", hash = "sha256:0c3f67e2aeda739d1cc0b1102c9a9129f7dc83901226cc24dd72ba275ced4218"}, @@ -3571,6 +3572,7 @@ optional = false python-versions = ">=3.9" files = [ {file = "pandas-2.2.2-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:90c6fca2acf139569e74e8781709dccb6fe25940488755716d1d354d6bc58bce"}, + {file = "pandas-2.2.2-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:c7adfc142dac335d8c1e0dcbd37eb8617eac386596eb9e1a1b77791cf2498238"}, {file = "pandas-2.2.2-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:4abfe0be0d7221be4f12552995e58723c7422c80a659da13ca382697de830c08"}, {file = "pandas-2.2.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:8635c16bf3d99040fdf3ca3db669a7250ddf49c55dc4aa8fe0ae0fa8d6dcc1f0"}, {file = "pandas-2.2.2-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:40ae1dffb3967a52203105a077415a86044a2bea011b5f321c6aa64b379a3f51"}, @@ -3591,6 +3593,7 @@ files = [ {file = "pandas-2.2.2-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:43498c0bdb43d55cb162cdc8c06fac328ccb5d2eabe3cadeb3529ae6f0517c32"}, {file = "pandas-2.2.2-cp312-cp312-win_amd64.whl", hash = "sha256:d187d355ecec3629624fccb01d104da7d7f391db0311145817525281e2804d23"}, {file = "pandas-2.2.2-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:0ca6377b8fca51815f382bd0b697a0814c8bda55115678cbc94c30aacbb6eff2"}, + {file = "pandas-2.2.2-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:9057e6aa78a584bc93a13f0a9bf7e753a5e9770a30b4d758b8d5f2a62a9433cd"}, {file = "pandas-2.2.2-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:001910ad31abc7bf06f49dcc903755d2f7f3a9186c0c040b827e522e9cef0863"}, {file = "pandas-2.2.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:66b479b0bd07204e37583c191535505410daa8df638fd8e75ae1b383851fe921"}, {file = "pandas-2.2.2-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:a77e9d1c386196879aa5eb712e77461aaee433e54c68cf253053a73b7e49c33a"}, diff --git a/pyproject.toml b/pyproject.toml index 0f484efbc..564d4d717 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -105,6 +105,7 @@ lint.extend-ignore = [ "S607", # Starting a process with a partial executable path "S608", # Possible SQL injection vector through string-based query construction "S603", # `subprocess` call: check for execution of untrusted input + "B024", # XXX is an abstract base class, but it has no abstract methods ] lint.exclude = ["src/oaklib/datamodels/*"] line-length = 120 diff --git a/src/oaklib/datamodels/vocabulary.py b/src/oaklib/datamodels/vocabulary.py index 8dec4aa3f..eb1f845dc 100644 --- a/src/oaklib/datamodels/vocabulary.py +++ b/src/oaklib/datamodels/vocabulary.py @@ -171,7 +171,6 @@ OWL_VERSION_INFO = "owl:versionInfo" OWL_VERSION_IRI = "owl:versionIRI" -MAPPING_EDGE_DELETION = "MappingEdgeDeletion" CLASS_CREATION = "ClassCreation" NODE_CREATION = "NodeCreation" NODE_DELETION = "NodeDeletion" diff --git a/src/oaklib/utilities/writers/change_handler.py b/src/oaklib/utilities/writers/change_handler.py index c67b19e44..e959c2867 100644 --- a/src/oaklib/utilities/writers/change_handler.py +++ b/src/oaklib/utilities/writers/change_handler.py @@ -67,7 +67,7 @@ def handle_edge_creation(self, value): header = "| Subject | Predicate | Object|" # Write the "Edges Created" section as a collapsible markdown table - self.write_markdown_table(f"Mappings added: {len(rows)}", header, rows) + self.write_markdown_table(f"Relationships added: {len(rows)}", header, rows) def handle_edge_change(self, value): # Create rows for the table @@ -82,21 +82,7 @@ def handle_edge_change(self, value): header = "| Subject | Predicate | Old Object | New Object |" # Write the "Edges Changed" section as a collapsible markdown table - self.write_markdown_table(f"Mappings changed: {len(rows)}", header, rows) - - def handle_mapping_edge_deletion(self, value): - # Create rows for the table - rows = [ - f"| {self._format_entity_labels(change.subject)} | {self._format_entity_labels(change.predicate)} |\ - {self._format_entity_labels(change.object)} |" - for change in value - ] - - # Define the header for the table - header = "| Subject | Predicate | Object |" - - # Write the "Edges Deleted" section as a collapsible markdown table - self.write_markdown_table(f"Mappings removed: {len(rows)}", header, rows) + self.write_markdown_table(f"Relationships changed: {len(rows)}", header, rows) def handle_node_move(self, value): # Create rows for the table @@ -353,7 +339,6 @@ def process_changes(self, curie_or_change: Dict[str, Change]): "NodeDirectMerge": self.handle_node_direct_merge, "EdgeCreation": self.handle_edge_creation, "EdgeChange": self.handle_edge_change, - "MappingEdgeDeletion": self.handle_mapping_edge_deletion, "AddNodeToSubset": self.handle_add_node_to_subset, # "DatatypeOrLanguageTagChange": self.handle_datatype_or_language_tag_change, # "LanguageTagChange": self.handle_language_tag_change,