Skip to content

Commit 2582af9

Browse files
authored
Merge pull request #210 from ResearchObject/optional_gen_cwl
Make Galaxy to CWL workflow conversion optional
2 parents 458baa3 + 6dc5e63 commit 2582af9

File tree

5 files changed

+35
-6
lines changed

5 files changed

+35
-6
lines changed

.github/workflows/python-package.yml

+20-4
Original file line numberDiff line numberDiff line change
@@ -24,19 +24,35 @@ jobs:
2424
runs-on: ${{ matrix.os }}
2525

2626
steps:
27-
- uses: actions/checkout@v2
27+
- uses: actions/checkout@v4
2828
- name: Set up Python ${{ matrix.python-version }}
29-
uses: actions/setup-python@v2
29+
uses: actions/setup-python@v5
3030
with:
3131
python-version: ${{ matrix.python-version }}
32-
- name: Install dependencies
32+
- name: Install
3333
run: |
3434
python -m pip install --upgrade pip
35+
pip install -e .
3536
pip install flake8 pytest
36-
pip install -r requirements.txt
3737
- name: Lint with flake8
3838
run: |
3939
flake8 -v .
4040
- name: Test
4141
run: |
4242
pytest -v test
43+
check-ga2cwl:
44+
runs-on: ubuntu-latest
45+
steps:
46+
- uses: actions/checkout@v4
47+
- name: Set up Python 3.12
48+
uses: actions/setup-python@v5
49+
with:
50+
python-version: '3.12'
51+
- name: Install
52+
run: |
53+
python -m pip install --upgrade pip
54+
pip install -e .[ga2cwl]
55+
pip install pytest
56+
- name: Test
57+
run: |
58+
pytest -v test

requirements.txt

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
requests
22
arcp==0.2.1
3-
galaxy2cwl
43
jinja2
54
python-dateutil
65
click

rocrate/model/computationalworkflow.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
import os
2525
import tempfile
2626
from contextlib import redirect_stdout
27-
from galaxy2cwl import get_cwl_interface
2827

2928
from .file import File
3029

@@ -76,6 +75,10 @@ class Workflow(ComputationalWorkflow):
7675

7776

7877
def galaxy_to_abstract_cwl(workflow_path, delete=True):
78+
try:
79+
from galaxy2cwl import get_cwl_interface
80+
except ImportError:
81+
raise RuntimeError("conversion to cwl not available: package was not installed with the 'ga2cwl' option")
7982
with tempfile.NamedTemporaryFile(mode='w', delete=False, suffix=".cwl") as f:
8083
with redirect_stdout(f):
8184
get_cwl_interface.main(['1', str(workflow_path)])

setup.py

+3
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,9 @@
8282
f'{__version__}.tar.gz'),
8383
keywords="researchobject ro-crate ro metadata jsonld",
8484
install_requires=[required],
85+
extras_require={
86+
'ga2cwl': ['galaxy2cwl'],
87+
},
8588
classifiers=[
8689
'Operating System :: OS Independent',
8790
'Development Status :: 3 - Alpha',

test/test_workflow_ro_crate.py

+8
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,17 @@
2121
import pytest
2222

2323
from rocrate.rocrate import ROCrate, make_workflow_rocrate
24+
try:
25+
import galaxy2cwl # noqa: F401
26+
except ImportError:
27+
CAN_CONVERT_TO_CWL = False
28+
else:
29+
CAN_CONVERT_TO_CWL = True
2430

2531
WF_CRATE = "https://w3id.org/workflowhub/workflow-ro-crate"
2632

2733

34+
@pytest.mark.skipif(not CAN_CONVERT_TO_CWL, reason="cwl gen not enabled")
2835
def test_galaxy_wf_crate(test_data_dir, tmpdir, helpers):
2936
wf_id = 'test_galaxy_wf.ga'
3037
wf_path = test_data_dir / wf_id
@@ -87,6 +94,7 @@ def test_cwl_wf_crate(test_data_dir, tmpdir, helpers):
8794
assert f1.read() == f2.read()
8895

8996

97+
@pytest.mark.skipif(not CAN_CONVERT_TO_CWL, reason="cwl gen not enabled")
9098
def test_create_wf_include(test_data_dir, tmpdir, helpers):
9199
wf_id = 'test_galaxy_wf.ga'
92100
wf_path = test_data_dir / wf_id

0 commit comments

Comments
 (0)