Skip to content

Commit d7e6b62

Browse files
authored
Merge pull request #157 from djarecka/singularity
I've checked it on openmind
2 parents d40669a + 40fe321 commit d7e6b62

File tree

8 files changed

+963
-23
lines changed

8 files changed

+963
-23
lines changed

.travis.yml

+7-3
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ env:
2626
- INSTALL_TYPE="sdist"
2727
- INSTALL_TYPE="wheel"
2828
- INSTALL_DEPENDS="pip==18.1 setuptools==30.2.1"
29-
- INSTALL_DEPENDS="pip==10.0.1 setuptools==30.3.0"
3029
- DEPENDS="-r min-requirements.txt"
3130
- CHECK_TYPE="style"
3231

@@ -36,10 +35,15 @@ matrix:
3635
include:
3736
- python: 3.7
3837
env: JOBQUEUE="slurm"
39-
allow_failures:
38+
- language: go
39+
go: 1.13
40+
env:
41+
- JOBQUEUE="singularity"
42+
- INSTALL_TYPE="develop"
4043
- python: 3.7
4144
env: INSTALL_DEPENDS="pip==10.0.1 setuptools==30.3.0"
42-
- python: 3.8
45+
allow_failures:
46+
- python: 3.7
4347
env: INSTALL_DEPENDS="pip==10.0.1 setuptools==30.3.0"
4448

4549

ci/none.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ function travis_before_script {
4747

4848
function travis_script {
4949
if [ "$CHECK_TYPE" = "test" ]; then
50-
pytest -vs -n auto --cov pydra tutorial --cov-config .coveragerc --cov-report xml:cov.xml --doctest-modules pydra
50+
pytest -vs -n auto --cov pydra --cov-config .coveragerc --cov-report xml:cov.xml --doctest-modules pydra tutorial
5151
elif [ "$CHECK_TYPE" = "style" ]; then
5252
black --check pydra tools setup.py
5353
fi

ci/singularity.sh

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# local build environment
2+
3+
function travis_before_install {
4+
sudo apt-get update;
5+
sudo apt-get install flawfinder squashfs-tools uuid-dev libuuid1 libffi-dev libssl-dev libssl1.0.0 \
6+
libarchive-dev libgpgme11-dev libseccomp-dev wget gcc make pkg-config -y;
7+
export VERSION=3.5.0;
8+
travis_retry wget -q https://github.com/sylabs/singularity/releases/download/v${VERSION}/singularity-${VERSION}.tar.gz;
9+
tar -xzf singularity-${VERSION}.tar.gz;
10+
cd singularity;
11+
./mconfig;
12+
make -C ./builddir;
13+
sudo make -C ./builddir install;
14+
cd -;
15+
travis_retry wget -q https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh;
16+
bash Miniconda3-latest-Linux-x86_64.sh -b -p $HOME/miniconda;
17+
eval "$($HOME/miniconda/bin/conda shell.bash hook)"
18+
}
19+
20+
function travis_install {
21+
python setup.py develop
22+
# Verify import with bare install
23+
python -c 'import pydra; print(pydra.__version__)'
24+
}
25+
26+
function travis_before_script {
27+
pip install -e ".[test]"
28+
}
29+
30+
function travis_script {
31+
pytest -vs --cov pydra --cov-config .coveragerc --cov-report xml:cov.xml --doctest-modules pydra
32+
}
33+
34+
function travis_after_script {
35+
codecov --file cov.xml --flags unittests -e TRAVIS_JOB_NUMBER
36+
}

codecov.yml

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
11
coverage:
2-
range: "0...100"
2+
range: "50...100"
33
ignore: # files and folders that will be removed during processing
44
- "**/tests"
55
- "pydra/_version.py"
66
- "setup.py"
77
- "versioneer.py"
8+
status:
9+
project:
10+
default:
11+
threshold: 1
12+
patch:
13+
default:
14+
target: 80

pydra/engine/task.py

+17-15
Original file line numberDiff line numberDiff line change
@@ -309,12 +309,9 @@ def cmdline(self):
309309
def container_args(self):
310310
if self.inputs.container is None:
311311
raise AttributeError("Container software is not specified")
312-
cargs = [self.inputs.container, "run"]
313-
if self.inputs.container_xargs is not None:
314-
cargs.extend(self.inputs.container_xargs)
312+
cargs = [self.inputs.container]
315313
if self.inputs.image is None:
316314
raise AttributeError("Container image is not specified")
317-
cargs.append(self.inputs.image)
318315
return cargs
319316

320317
@property
@@ -351,7 +348,6 @@ def binds(self, opt):
351348
for (key, val) in self.bind_paths.items():
352349
bargs.extend([opt, "{0}:{1}:{2}".format(key, val[0], val[1])])
353350
# TODO: would need changes for singularity
354-
bargs.extend(["-w", str(self.output_cpath)])
355351
return bargs
356352

357353
def _run_task(self):
@@ -399,9 +395,14 @@ def __init__(
399395
def container_args(self):
400396
cargs = super().container_args
401397
assert self.inputs.container == "docker"
402-
# insert bindings before image
403-
idx = len(cargs) - 1
404-
cargs[idx:-1] = self.binds("-v")
398+
cargs.append("run")
399+
if self.inputs.container_xargs is not None:
400+
cargs.extend(self.inputs.container_xargs)
401+
402+
cargs.extend(self.binds("-v"))
403+
cargs.extend(["-w", str(self.output_cpath)])
404+
cargs.append(self.inputs.image)
405+
405406
return cargs
406407

407408

@@ -418,14 +419,10 @@ def __init__(
418419
**kwargs,
419420
):
420421
if input_spec is None:
421-
field = dc.field(default_factory=list)
422-
field.metadata = {}
423-
fields = [("args", ty.List[str], field)]
424-
input_spec = SpecInfo(
425-
name="Inputs", fields=fields, bases=(SingularitySpec,)
426-
)
427-
super(ContainerTask, self).__init__(
422+
input_spec = SpecInfo(name="Inputs", fields=[], bases=(SingularitySpec,))
423+
super(SingularityTask, self).__init__(
428424
input_spec=input_spec,
425+
output_spec=output_spec,
429426
audit_flags=audit_flags,
430427
messengers=messengers,
431428
messenger_args=messenger_args,
@@ -438,6 +435,11 @@ def __init__(
438435
def container_args(self):
439436
cargs = super().container_args
440437
assert self.inputs.container == "singularity"
438+
cargs.append("exec")
439+
if self.inputs.container_xargs is not None:
440+
cargs.extend(self.inputs.container_xargs)
441+
cargs.append(self.inputs.image)
442+
441443
# insert bindings before image
442444
idx = len(cargs) - 1
443445
cargs[idx:-1] = self.binds("-B")

pydra/engine/tests/test_dockertask.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# -*- coding: utf-8 -*-
22

33
import os, shutil
4+
import subprocess as sp
45
import pytest
5-
from pathlib import Path
66
import dataclasses as dc
77

88
from ..task import DockerTask
@@ -16,7 +16,8 @@
1616
Plugins = ["cf"]
1717

1818
need_docker = pytest.mark.skipif(
19-
shutil.which("docker") is None, reason="no docker within the container"
19+
shutil.which("docker") is None or sp.call(["docker", "info"]),
20+
reason="no docker within the container",
2021
)
2122

2223

@@ -343,6 +344,9 @@ def test_wf_docker_2(plugin, tmpdir):
343344
assert res.output.out == "Hello!"
344345

345346

347+
# tests with customized output_spec
348+
349+
346350
@need_docker
347351
@pytest.mark.parametrize("plugin", Plugins)
348352
def test_docker_outputspec_1(plugin, tmpdir):

0 commit comments

Comments
 (0)