From fed64dfca6c017078327e40b963187a8faed710d Mon Sep 17 00:00:00 2001 From: Sierra Taylor Moxon Date: Mon, 8 Apr 2024 12:00:25 -0700 Subject: [PATCH 1/6] update toolkit to 4.1.6, add support for biolink formatted aliases in get_element --- bmt/toolkit.py | 7 +++++-- pyproject.toml | 2 +- tests/unit/test_toolkit.py | 5 +++++ 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/bmt/toolkit.py b/bmt/toolkit.py index 228186f..25a25d8 100644 --- a/bmt/toolkit.py +++ b/bmt/toolkit.py @@ -21,7 +21,7 @@ Url = str Path = str -LATEST_BIOLINK_RELEASE = "4.1.5" +LATEST_BIOLINK_RELEASE = "4.1.6" REMOTE_PATH = f"https://raw.githubusercontent.com/biolink/biolink-model/v{LATEST_BIOLINK_RELEASE}/biolink-model.yaml" PREDICATE_MAP = f"https://raw.githubusercontent.com/biolink/biolink-model/v{LATEST_BIOLINK_RELEASE}/predicate_mapping.yaml" @@ -884,8 +884,11 @@ def get_element(self, name: str) -> Optional[Element]: logger.debug(parsed_name) element = self.view.get_element(parsed_name) if element is None and self.view.all_aliases() is not None: + if parsed_name.startswith("biolink:"): + parsed_name = parsed_name.replace("biolink:", "") + parsed_name = parsed_name.replace("_", " ") for e in self.view.all_aliases(): - if name in self.view.all_aliases()[e]: + if name in self.view.all_aliases()[e] or parsed_name in self.view.all_aliases()[e]: element = self.view.get_element(e) if element is None and "_" in name: element = self.get_element(name.replace("_", " ")) diff --git a/pyproject.toml b/pyproject.toml index 44ded06..f717099 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "bmt" -version = "1.1.2.post14.dev0+08be61e" +version = "1.2.1" description = "Biolink Model Toolkit: A Python API for working with the Biolink Model" authors = ["Sierra Taylor Moxon "] license = "BSD" diff --git a/tests/unit/test_toolkit.py b/tests/unit/test_toolkit.py index 2ecdfdf..ac00e0e 100644 --- a/tests/unit/test_toolkit.py +++ b/tests/unit/test_toolkit.py @@ -130,6 +130,11 @@ def test_not_valid_edge(toolkit): def test_get_element_via_alias(toolkit): el = toolkit.get_element('definition') + pred_alias = toolkit.get_element("biolink:realized_in_response_to") + print(pred_alias) + ameliorates_aliase = toolkit.get_element("biolink:ameliorates") + assert ameliorates_aliase.name == "ameliorates condition" + assert pred_alias.name == "caused by" assert el.name == 'description' From b5e25e42858a57c51154b92d8ea7ef65538c2725 Mon Sep 17 00:00:00 2001 From: Sierra Taylor Moxon Date: Mon, 8 Apr 2024 12:03:59 -0700 Subject: [PATCH 2/6] add tests for formatted and not --- tests/unit/test_toolkit.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/unit/test_toolkit.py b/tests/unit/test_toolkit.py index ac00e0e..3956c2a 100644 --- a/tests/unit/test_toolkit.py +++ b/tests/unit/test_toolkit.py @@ -890,6 +890,9 @@ def test_descendants(toolkit): assert INTERACTS_WITH in toolkit.get_descendants(RELATED_TO) assert PHENOTYPIC_FEATURE in toolkit.get_descendants(NAMED_THING) assert RELATED_TO not in toolkit.get_descendants(NAMED_THING) + assert "ameliorates condition" in toolkit.get_descendants("biolink:ameliorates") + assert "biolink:ameliorates_condition" in toolkit.get_descendants("biolink:ameliorates", formatted=True) + with pytest.raises(ValueError): toolkit.get_descendants('biolink:invalid') assert "biolink:PhenotypicFeature" in toolkit.get_descendants( From c3839cbf04724a839f02f6d1a7106d8155f4859a Mon Sep 17 00:00:00 2001 From: Sierra Taylor Moxon Date: Mon, 8 Apr 2024 14:04:05 -0700 Subject: [PATCH 3/6] add support for more python versions, bump actions --- .github/workflows/check-dependencies.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/check-dependencies.yaml b/.github/workflows/check-dependencies.yaml index 9a332b8..330f25b 100644 --- a/.github/workflows/check-dependencies.yaml +++ b/.github/workflows/check-dependencies.yaml @@ -18,7 +18,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python: [ "3.9", "3.10" ] + python: [ "3.9", "3.10", "3.11", "3.12" ] # Steps represent a sequence of tasks that will be executed as part of the job steps: From e7b92f2c61ed4dc7a35638a29cfc7a77405fc448 Mon Sep 17 00:00:00 2001 From: Sierra Taylor Moxon Date: Mon, 8 Apr 2024 14:12:17 -0700 Subject: [PATCH 4/6] expand range of test OS --- .github/workflows/initialize-toolkit-daily.yaml | 14 ++++---------- .github/workflows/run-tests.yml | 2 +- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/.github/workflows/initialize-toolkit-daily.yaml b/.github/workflows/initialize-toolkit-daily.yaml index 9a0eac3..f87f338 100644 --- a/.github/workflows/initialize-toolkit-daily.yaml +++ b/.github/workflows/initialize-toolkit-daily.yaml @@ -16,7 +16,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python: [ "3.9", "3.10" ] + python: [ "3.9", "3.10", "3.11", "3.12" ] # Steps represent a sequence of tasks that will be executed as part of the job steps: @@ -48,18 +48,12 @@ jobs: git clone https://github.com/biolink/kgx.git cd kgx poetry install # this will install a different version of hdmf from the current one - poetry remove bmt - ls -al ../ - poetry add /home/runner/work/biolink-model-toolkit/biolink-model-toolkit - - - name: Setup Neo4j Docker - run: | - cd ../ - pwd - cd kgx docker run --detach --name kgx-neo4j-unit-test -p 8484:7474 -p 8888:7687 --env NEO4J_AUTH=neo4j/test neo4j:4.3.0 docker run --detach --name kgx-neo4j-integration-test -p 7474:7474 -p 7687:7687 --env NEO4J_AUTH=neo4j/test neo4j:4.3.0 docker ps -a + poetry remove bmt + ls -al ../ + poetry add /home/runner/work/biolink-model-toolkit/biolink-model-toolkit - name: Wait uses: jakejarvis/wait-action@master diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 8ec6c9c..49d0184 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -22,7 +22,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python: [ "3.9", "3.10" ] + python: [ "3.9", "3.10", "3.11", "3.12" ] # Steps represent a sequence of tasks that will be executed as part of the job steps: From 9f0dcf9bf69a394960cd5e958552bc207b5b4848 Mon Sep 17 00:00:00 2001 From: Sierra Taylor Moxon Date: Mon, 8 Apr 2024 14:16:04 -0700 Subject: [PATCH 5/6] not 3.12 --- .github/workflows/check-dependencies.yaml | 2 +- .github/workflows/initialize-toolkit-daily.yaml | 14 ++++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/.github/workflows/check-dependencies.yaml b/.github/workflows/check-dependencies.yaml index 330f25b..9d32dd7 100644 --- a/.github/workflows/check-dependencies.yaml +++ b/.github/workflows/check-dependencies.yaml @@ -18,7 +18,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python: [ "3.9", "3.10", "3.11", "3.12" ] + python: [ "3.9", "3.10", "3.11" ] # Steps represent a sequence of tasks that will be executed as part of the job steps: diff --git a/.github/workflows/initialize-toolkit-daily.yaml b/.github/workflows/initialize-toolkit-daily.yaml index f87f338..cef81b7 100644 --- a/.github/workflows/initialize-toolkit-daily.yaml +++ b/.github/workflows/initialize-toolkit-daily.yaml @@ -16,7 +16,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python: [ "3.9", "3.10", "3.11", "3.12" ] + python: [ "3.9", "3.10", "3.11" ] # Steps represent a sequence of tasks that will be executed as part of the job steps: @@ -48,13 +48,19 @@ jobs: git clone https://github.com/biolink/kgx.git cd kgx poetry install # this will install a different version of hdmf from the current one - docker run --detach --name kgx-neo4j-unit-test -p 8484:7474 -p 8888:7687 --env NEO4J_AUTH=neo4j/test neo4j:4.3.0 - docker run --detach --name kgx-neo4j-integration-test -p 7474:7474 -p 7687:7687 --env NEO4J_AUTH=neo4j/test neo4j:4.3.0 - docker ps -a poetry remove bmt ls -al ../ poetry add /home/runner/work/biolink-model-toolkit/biolink-model-toolkit + - name: Setup Neo4j Docker + run: | + cd ../ + pwd + cd kgx + docker run --detach --name kgx-neo4j-unit-test -p 8484:7474 -p 8888:7687 --env NEO4J_AUTH=neo4j/test neo4j:4.3.0 + docker run --detach --name kgx-neo4j-integration-test -p 7474:7474 -p 7687:7687 --env NEO4J_AUTH=neo4j/test neo4j:4.3.0 + docker ps -a + - name: Wait uses: jakejarvis/wait-action@master with: From 89b7eeeed3b1b14a012060549186d97cacf6d69f Mon Sep 17 00:00:00 2001 From: Sierra Taylor Moxon Date: Mon, 8 Apr 2024 14:16:38 -0700 Subject: [PATCH 6/6] not 3.12 --- .github/workflows/run-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 49d0184..c6bc5b2 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -22,7 +22,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python: [ "3.9", "3.10", "3.11", "3.12" ] + python: [ "3.9", "3.10", "3.11" ] # Steps represent a sequence of tasks that will be executed as part of the job steps: