Skip to content

Commit 4b97ed6

Browse files
authored
Merge pull request #769 from nipype/test_environments
Develop: fixes for test_environments
2 parents 099b0f4 + e6724c1 commit 4b97ed6

31 files changed

+1208
-1417
lines changed

.github/workflows/testdask.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ jobs:
2828
uses: actions/checkout@v4
2929
with:
3030
repository: ${{ github.repository }}
31-
31+
- name: Fetch tags
32+
run: git fetch --prune --unshallow
3233
- name: Setup Python version ${{ matrix.python-version }}
3334
uses: actions/setup-python@v5
3435
with:

.github/workflows/testpsijlocal.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ jobs:
2828
uses: actions/checkout@v4
2929
with:
3030
repository: ${{ github.repository }}
31-
31+
- name: Fetch tags
32+
run: git fetch --prune --unshallow
3233
- name: Setup Python version ${{ matrix.python-version }}
3334
uses: actions/setup-python@v5
3435
with:

.github/workflows/testpsijslurm.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ jobs:
2525
- name: Disable etelemetry
2626
run: echo "NO_ET=TRUE" >> $GITHUB_ENV
2727
- uses: actions/checkout@v4
28+
- name: Fetch tags
29+
run: git fetch --prune --unshallow
2830
- name: Pull docker image
2931
run: |
3032
docker pull $DOCKER_IMAGE
@@ -48,7 +50,7 @@ jobs:
4850
docker exec slurm bash -c "CONFIGURE_OPTS=\"-with-openssl=/opt/openssl\" pyenv install -v 3.11.5"
4951
fi
5052
docker exec slurm bash -c "pyenv global ${{ matrix.python-version }}"
51-
docker exec slurm bash -c "pip install --upgrade pip && pip install -e /pydra[test,psij] && python -c 'import pydra; print(pydra.__version__)'"
53+
docker exec slurm bash -c "pip install --upgrade pip && pip install -e /pydra[test,psij] && python -c 'import pydra.engine; print(pydra.engine.__version__)'"
5254
- name: Run pytest
5355
run: |
5456
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/ -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'"

.github/workflows/testpydra.yml

Lines changed: 6 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -52,74 +52,35 @@ jobs:
5252
matrix:
5353
os: [macos-latest, ubuntu-latest, windows-latest]
5454
python-version: ['3.11', '3.12', '3.13']
55-
install: ['wheel']
56-
include:
57-
- os: 'ubuntu-latest'
58-
python-version: '3.11'
59-
install: 'sdist'
60-
- os: 'ubuntu-latest'
61-
python-version: '3.11'
62-
install: 'repo'
63-
- os: 'ubuntu-latest'
64-
python-version: '3.11'
65-
install: 'archive'
6655
fail-fast: false
6756
runs-on: ${{ matrix.os }}
6857

6958

7059
steps:
71-
- name: Fetch sdist/wheel
72-
uses: actions/download-artifact@v4
73-
if: matrix.install == 'sdist' || matrix.install == 'wheel'
74-
with:
75-
name: dist
76-
path: dist/
77-
- name: Fetch git archive
78-
uses: actions/download-artifact@v4
79-
if: matrix.install == 'archive'
80-
with:
81-
name: archive
82-
path: archive/
8360
- name: Fetch repository
8461
uses: actions/checkout@v4
85-
if: matrix.install == 'repo'
86-
62+
- name: Fetch tags
63+
run: git fetch --prune --unshallow
8764
- name: Set up Python ${{ matrix.python-version }} on ${{ matrix.os }}
8865
uses: actions/setup-python@v5
8966
with:
9067
python-version: ${{ matrix.python-version }}
68+
9169
- name: Update pip
9270
run: python -m pip install --upgrade pip
9371

94-
- name: Determine installation target
95-
run: |
96-
if [[ "$INSTALL" = "sdist" ]]; then
97-
echo "ARCHIVE=$( ls dist/*.tar.gz )" >> $GITHUB_ENV
98-
elif [[ "$INSTALL" = "wheel" ]]; then
99-
echo "ARCHIVE=$( ls dist/*.whl )" >> $GITHUB_ENV
100-
elif [[ "$INSTALL" = "archive" ]]; then
101-
echo "ARCHIVE=$( ls archive/*.zip )" >> $GITHUB_ENV
102-
elif [[ "$INSTALL" = "repo" ]]; then
103-
echo "ARCHIVE=." >> $GITHUB_ENV
104-
fi
105-
env:
106-
INSTALL: ${{ matrix.install }}
107-
10872
- name: Install Pydra
109-
run: pip install $ARCHIVE
73+
run: pip install .[test]
11074

11175
- name: Print version
112-
run: python -c "import pydra; print(pydra.__version__)"
113-
114-
- name: Install Pydra tests dependencies
115-
run: pip install pydra[test]
76+
run: python -c "import pydra.engine; print(pydra.engine.__version__)"
11677

11778
- name: Disable etelemetry
11879
run: echo "NO_ET=TRUE" >> $GITHUB_ENV
11980

12081
- name: Pytest
12182
run: |
122-
pytest -vs -n auto --doctest-modules --pyargs pydra \
83+
pytest -vs -n auto --doctest-modules \
12384
--cov pydra --cov-config .coveragerc --cov-report xml:cov.xml
12485
12586
- name: Upload to codecov

.github/workflows/testsingularity.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ concurrency:
1414
jobs:
1515
build:
1616
name: Build
17-
runs-on: ubuntu-latest
17+
runs-on: ubuntu-22.04
1818
strategy:
1919
matrix:
2020
python-version: ['3.11', '3.12', '3.13']
@@ -65,11 +65,13 @@ jobs:
6565
uses: actions/checkout@v4
6666
with:
6767
repository: ${{ github.repository }}
68+
- name: Fetch tags
69+
run: git fetch --prune --unshallow
6870
- name: Install pydra (test)
6971
run: pip install -e ".[test]"
7072

7173

7274
- name: Pytest
73-
run: pytest -vs --cov pydra --cov-config .coveragerc --cov-report xml:cov.xml pydra/engine/tests/test_singularity.py
75+
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
7476
- name: Upload to codecov
7577
run: codecov -f cov.xml -F unittests -e GITHUB_WORKFLOW

.github/workflows/testslurm.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ jobs:
2525
- name: Disable etelemetry
2626
run: echo "NO_ET=TRUE" >> $GITHUB_ENV
2727
- uses: actions/checkout@v4
28+
- name: Fetch tags
29+
run: git fetch --prune --unshallow
2830
- name: Pull docker image
2931
run: |
3032
docker pull $DOCKER_IMAGE
@@ -48,7 +50,7 @@ jobs:
4850
docker exec slurm bash -c "CONFIGURE_OPTS=\"-with-openssl=/opt/openssl\" pyenv install -v 3.11.5"
4951
fi
5052
docker exec slurm bash -c "pyenv global ${{ matrix.python-version }}"
51-
docker exec slurm bash -c "pip install --upgrade pip && pip install -e /pydra[test] && python -c 'import pydra; print(pydra.__version__)'"
53+
docker exec slurm bash -c "pip install --upgrade pip && pip install -e /pydra[test] && python -c 'import pydra.engine; print(pydra.engine.__version__)'"
5254
- name: Run pytest
5355
run: |
5456
docker exec slurm bash -c "pytest --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'"

new-docs/source/tutorial/5-shell.ipynb

Lines changed: 62 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -109,11 +109,6 @@
109109
"print(trim_png.cmdline)"
110110
]
111111
},
112-
{
113-
"cell_type": "markdown",
114-
"metadata": {},
115-
"source": []
116-
},
117112
{
118113
"cell_type": "markdown",
119114
"metadata": {},
@@ -180,6 +175,68 @@
180175
"print(f\"'--int-arg' default: {fields_dict(Cp)['int_arg'].default}\")"
181176
]
182177
},
178+
{
179+
"cell_type": "markdown",
180+
"metadata": {},
181+
"source": [
182+
"## Path templates for output files\n",
183+
"\n",
184+
"By default, when an output file argument is defined, a `path_template` attribute will\n",
185+
"be assigned to the field based on its name and extension (if applicable). For example,\n",
186+
"the `zipped` output field in the following Gzip command will be assigned a\n",
187+
"`path_template` of `out_file.gz`"
188+
]
189+
},
190+
{
191+
"cell_type": "code",
192+
"execution_count": null,
193+
"metadata": {},
194+
"outputs": [],
195+
"source": [
196+
"from pydra.design import shell\n",
197+
"from fileformats.generic import File\n",
198+
"\n",
199+
"Gzip = shell.define(\"gzip <out|out_file:application/gzip> <in_files+>\")\n",
200+
"gzip = Gzip(in_files=File.mock(\"/a/file.txt\"))\n",
201+
"print(gzip.cmdline)"
202+
]
203+
},
204+
{
205+
"cell_type": "markdown",
206+
"metadata": {},
207+
"source": [
208+
"However, if this needs to be specified it can be by using the `$` operator, e.g."
209+
]
210+
},
211+
{
212+
"cell_type": "code",
213+
"execution_count": null,
214+
"metadata": {},
215+
"outputs": [],
216+
"source": [
217+
"Gzip = shell.define(\"gzip <out|out_file:application/gzip$zipped.gz> <in_files+>\")\n",
218+
"gzip = Gzip(in_files=File.mock(\"/a/file.txt\"))\n",
219+
"print(gzip.cmdline)"
220+
]
221+
},
222+
{
223+
"cell_type": "markdown",
224+
"metadata": {},
225+
"source": [
226+
"To give the field a path_template of `archive.gz` when it is written on the command line.\n",
227+
"Note that this value can always be overridden when the task is initialised, e.g."
228+
]
229+
},
230+
{
231+
"cell_type": "code",
232+
"execution_count": null,
233+
"metadata": {},
234+
"outputs": [],
235+
"source": [
236+
"gzip = Gzip(in_files=File.mock(\"/a/file.txt\"), out_file=\"/path/to/archive.gz\")\n",
237+
"print(gzip.cmdline)"
238+
]
239+
},
183240
{
184241
"cell_type": "markdown",
185242
"metadata": {},

pydra/design/boutiques.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
from functools import reduce
77
from fileformats.generic import File
88
from pydra.engine.specs import ShellDef
9-
from .base import make_task_def
10-
from . import shell
9+
from pydra.design.base import make_task_def
10+
from pydra.design import shell
1111

1212

1313
class arg(shell.arg):

pydra/design/python.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import inspect
33
from typing import dataclass_transform
44
import attrs
5-
from .base import (
5+
from pydra.design.base import (
66
Arg,
77
Out,
88
ensure_field_objects,

0 commit comments

Comments
 (0)