From 1e3682373cb0ad7c2bd659df11f0f614cb13a65c Mon Sep 17 00:00:00 2001 From: simleo Date: Fri, 20 Dec 2024 11:45:56 +0100 Subject: [PATCH 1/3] make galaxy to cwl conversion optional --- requirements.txt | 1 - rocrate/model/computationalworkflow.py | 5 ++++- setup.py | 3 +++ test/test_workflow_ro_crate.py | 8 ++++++++ 4 files changed, 15 insertions(+), 2 deletions(-) diff --git a/requirements.txt b/requirements.txt index 69b8447..6f3749b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,5 @@ requests arcp==0.2.1 -galaxy2cwl jinja2 python-dateutil click diff --git a/rocrate/model/computationalworkflow.py b/rocrate/model/computationalworkflow.py index 233d2a7..1ca9377 100644 --- a/rocrate/model/computationalworkflow.py +++ b/rocrate/model/computationalworkflow.py @@ -24,7 +24,6 @@ import os import tempfile from contextlib import redirect_stdout -from galaxy2cwl import get_cwl_interface from .file import File @@ -76,6 +75,10 @@ class Workflow(ComputationalWorkflow): def galaxy_to_abstract_cwl(workflow_path, delete=True): + try: + from galaxy2cwl import get_cwl_interface + except ImportError: + raise RuntimeError("conversion to cwl not available: package was not installed with the 'ga2cwl' option") with tempfile.NamedTemporaryFile(mode='w', delete=False, suffix=".cwl") as f: with redirect_stdout(f): get_cwl_interface.main(['1', str(workflow_path)]) diff --git a/setup.py b/setup.py index bd7b6d6..c4fc123 100755 --- a/setup.py +++ b/setup.py @@ -82,6 +82,9 @@ f'{__version__}.tar.gz'), keywords="researchobject ro-crate ro metadata jsonld", install_requires=[required], + extras_require={ + 'ga2cwl': ['galaxy2cwl'], + }, classifiers=[ 'Operating System :: OS Independent', 'Development Status :: 3 - Alpha', diff --git a/test/test_workflow_ro_crate.py b/test/test_workflow_ro_crate.py index 7b2e566..eb4f547 100644 --- a/test/test_workflow_ro_crate.py +++ b/test/test_workflow_ro_crate.py @@ -21,10 +21,17 @@ import pytest from rocrate.rocrate import ROCrate, make_workflow_rocrate +try: + import galaxy2cwl # noqa: F401 +except ImportError: + CAN_CONVERT_TO_CWL = False +else: + CAN_CONVERT_TO_CWL = True WF_CRATE = "https://w3id.org/workflowhub/workflow-ro-crate" +@pytest.mark.skipif(not CAN_CONVERT_TO_CWL, reason="cwl gen not enabled") def test_galaxy_wf_crate(test_data_dir, tmpdir, helpers): wf_id = 'test_galaxy_wf.ga' wf_path = test_data_dir / wf_id @@ -87,6 +94,7 @@ def test_cwl_wf_crate(test_data_dir, tmpdir, helpers): assert f1.read() == f2.read() +@pytest.mark.skipif(not CAN_CONVERT_TO_CWL, reason="cwl gen not enabled") def test_create_wf_include(test_data_dir, tmpdir, helpers): wf_id = 'test_galaxy_wf.ga' wf_path = test_data_dir / wf_id From 163a2b5ae939084acf697876c07d3ddcd63a2757 Mon Sep 17 00:00:00 2001 From: simleo Date: Fri, 20 Dec 2024 12:28:17 +0100 Subject: [PATCH 2/3] update ci workflow --- .github/workflows/python-package.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index 1dff7a4..02e4231 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -24,16 +24,16 @@ jobs: runs-on: ${{ matrix.os }} steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - name: Install dependencies run: | python -m pip install --upgrade pip + pip install -e . pip install flake8 pytest - pip install -r requirements.txt - name: Lint with flake8 run: | flake8 -v . From 6dc5e630e855328b7c75281fcfcde89b1e8826b7 Mon Sep 17 00:00:00 2001 From: simleo Date: Fri, 20 Dec 2024 12:46:47 +0100 Subject: [PATCH 3/3] ci workflow: add check for ga2cwl --- .github/workflows/python-package.yml | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index 02e4231..88f9ebb 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -29,7 +29,7 @@ jobs: uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - - name: Install dependencies + - name: Install run: | python -m pip install --upgrade pip pip install -e . @@ -40,3 +40,19 @@ jobs: - name: Test run: | pytest -v test + check-ga2cwl: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Set up Python 3.12 + uses: actions/setup-python@v5 + with: + python-version: '3.12' + - name: Install + run: | + python -m pip install --upgrade pip + pip install -e .[ga2cwl] + pip install pytest + - name: Test + run: | + pytest -v test