Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make Galaxy to CWL workflow conversion optional #210

Merged
merged 3 commits into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 20 additions & 4 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,35 @@ 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
- name: Install
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 .
- 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
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
requests
arcp==0.2.1
galaxy2cwl
jinja2
python-dateutil
click
5 changes: 4 additions & 1 deletion rocrate/model/computationalworkflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import os
import tempfile
from contextlib import redirect_stdout
from galaxy2cwl import get_cwl_interface

from .file import File

Expand Down Expand Up @@ -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)])
Expand Down
3 changes: 3 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
8 changes: 8 additions & 0 deletions test/test_workflow_ro_crate.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Loading