From 3835d2188a9c80b2c627a2e07a5cf0027e006d32 Mon Sep 17 00:00:00 2001 From: Fernando Zhapa-Camacho Date: Tue, 19 Nov 2024 17:51:39 +0300 Subject: [PATCH 1/6] =?UTF-8?q?=F0=9F=91=B7=20Unified=20yml=20files=20for?= =?UTF-8?q?=20different=20python=20version=20into=20a=20single=20one?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/python-package_3_10.yml | 48 ------- .github/workflows/python-package_3_11.yml | 48 ------- .github/workflows/python-package_3_12.yml | 48 ------- .github/workflows/python-package_3_9.yml | 48 ------- .github/workflows/python-publish.yml | 4 +- .github/workflows/unittests.yml | 159 ++++++++++++++++++++++ 6 files changed, 162 insertions(+), 193 deletions(-) delete mode 100644 .github/workflows/python-package_3_10.yml delete mode 100644 .github/workflows/python-package_3_11.yml delete mode 100644 .github/workflows/python-package_3_12.yml delete mode 100644 .github/workflows/python-package_3_9.yml create mode 100644 .github/workflows/unittests.yml diff --git a/.github/workflows/python-package_3_10.yml b/.github/workflows/python-package_3_10.yml deleted file mode 100644 index 4d1d69ee..00000000 --- a/.github/workflows/python-package_3_10.yml +++ /dev/null @@ -1,48 +0,0 @@ -# This workflow will install Python dependencies, run tests and lint with a variety of Python versions -# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions - -name: Python package - -on: - push: - branches: [ "main", develop ] - pull_request: - branches: [ "main", develop ] - -jobs: - build: - - runs-on: ${{ matrix.os }} - strategy: - fail-fast: false - matrix: - os: ["ubuntu-latest"] - python-version: ["3.10"] - defaults: - run: - shell: bash -l {0} - steps: - - uses: actions/checkout@v3 - - uses: conda-incubator/setup-miniconda@v2 - with: - auto-update-conda: true - python-version: ${{ matrix.python-version }} - activate-environment: anaconda-client-env - environment-file: envs/environment_3_10.yml - auto-activate-base: false - channels: conda-forge - use-mamba: true - - name: Install dependencies - run: | - python -m pip install --upgrade pip - python -m pip install flake8 pytest coverage pytest-faulthandler - if [ -f requirements.txt ]; then pip install -r requirements.txt; fi - - name: Lint with flake8 - run: | - # stop the build if there are Python syntax errors or undefined names - # flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics - # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide - flake8 mowl --count --exit-zero --max-complexity=20 --max-line-length=127 --statistics - - name: Test with pytest - run: | - pytest -m "not slow" -p no:faulthandler diff --git a/.github/workflows/python-package_3_11.yml b/.github/workflows/python-package_3_11.yml deleted file mode 100644 index b09fdcaf..00000000 --- a/.github/workflows/python-package_3_11.yml +++ /dev/null @@ -1,48 +0,0 @@ -# This workflow will install Python dependencies, run tests and lint with a variety of Python versions -# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions - -name: Python package - -on: - push: - branches: [ "main", develop ] - pull_request: - branches: [ "main", develop ] - -jobs: - build: - - runs-on: ${{ matrix.os }} - strategy: - fail-fast: false - matrix: - os: ["ubuntu-latest"] - python-version: ["3.11"] - defaults: - run: - shell: bash -l {0} - steps: - - uses: actions/checkout@v3 - - uses: conda-incubator/setup-miniconda@v2 - with: - auto-update-conda: true - python-version: ${{ matrix.python-version }} - activate-environment: anaconda-client-env - environment-file: envs/environment_3_11.yml - auto-activate-base: false - channels: conda-forge - use-mamba: true - - name: Install dependencies - run: | - python -m pip install --upgrade pip - python -m pip install flake8 pytest coverage pytest-faulthandler - if [ -f requirements.txt ]; then pip install -r requirements.txt; fi - - name: Lint with flake8 - run: | - # stop the build if there are Python syntax errors or undefined names - # flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics - # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide - flake8 mowl --count --exit-zero --max-complexity=20 --max-line-length=127 --statistics - - name: Test with pytest - run: | - pytest -m "not slow" -p no:faulthandler diff --git a/.github/workflows/python-package_3_12.yml b/.github/workflows/python-package_3_12.yml deleted file mode 100644 index a134e12d..00000000 --- a/.github/workflows/python-package_3_12.yml +++ /dev/null @@ -1,48 +0,0 @@ -# This workflow will install Python dependencies, run tests and lint with a variety of Python versions -# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions - -name: Python package - -on: - push: - branches: [ "main", develop ] - pull_request: - branches: [ "main", develop ] - -jobs: - build: - - runs-on: ${{ matrix.os }} - strategy: - fail-fast: false - matrix: - os: ["ubuntu-latest"] - python-version: ["3.12"] - defaults: - run: - shell: bash -l {0} - steps: - - uses: actions/checkout@v3 - - uses: conda-incubator/setup-miniconda@v2 - with: - auto-update-conda: true - python-version: ${{ matrix.python-version }} - activate-environment: anaconda-client-env - environment-file: envs/environment_3_12.yml - auto-activate-base: false - channels: conda-forge - use-mamba: true - - name: Install dependencies - run: | - python -m pip install --upgrade pip - python -m pip install flake8 pytest coverage pytest-faulthandler - if [ -f requirements.txt ]; then pip install -r requirements.txt; fi - - name: Lint with flake8 - run: | - # stop the build if there are Python syntax errors or undefined names - # flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics - # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide - flake8 mowl --count --exit-zero --max-complexity=20 --max-line-length=127 --statistics - - name: Test with pytest - run: | - pytest -m "not slow" -p no:faulthandler diff --git a/.github/workflows/python-package_3_9.yml b/.github/workflows/python-package_3_9.yml deleted file mode 100644 index 8181676b..00000000 --- a/.github/workflows/python-package_3_9.yml +++ /dev/null @@ -1,48 +0,0 @@ -# This workflow will install Python dependencies, run tests and lint with a variety of Python versions -# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions - -name: Python package - -on: - push: - branches: [ "main", develop ] - pull_request: - branches: [ "main", develop ] - -jobs: - build: - - runs-on: ${{ matrix.os }} - strategy: - fail-fast: false - matrix: - os: ["ubuntu-latest"] - python-version: ["3.9"] - defaults: - run: - shell: bash -l {0} - steps: - - uses: actions/checkout@v3 - - uses: conda-incubator/setup-miniconda@v2 - with: - auto-update-conda: true - python-version: ${{ matrix.python-version }} - activate-environment: anaconda-client-env - environment-file: envs/environment_3_9.yml - auto-activate-base: false - channels: conda-forge - use-mamba: true - - name: Install dependencies - run: | - python -m pip install --upgrade pip - python -m pip install flake8 nose pinocchio nose-exclude coverage - if [ -f requirements.txt ]; then pip install -r requirements.txt; fi - - name: Lint with flake8 - run: | - # stop the build if there are Python syntax errors or undefined names - # flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics - # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide - flake8 mowl --count --exit-zero --max-complexity=20 --max-line-length=127 --statistics - - name: Test with nose - run: | - nosetests tests diff --git a/.github/workflows/python-publish.yml b/.github/workflows/python-publish.yml index 380c5ea9..b3c5d061 100644 --- a/.github/workflows/python-publish.yml +++ b/.github/workflows/python-publish.yml @@ -2,7 +2,9 @@ name: Publish Python 🐍 distribution 📦 to PyPI and TestPyPI -on: push +on: + push: + branches: ["main"] jobs: build: diff --git a/.github/workflows/unittests.yml b/.github/workflows/unittests.yml new file mode 100644 index 00000000..b4efd9b9 --- /dev/null +++ b/.github/workflows/unittests.yml @@ -0,0 +1,159 @@ +# This workflow will install Python dependencies, run tests and lint with a variety of Python versions +# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions + +name: Python Unit Tests + +on: + push: + branches: [ "main", develop ] + pull_request: + branches: [ "main", develop ] + +jobs: + python-3.9: + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: ["ubuntu-latest"] + python-version: ["3.9"] + defaults: + run: + shell: bash -l {0} + steps: + - uses: actions/checkout@v3 + - uses: conda-incubator/setup-miniconda@v2 + with: + auto-update-conda: true + python-version: ${{ matrix.python-version }} + activate-environment: anaconda-client-env + environment-file: envs/environment_3_9.yml + auto-activate-base: false + channels: conda-forge + use-mamba: true + - name: Install dependencies + run: | + python -m pip install --upgrade pip + python -m pip install flake8 nose pinocchio nose-exclude coverage + if [ -f requirements.txt ]; then pip install -r requirements.txt; fi + - name: Lint with flake8 + run: | + # stop the build if there are Python syntax errors or undefined names + # flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics + # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide + flake8 mowl --count --exit-zero --max-complexity=20 --max-line-length=127 --statistics + - name: Test with nose + run: | + nosetests tests + + python-3.10: + + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: ["ubuntu-latest"] + python-version: ["3.10"] + defaults: + run: + shell: bash -l {0} + steps: + - uses: actions/checkout@v3 + - uses: conda-incubator/setup-miniconda@v2 + with: + auto-update-conda: true + python-version: ${{ matrix.python-version }} + activate-environment: anaconda-client-env + environment-file: envs/environment_3_10.yml + auto-activate-base: false + channels: conda-forge + use-mamba: true + - name: Install dependencies + run: | + python -m pip install --upgrade pip + python -m pip install flake8 pytest coverage pytest-faulthandler + if [ -f requirements.txt ]; then pip install -r requirements.txt; fi + - name: Lint with flake8 + run: | + # stop the build if there are Python syntax errors or undefined names + # flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics + # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide + flake8 mowl --count --exit-zero --max-complexity=20 --max-line-length=127 --statistics + - name: Test with pytest + run: | + pytest -m "not slow" -p no:faulthandler + + + python-3.11: + + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: ["ubuntu-latest"] + python-version: ["3.11"] + defaults: + run: + shell: bash -l {0} + steps: + - uses: actions/checkout@v3 + - uses: conda-incubator/setup-miniconda@v2 + with: + auto-update-conda: true + python-version: ${{ matrix.python-version }} + activate-environment: anaconda-client-env + environment-file: envs/environment_3_11.yml + auto-activate-base: false + channels: conda-forge + use-mamba: true + - name: Install dependencies + run: | + python -m pip install --upgrade pip + python -m pip install flake8 pytest coverage pytest-faulthandler + if [ -f requirements.txt ]; then pip install -r requirements.txt; fi + - name: Lint with flake8 + run: | + # stop the build if there are Python syntax errors or undefined names + # flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics + # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide + flake8 mowl --count --exit-zero --max-complexity=20 --max-line-length=127 --statistics + - name: Test with pytest + run: | + pytest -m "not slow" -p no:faulthandler + + python-3.12: + + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: ["ubuntu-latest"] + python-version: ["3.12"] + defaults: + run: + shell: bash -l {0} + steps: + - uses: actions/checkout@v3 + - uses: conda-incubator/setup-miniconda@v2 + with: + auto-update-conda: true + python-version: ${{ matrix.python-version }} + activate-environment: anaconda-client-env + environment-file: envs/environment_3_12.yml + auto-activate-base: false + channels: conda-forge + use-mamba: true + - name: Install dependencies + run: | + python -m pip install --upgrade pip + python -m pip install flake8 pytest coverage pytest-faulthandler + if [ -f requirements.txt ]; then pip install -r requirements.txt; fi + - name: Lint with flake8 + run: | + # stop the build if there are Python syntax errors or undefined names + # flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics + # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide + flake8 mowl --count --exit-zero --max-complexity=20 --max-line-length=127 --statistics + - name: Test with pytest + run: | + pytest -m "not slow" -p no:faulthandler From e6724a98837a10a7683aadaeb77dcf482d0e8d7c Mon Sep 17 00:00:00 2001 From: Fernando Zhapa-Camacho Date: Tue, 19 Nov 2024 17:55:39 +0300 Subject: [PATCH 2/6] =?UTF-8?q?=E2=9C=8F=EF=B8=8F=20Fix=20yml=20idenifiers?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/unittests.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/unittests.yml b/.github/workflows/unittests.yml index b4efd9b9..d93fbd76 100644 --- a/.github/workflows/unittests.yml +++ b/.github/workflows/unittests.yml @@ -10,7 +10,7 @@ on: branches: [ "main", develop ] jobs: - python-3.9: + python-3-9: runs-on: ${{ matrix.os }} strategy: fail-fast: false @@ -46,7 +46,7 @@ jobs: run: | nosetests tests - python-3.10: + python-3-10: runs-on: ${{ matrix.os }} strategy: @@ -84,7 +84,7 @@ jobs: pytest -m "not slow" -p no:faulthandler - python-3.11: + python-3-11: runs-on: ${{ matrix.os }} strategy: @@ -121,7 +121,7 @@ jobs: run: | pytest -m "not slow" -p no:faulthandler - python-3.12: + python-3-12: runs-on: ${{ matrix.os }} strategy: From dcfb64cef74cc1f86301b26c4ce6f2c93202601b Mon Sep 17 00:00:00 2001 From: Fernando Zhapa-Camacho Date: Tue, 19 Nov 2024 22:10:04 +0300 Subject: [PATCH 3/6] =?UTF-8?q?=F0=9F=90=9B=20Issue=20#37?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/source/conf.py | 4 ++-- docs/source/index.rst | 2 +- mowl/projection/edge.py | 11 +++++++---- setup.py | 2 +- 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/docs/source/conf.py b/docs/source/conf.py index 3be42f53..0a9e56e3 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -22,8 +22,8 @@ copyright = '2023, Bio-Ontology Research Group' author = 'BORG' -release = '1.0.1' -version = '1.0.1' +release = '1.0.2-dev' +version = '1.0.2-dev' # -- General configuration extensions = [ diff --git a/docs/source/index.rst b/docs/source/index.rst index a0de0320..946bc7a6 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -27,7 +27,7 @@ Getting started **mOWL** can be installed from `source code `_ or from `PyPi `_. For more details on installation check out the how to :doc:`install/index` section of the project. .. note:: - This version of documentation corresponds to mOWL-1.0.1. + This version of documentation corresponds to mOWL-1.0.2-dev. mOWL, JPype and the JVM diff --git a/mowl/projection/edge.py b/mowl/projection/edge.py index 3161bcc2..429933c8 100644 --- a/mowl/projection/edge.py +++ b/mowl/projection/edge.py @@ -69,6 +69,7 @@ def getEntitiesAndRelations(edges): return Edge.get_entities_and_relations(edges) @staticmethod + @versionchanged(version="1.0.2", reason="Method return type changed to tuple of lists") def get_entities_and_relations(edges): ''' :param edges: list of edges @@ -76,7 +77,7 @@ def get_entities_and_relations(edges): :returns: Returns a 2-tuple containing the list of entities (heads and tails) and the \ list of relations - :rtype: (Set of str, Set of str) + :rtype: (list of str, list of str) ''' entities = set() @@ -86,6 +87,9 @@ def get_entities_and_relations(edges): entities |= {edge.src, edge.dst} relations |= {edge.rel} + entities = sorted(list(entities)) + relations = sorted(list(relations)) + return (entities, relations) @staticmethod @@ -109,12 +113,11 @@ def as_pykeen(edges, create_inverse_triples=True, entity_to_id=None, relation_to """ if entity_to_id is None or relation_to_id is None: classes, relations = Edge.getEntitiesAndRelations(edges) - classes, relations = set(classes), set(relations) if entity_to_id is None: - entity_to_id = {v: k for k, v in enumerate(list(classes))} + entity_to_id = {v: k for k, v in enumerate(classes)} if relation_to_id is None: - relation_to_id = {v: k for k, v in enumerate(list(relations))} + relation_to_id = {v: k for k, v in enumerate(relations)} def map_edge(edge): return [entity_to_id[edge.src], relation_to_id[edge.rel], entity_to_id[edge.dst]] diff --git a/setup.py b/setup.py index c18e34c4..c86b9cb1 100644 --- a/setup.py +++ b/setup.py @@ -6,7 +6,7 @@ setuptools.setup( name="mowl-borg", - version="1.0.2-dev.1", + version="1.0.2-dev.2", author="Bio-Ontology Research Group", author_email="fernando.zhapacamacho@kaust.edu.sa", description="mOWL: A machine learning library with ontologies", From 24afae0fcfb04a6861c71a6ad582217cf4abeb86 Mon Sep 17 00:00:00 2001 From: Fernando Zhapa-Camacho Date: Tue, 19 Nov 2024 22:15:58 +0300 Subject: [PATCH 4/6] =?UTF-8?q?=E2=9C=8F=EF=B8=8F=20Issue=20#37?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mowl/projection/edge.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mowl/projection/edge.py b/mowl/projection/edge.py index 429933c8..1c80cd37 100644 --- a/mowl/projection/edge.py +++ b/mowl/projection/edge.py @@ -1,5 +1,5 @@ from pykeen.triples import TriplesFactory -from deprecated.sphinx import versionadded, deprecated +from deprecated.sphinx import versionadded, deprecated, versionchanged import numpy as np import torch as th From 30d676fe4d4b6ac0d5b320774d055a82b293173a Mon Sep 17 00:00:00 2001 From: Fernando Zhapa-Camacho Date: Tue, 19 Nov 2024 22:19:18 +0300 Subject: [PATCH 5/6] =?UTF-8?q?=F0=9F=92=9A=20Constrain=20publishing=20to?= =?UTF-8?q?=20PyPi=20only=20when=20push=20or=20pull=20requests=20involve?= =?UTF-8?q?=20the=20main=20branch?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/python-publish.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/python-publish.yml b/.github/workflows/python-publish.yml index 380c5ea9..ced87e6b 100644 --- a/.github/workflows/python-publish.yml +++ b/.github/workflows/python-publish.yml @@ -2,7 +2,11 @@ name: Publish Python 🐍 distribution 📦 to PyPI and TestPyPI -on: push +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] jobs: build: From ffccdd8610ab4b40a7fa6bdd2e1cd36b4b7b98df Mon Sep 17 00:00:00 2001 From: Fernando Zhapa-Camacho Date: Tue, 19 Nov 2024 22:39:41 +0300 Subject: [PATCH 6/6] =?UTF-8?q?=F0=9F=90=9B=20Issue=20#37?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/projection/test_edge.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/projection/test_edge.py b/tests/projection/test_edge.py index 01bd5c91..1fe930a4 100644 --- a/tests/projection/test_edge.py +++ b/tests/projection/test_edge.py @@ -37,8 +37,8 @@ def test_get_ents_and_rels_method(self): ents, rels = Edge.get_entities_and_relations([edge1, edge2]) - self.assertEqual(ents, {"src1", "src2", "dst1", "dst2"}) - self.assertEqual(rels, {"rel1", "rel2"}) + self.assertEqual(ents, ["dst1", "dst2", "src1", "src2"]) + self.assertEqual(rels, ["rel1", "rel2"]) def test_zip_method(self): """This checks if Edge.zip method works correctly"""