Skip to content

Commit 4176284

Browse files
committed
simplifying test job structure, avoiding duplicate test runs between jobs
1 parent cde9d13 commit 4176284

File tree

17 files changed

+680
-847
lines changed

17 files changed

+680
-847
lines changed

.github/workflows/ci-cd.yml

Lines changed: 37 additions & 142 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,36 @@ jobs:
5555
fail-fast: false
5656
runs-on: ${{ matrix.os }}
5757
steps:
58+
- name: Set env for singularity
59+
run: echo "RELEASE_VERSION=v3.7.1" >> $GITHUB_ENV
60+
- name: Disable etelemetry
61+
run: echo "NO_ET=TRUE" >> $GITHUB_ENV
62+
- name: Setup Singularity
63+
uses: actions/checkout@v4
64+
with:
65+
repository: hpcng/singularity
66+
ref: 'v3.7.1'
67+
path: 'singularity'
68+
- name: Setup GO
69+
uses: actions/setup-go@v5
70+
with:
71+
go-version: '^1.13'
72+
- name: Install OS deps
73+
run: |
74+
sudo apt-get update
75+
sudo apt-get install flawfinder squashfs-tools uuid-dev libuuid1 libffi-dev libssl-dev libssl1.1 \
76+
libarchive-dev libgpgme11-dev libseccomp-dev wget gcc make pkg-config -y
77+
- name: Build
78+
run: |
79+
cd singularity
80+
./mconfig --without-suid -p /usr/local/
81+
make -C ./builddir
82+
sudo make -C ./builddir install
83+
cd ..
84+
- name: Echo singularity version
85+
run: |
86+
echo ${{ github.ref }}
87+
singularity --version
5888
- name: Fetch repository
5989
uses: actions/checkout@v4
6090
- name: Fetch tags
@@ -66,14 +96,12 @@ jobs:
6696
- name: Update pip
6797
run: python -m pip install --upgrade pip
6898
- name: Install Pydra
69-
run: pip install .[test]
99+
run: pip install .[test,psij,dask]
70100
- name: Print version
71101
run: python -c "import pydra.engine; print(pydra.engine.__version__)"
72-
- name: Disable etelemetry
73-
run: echo "NO_ET=TRUE" >> $GITHUB_ENV
74102
- name: Pytest
75103
run: |
76-
pytest -vs -n auto pydra --doctest-modules --cov pydra --cov-config .coveragerc --cov-report xml:cov.xml
104+
pytest -vs -n auto pydra --doctest-modules --with-psij --cov pydra --cov-config .coveragerc --cov-report xml:cov.xml
77105
- name: Upload to codecov
78106
run: codecov -f cov.xml -F unittests -e GITHUB_WORKFLOW
79107

@@ -101,148 +129,15 @@ jobs:
101129
pip install -e ".[test,dask]"
102130
- name: Run tests for Dask
103131
run: |
104-
pytest -v --dask pydra/engine --cov pydra --cov-config .coveragerc --cov-report xml:cov.xml
105-
- name: Upload to codecov
106-
run: codecov -f cov.xml -F unittests -e GITHUB_WORKFLOW
107-
108-
test-psijlocal:
109-
needs: ['build']
110-
strategy:
111-
matrix:
112-
os: [ubuntu-latest, macos-latest]
113-
python-version: ['3.11']
114-
fail-fast: false
115-
runs-on: ${{ matrix.os }}
116-
steps:
117-
- name: Checkout repository
118-
uses: actions/checkout@v4
119-
with:
120-
repository: ${{ github.repository }}
121-
- name: Fetch tags
122-
run: git fetch --prune --unshallow
123-
- name: Setup Python version ${{ matrix.python-version }}
124-
uses: actions/setup-python@v5
125-
with:
126-
python-version: ${{ matrix.python-version }}
127-
- name: Install dependencies for PSI/J
128-
run: |
129-
pip install -e ".[test, psij]"
130-
- name: Run tests for PSI/J
131-
run: |
132-
pytest --color=yes -vs --psij=local -n auto pydra/engine --cov pydra --cov-config .coveragerc --cov-report xml:cov.xml
133-
- name: Upload to codecov
134-
run: codecov -f cov.xml -F unittests -e GITHUB_WORKFLOW
135-
136-
test-psijslurm:
137-
needs: ['build']
138-
strategy:
139-
matrix:
140-
python-version: [3.11.5]
141-
fail-fast: false
142-
runs-on: ubuntu-latest
143-
env:
144-
DOCKER_IMAGE: adi611/docker-centos7-slurm:23.02.1
145-
steps:
146-
- name: Disable etelemetry
147-
run: echo "NO_ET=TRUE" >> $GITHUB_ENV
148-
- uses: actions/checkout@v4
149-
- name: Fetch tags
150-
run: git fetch --prune --unshallow
151-
- name: Pull docker image
152-
run: |
153-
docker pull $DOCKER_IMAGE
154-
# Have image running in the background
155-
docker run `bash <(curl -s https://codecov.io/env)` -itd -h slurmctl --cap-add sys_admin -d --name slurm -v `pwd`:/pydra -e NO_ET=$NO_ET $DOCKER_IMAGE
156-
- name: Display previous jobs with sacct
157-
run: |
158-
echo "Allowing ports/daemons time to start" && sleep 10
159-
docker exec slurm bash -c "sacctmgr -i add account none,test Cluster=linux Description='none' Organization='none'"
160-
docker exec slurm bash -c "sacct && sinfo && squeue" 2&> /dev/null
161-
if [ $? -ne 0 ]; then
162-
echo "Slurm docker image error"
163-
exit 1
164-
fi
165-
- name: Setup Python
166-
run: |
167-
docker exec slurm bash -c "echo $NO_ET"
168-
docker exec slurm bash -c "ls -la && echo list top level dir"
169-
docker exec slurm bash -c "ls -la /pydra && echo list pydra dir"
170-
if [[ "${{ matrix.python-version }}" == "3.11.5" ]]; then
171-
docker exec slurm bash -c "CONFIGURE_OPTS=\"-with-openssl=/opt/openssl\" pyenv install -v 3.11.5"
172-
fi
173-
docker exec slurm bash -c "pyenv global ${{ matrix.python-version }}"
174-
docker exec slurm bash -c "pip install --upgrade pip && pip install -e /pydra[test,psij] && python -c 'import pydra.engine; print(pydra.engine.__version__)'"
175-
- name: Run pytest
176-
run: |
177-
docker exec slurm bash -c "pytest --color=yes -vs -n auto --psij=slurm --cov pydra --cov-config /pydra/.coveragerc --cov-report xml:/pydra/cov.xml --doctest-modules /pydra/pydra/engine/tests/test_workflow.py /pydra/pydra/engine/tests/test_submitter.py /pydra/pydra/engine/tests/test_node_task.py -k 'not test_audit_prov and not test_audit_prov_messdir_1 and not test_audit_prov_messdir_2 and not test_audit_prov_wf and not test_audit_all'"
178-
- name: Upload to codecov
179-
run: |
180-
docker exec slurm bash -c "pip install urllib3==1.26.6"
181-
docker exec slurm bash -c "codecov --root /pydra -f /pydra/cov.xml -F unittests"
182-
docker rm -f slurm
183-
184-
test-singularity:
185-
needs: ['build']
186-
runs-on: ubuntu-22.04
187-
strategy:
188-
matrix:
189-
python-version: ['3.11', '3.12', '3.13']
190-
fail-fast: False
191-
steps:
192-
- name: Set env
193-
run: |
194-
echo "RELEASE_VERSION=v3.7.1" >> $GITHUB_ENV
195-
echo "NO_ET=TRUE" >> $GITHUB_ENV
196-
- name: Setup Singularity
197-
uses: actions/checkout@v4
198-
with:
199-
repository: hpcng/singularity
200-
ref: 'v3.7.1'
201-
path: 'singularity'
202-
- name: Setup GO
203-
uses: actions/setup-go@v5
204-
with:
205-
go-version: '^1.13'
206-
- name: Install OS deps
207-
run: |
208-
sudo apt-get update
209-
sudo apt-get install flawfinder squashfs-tools uuid-dev libuuid1 libffi-dev libssl-dev libssl1.1 \
210-
libarchive-dev libgpgme11-dev libseccomp-dev wget gcc make pkg-config -y
211-
- name: Build
212-
run: |
213-
cd singularity
214-
./mconfig --without-suid -p /usr/local/
215-
make -C ./builddir
216-
sudo make -C ./builddir install
217-
cd ..
218-
- name: Echo singularity version
219-
run: |
220-
echo ${{ github.ref }}
221-
singularity --version
222-
- name: Set up Python ${{ matrix.python-version }}
223-
uses: actions/setup-python@v5
224-
with:
225-
python-version: ${{ matrix.python-version }}
226-
- name: Update build tools
227-
run: python -m pip install --upgrade pip
228-
- name: Checkout Pydra repo
229-
uses: actions/checkout@v4
230-
with:
231-
repository: ${{ github.repository }}
232-
- name: Fetch tags
233-
run: git fetch --prune --unshallow
234-
- name: Install pydra (test)
235-
run: pip install -e ".[test]"
236-
- name: Pytest
237-
run: pytest -vs --cov pydra --cov-config .coveragerc --cov-report xml:cov.xml pydra/engine/tests/test_singularity.py pydra/engine/tests/test_environments.py
132+
pytest -v --dask pydra/engine/test_submitter.py --cov pydra --cov-config .coveragerc --cov-report xml:cov.xml
238133
- name: Upload to codecov
239134
run: codecov -f cov.xml -F unittests -e GITHUB_WORKFLOW
240135

241136
test-slurm:
242137
needs: ['build']
243138
strategy:
244139
matrix:
245-
python-version: [3.11.5]
140+
python-version: [3.11.7]
246141
fail-fast: false
247142
runs-on: ubuntu-latest
248143
env:
@@ -276,10 +171,10 @@ jobs:
276171
docker exec slurm bash -c "CONFIGURE_OPTS=\"-with-openssl=/opt/openssl\" pyenv install -v 3.11.5"
277172
fi
278173
docker exec slurm bash -c "pyenv global ${{ matrix.python-version }}"
279-
docker exec slurm bash -c "pip install --upgrade pip && pip install -e /pydra[test] && python -c 'import pydra.engine; print(pydra.engine.__version__)'"
174+
docker exec slurm bash -c "pip install --upgrade pip && pip install -e /pydra[test,psij] && python -c 'import pydra.engine; print(pydra.engine.__version__)'"
280175
- name: Run pytest
281176
run: |
282-
docker exec slurm bash -c "pytest /pydra/pydra/engine/tests/test_workflow.py /pydra/pydra/engine/tests/test_submitter.py /pydra/pydra/engine/tests/test_node_task.py --color=yes -vs --cov pydra --cov-config /pydra/.coveragerc --cov-report xml:/pydra/cov.xml --doctest-modules /pydra/pydra/ -k 'not test_audit_prov and not test_audit_prov_messdir_1 and not test_audit_prov_messdir_2 and not test_audit_prov_wf and not test_audit_all'"
177+
docker exec slurm bash -c "pytest /pydra/pydra/engine/tests/test_submitter.py --with-psij --color=yes -vs --cov pydra --cov-config /pydra/.coveragerc --cov-report xml:/pydra/cov.xml --doctest-modules /pydra/pydra/"
283178
- name: Upload to codecov
284179
run: |
285180
docker exec slurm bash -c "pip install urllib3==1.26.6"
@@ -357,7 +252,7 @@ jobs:
357252
path: docs/build/html
358253

359254
deploy:
360-
needs: [build-docs, test, test-dask, test-psijlocal, test-psijslurm, test-singularity, test-slurm]
255+
needs: [build-docs, test, test-dask, test-slurm]
361256
runs-on: ubuntu-latest
362257
steps:
363258
- name: Download dist

docs/source/explanation/environments.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ construction, and allows tasks to be run in environments that are isolated from
77
host system, and that have specific software dependencies.
88

99
The environment a task runs within is specified by the ``environment`` argument passed
10-
to the execution call (e.g. ``my_task(plugin="cf", environment="docker")``) or in the
10+
to the execution call (e.g. ``my_task(worker="cf", environment="docker")``) or in the
1111
``workflow.add()`` call in workflow constructors.
1212

1313
Specifying at execution

docs/tst.py

Lines changed: 0 additions & 14 deletions
This file was deleted.

pydra/conftest.py

Lines changed: 18 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -8,69 +8,35 @@
88
def pytest_addoption(parser):
99
parser.addoption("--dask", action="store_true", help="run all combinations")
1010
parser.addoption(
11-
"--psij",
12-
action="store",
13-
help="run with psij subtype plugin",
14-
choices=["local", "slurm"],
11+
"--with-psij",
12+
action="store_true",
13+
help="run with psij workers in test matrix",
1514
)
1615

1716

1817
def pytest_generate_tests(metafunc):
19-
if "plugin_dask_opt" in metafunc.fixturenames:
20-
if bool(shutil.which("sbatch")):
21-
Plugins = ["slurm"]
22-
else:
23-
Plugins = ["debug", "cf"]
24-
try:
25-
if metafunc.config.getoption("dask"):
26-
Plugins = ["dask"]
27-
except ValueError:
28-
# Called as --pyargs, so --dask isn't available
29-
pass
30-
try:
31-
if metafunc.config.getoption("psij"):
32-
Plugins = ["psij-" + metafunc.config.getoption("psij")]
33-
except ValueError:
34-
pass
35-
metafunc.parametrize("plugin_dask_opt", Plugins)
18+
if "worker" in metafunc.fixturenames:
19+
metafunc.parametrize("worker", ["debug", "cf"])
3620

37-
if "plugin" in metafunc.fixturenames:
38-
use_dask = False
21+
if "any_worker" in metafunc.fixturenames:
22+
available_workers = ["debug", "cf"]
3923
try:
4024
use_dask = metafunc.config.getoption("dask")
4125
except ValueError:
42-
pass
43-
if use_dask:
44-
Plugins = []
45-
elif bool(shutil.which("sbatch")):
46-
Plugins = ["slurm"]
47-
else:
48-
Plugins = ["debug", "cf"]
26+
use_dask = False
4927
try:
50-
if metafunc.config.getoption("psij"):
51-
Plugins = ["psij-" + metafunc.config.getoption("psij")]
28+
use_psij = metafunc.config.getoption("with-psij")
5229
except ValueError:
53-
pass
54-
metafunc.parametrize("plugin", Plugins)
55-
56-
if "plugin_parallel" in metafunc.fixturenames:
57-
use_dask = False
58-
try:
59-
use_dask = metafunc.config.getoption("dask")
60-
except ValueError:
61-
pass
30+
use_psij = False
6231
if use_dask:
63-
Plugins = []
64-
elif bool(shutil.which("sbatch")):
65-
Plugins = ["slurm"]
66-
else:
67-
Plugins = ["cf"]
68-
try:
69-
if metafunc.config.getoption("psij"):
70-
Plugins = ["psij-" + metafunc.config.getoption("psij")]
71-
except ValueError:
72-
pass
73-
metafunc.parametrize("plugin_parallel", Plugins)
32+
available_workers.append("dask")
33+
if bool(shutil.which("sbatch")):
34+
available_workers.append("slurm")
35+
if use_psij:
36+
available_workers.append("psij-slurm")
37+
if use_psij:
38+
available_workers.append("psij-local")
39+
metafunc.parametrize("any_worker", available_workers)
7440

7541

7642
# For debugging in IDE's don't catch raised exceptions and let the IDE

pydra/engine/submitter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ def __init__(
139139
worker_cls = WORKERS[self.worker_name]
140140
except KeyError:
141141
raise NotImplementedError(
142-
f"No worker for '{self.worker_name}' plugin"
142+
f"No worker for '{self.worker_name}' worker"
143143
)
144144
else:
145145
try:

pydra/engine/tests/test_boutiques.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@
2323
"maskfile", ["test_brain.nii.gz", "test_brain", "test_brain.nii"]
2424
)
2525
@pytest.mark.parametrize("results_function", [run_no_submitter, run_submitter])
26-
def test_boutiques_1(maskfile, plugin, results_function, tmpdir, data_tests_dir):
26+
def test_boutiques_1(maskfile, worker, results_function, tmpdir, data_tests_dir):
2727
"""simple task to run fsl.bet using BoshTask"""
2828
btask = boutiques.define(zenodo_id="1482743")
2929
btask.infile = data_tests_dir / "test.nii.gz"
3030
btask.maskfile = maskfile
31-
res = btask(plugin, cache_dir=tmpdir)
31+
res = btask(worker, cache_dir=tmpdir)
3232

3333
assert res.output.return_code == 0
3434

@@ -92,7 +92,7 @@ def test_boutiques_spec_2(data_tests_dir):
9292
@pytest.mark.parametrize(
9393
"maskfile", ["test_brain.nii.gz", "test_brain", "test_brain.nii"]
9494
)
95-
def test_boutiques_wf_1(maskfile, plugin, tmpdir, infile):
95+
def test_boutiques_wf_1(maskfile, worker, tmpdir, infile):
9696
"""wf with one task that runs fsl.bet using BoshTask"""
9797

9898
@workflow.define
@@ -107,7 +107,7 @@ def Workflow(maskfile, infile):
107107
return bet.outfile
108108

109109
wf = Workflow(maskfile=maskfile, infile=infile)
110-
wf(plugin=plugin, cache_dir=tmpdir)
110+
wf(worker=worker, cache_dir=tmpdir)
111111

112112
res = wf.result()
113113
assert res.output.outfile.name == "test_brain.nii.gz"
@@ -121,7 +121,7 @@ def Workflow(maskfile, infile):
121121
@pytest.mark.parametrize(
122122
"maskfile", ["test_brain.nii.gz", "test_brain", "test_brain.nii"]
123123
)
124-
def test_boutiques_wf_2(maskfile, plugin, tmpdir, infile):
124+
def test_boutiques_wf_2(maskfile, worker, tmpdir, infile):
125125
"""wf with two BoshTasks (fsl.bet and fsl.stats) and one ShellTask"""
126126

127127
@workflow.define(outputs=["outfile_bet", "out_stat", "out"])
@@ -143,7 +143,7 @@ def Workflow(maskfile, infile):
143143
cat = workflow.add(shell.define("cat <file>")(file=stat.output))
144144
return bet.outfile, stat.output, cat.stdout
145145

146-
res = Workflow(maskfile=maskfile, infile=infile)(plugin=plugin, cache_dir=tmpdir)
146+
res = Workflow(maskfile=maskfile, infile=infile)(worker=worker, cache_dir=tmpdir)
147147
assert res.output.outfile_bet.name == "test_brain.nii.gz"
148148
assert res.output.outfile_bet.exists()
149149

0 commit comments

Comments
 (0)