Skip to content

Commit 9be16ca

Browse files
authored
🔖 [Version 0.4.0: Goodbye Singularity Hub](https://github.com/FCP-INDI/cpac/releases/tag/v0.4.0) (#24)
2 parents 46af66e + aa393c3 commit 9be16ca

File tree

9 files changed

+52
-21
lines changed

9 files changed

+52
-21
lines changed

.github/workflows/test_cpac.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ on:
88
paths-ignore:
99
- README.rst
1010
pull_request:
11-
pull_request_target:
1211

1312
jobs:
1413
test_cpac:
@@ -33,9 +32,11 @@ jobs:
3332
with:
3433
go-version: ${{ matrix.go }}
3534
- name: Set up Python
36-
uses: actions/setup-python@v1
35+
uses: actions/setup-python@v2
3736
with:
3837
python-version: ${{ matrix.python }}
38+
- name: Install --upgrade pip setuptools wheel
39+
run: python -m pip install --upgrade pip setuptools wheel
3940
- name: Set up Singularity
4041
if: ${{ matrix.platform == 'singularity' }}
4142
uses: eWaterCycle/setup-singularity@v5

CHANGELOG.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
=========
22
Changelog
33
=========
4+
`Version 0.4.0: Goodbye Singularity Hub <https://github.com/FCP-INDI/cpac/releases/tag/v0.4.0>`_
5+
================================================================================================
6+
* 👽 Drop call to now-deprecated Singularity Hub
7+
* 🐛 Resolves issue where minimal configs would cause wrapper to crash
8+
49
`Version 0.3.2: Pull / Upgrade <https://github.com/FCP-INDI/cpac/releases/tag/v0.3.2>`_
510
========================================================================================
611
* ➖ Remove dependecy on Nipype

README.rst

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@ Usage
2929
.. code-block:: shell
3030
3131
cpac --help
32-
usage: cpac [-h] [--version] [-o [OPT [OPT ...]]]
33-
[-B [CUSTOM_BINDING [CUSTOM_BINDING ...]]]
32+
usage: cpac [-h] [--version] [-o OPT] [-B CUSTOM_BINDING]
3433
[--platform {docker,singularity}] [--image IMAGE] [--tag TAG]
3534
[--working_dir PATH] [-v] [-vv]
3635
{run,group,utils,pull,upgrade,crash} ...
@@ -64,13 +63,13 @@ Usage
6463
optional arguments:
6564
-h, --help show this help message and exit
6665
--version show program's version number and exit
67-
-o [OPT [OPT ...]], --container_option [OPT [OPT ...]]
66+
-o OPT, --container_option OPT
6867
parameters and flags to pass through to Docker or Singularity
6968
7069
This flag can take multiple arguments so cannot be
7170
the final argument before the command argument (i.e.,
7271
run or any other command that does not start with - or --)
73-
-B [CUSTOM_BINDING [CUSTOM_BINDING ...]], --custom_binding [CUSTOM_BINDING [CUSTOM_BINDING ...]]
72+
-B CUSTOM_BINDING, --custom_binding CUSTOM_BINDING
7473
directories to bind with a different path in
7574
the container than the real path of the directory.
7675
One or more pairs in the format:

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ classifiers =
2323
Operating System :: OS Independent
2424
Programming Language :: Python :: 3
2525
Topic :: Scientific/Engineering :: Bio-Informatics
26-
version = 0.3.2.post1
26+
version = 0.4.0
2727

2828
[options]
2929
zip_safe = False

src/cpac/backends/platform.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from contextlib import redirect_stderr
1010
from io import StringIO
1111
from tabulate import tabulate
12+
from warnings import warn
1213

1314
from cpac.helpers import cpac_read_crash, get_extra_arg_value
1415
from cpac.utils import Locals_to_bind, PermissionMode
@@ -83,6 +84,7 @@ def _bind_volume(self, local, remote, mode):
8384
self.volumes[local] = [b]
8485

8586
def _collect_config_binding(self, config, config_key):
87+
config_binding = None
8688
if isinstance(config, str):
8789
if os.path.exists(config):
8890
path = os.path.dirname(config)
@@ -93,7 +95,21 @@ def _collect_config_binding(self, config, config_key):
9395
f'yaml.dump(Configuration({config}).dict())"'
9496
)
9597
config = yaml.safe_load(config)
96-
return config.get('pipeline_setup', {}).get(config_key, {}).get('path')
98+
pipeline_setup = config.get('pipeline_setup', {})
99+
minimal = pipeline_setup.get('FROM', False)
100+
if isinstance(pipeline_setup, dict):
101+
config_binding = pipeline_setup.get(config_key, {}).get('path')
102+
else:
103+
minimal = True
104+
if minimal:
105+
warn(
106+
'This run is using a minimal pipeline configuration. If this '
107+
'configuration imports a configuration that requires paths to '
108+
'be bound from your real environment to your container, you '
109+
'need to bind those paths manually with the `-B` flag.',
110+
UserWarning
111+
)
112+
return config_binding
97113

98114
def collect_config_bindings(self, config, **kwargs):
99115
kwargs['output_dir'] = kwargs.get(

src/cpac/backends/singularity.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -68,19 +68,12 @@ def pull(self, force=False, **kwargs):
6868
else: # pragma: no cover
6969
try:
7070
self.image = Client.pull(
71-
"shub://FCP-INDI/C-PAC",
71+
"docker://fcpindi/c-pac:latest",
7272
force=force,
7373
pull_folder=pwd
7474
)
7575
except Exception:
76-
try:
77-
self.image = Client.pull(
78-
"docker://fcpindi/c-pac:latest",
79-
force=force,
80-
pull_folder=pwd
81-
)
82-
except Exception:
83-
raise OSError("Could not connect to Singularity")
76+
raise OSError("Could not connect to Singularity")
8477

8578
def _try_to_stream(self, args, stream_command='run', **kwargs):
8679
self._bindings_as_option()

tests/test_cpac_installation.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
from pip._internal.utils.misc import get_installed_distributions
1+
"""Test if cpac is installed as expected"""
2+
from pkg_resources import working_set
23
from setuptools.config import read_configuration
34

45

@@ -22,7 +23,7 @@ def test_requirements():
2223
'but not in setup.cfg'
2324
)
2425
assert package_in_list(
25-
req, requirements_list(get_installed_distributions())
26+
req, requirements_list(working_set)
2627
), (
2728
f'package {req} is in requirements.txt '
2829
'but not installed'

tests/test_cpac_run.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88
from cpac.__main__ import run
99
from CONSTANTS import args_before_after, set_commandline_args
1010

11+
MINIMAL_CONFIG = os.path.join(
12+
os.path.dirname(__file__), 'test_data', 'minimal.min.yml'
13+
)
14+
1115

1216
@pytest.mark.parametrize('helpflag', ['--help', '-h'])
1317
@pytest.mark.parametrize('argsep', [' ', '='])
@@ -32,7 +36,10 @@ def run_test(argv):
3236

3337

3438
@pytest.mark.parametrize('argsep', [' ', '='])
35-
def test_run_test_config(argsep, tmp_path, platform=None, tag=None):
39+
@pytest.mark.parametrize('pipeline_file', [None, MINIMAL_CONFIG])
40+
def test_run_test_config(
41+
argsep, pipeline_file, tmp_path, platform=None, tag=None
42+
):
3643
def run_test(argv):
3744
with mock.patch.object(sys, 'argv', argv):
3845
run()
@@ -42,10 +49,14 @@ def run_test(argv):
4249

4350
wd = tmp_path
4451
args = set_commandline_args(platform, tag, argsep)
52+
pipeline = '' if pipeline_file is None else ' '.join([
53+
' --pipeline_file',
54+
pipeline_file
55+
])
4556
argv = (
4657
'run '
4758
f's3://fcp-indi/data/Projects/ABIDE/RawDataBIDS/NYU {wd} '
48-
'test_config --participant_ndx=2'
59+
f'test_config --participant_ndx=2{pipeline}'
4960
)
5061
if len(args):
5162
before, after = args_before_after(argv, args)

tests/test_data/minimal.min.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
FROM: default
2+
3+
pipeline_setup:
4+
5+
pipeline_name: test-minimal-imports

0 commit comments

Comments
 (0)