Skip to content

Commit 1eda051

Browse files
authored
Merge pull request #398 from SpheMakh/udocker
Udocker
2 parents 48e449c + 049857c commit 1eda051

17 files changed

Lines changed: 473 additions & 74 deletions

File tree

.travis/mypy.docker

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
FROM kernsuite/base:4
2-
RUN docker-apt-install python3-pip
3-
RUN pip3 install mypy
2+
RUN docker-apt-install python3-pip git
3+
RUN pip3 install -U mypy pip setuptools
44
ENV USER root
55
ADD . /code
66
WORKDIR /code
7+
RUN pip install /code
78
RUN mypy --ignore-missing-import stimela

.travis/py2.docker

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
FROM kernsuite/base:4
2-
RUN docker-apt-install python-pip
2+
RUN docker-apt-install python-pip git
33
ADD . /code
44
ENV USER root
55
WORKDIR /code
6+
RUN pip install pip setuptools -U
67
RUN pip install /code
78
RUN python -c "import stimela"

.travis/py3.docker

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
FROM kernsuite/base:4
2-
RUN docker-apt-install python3-pip
2+
RUN docker-apt-install python3-pip git
33
ENV USER root
44
ADD . /code
55
WORKDIR /code
6+
RUN pip3 install pip setuptools -U
67
RUN pip3 install .
78
RUN python3 -c "import stimela"

examples/simulation_pipeline.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
11
# import stimela package
22
import stimela
3+
import os
34

45
# Recipe I/O configuration
56
INPUT = "input" # This folder must exist
67
OUTPUT = "output"
78
MSDIR = "msdir"
89
PREFIX = "stimela-example" # Prefix for output images
9-
SINGULARTITY_IMAGE_DIR = "/home/sphe/work/github/Stimela/examples/IMAGES/"
10+
try:
11+
SINGULARTITY_IMAGE_DIR = os.environ["STIMELA_SINGULARTITY_IMAGE_DIR"]
12+
except KeyError:
13+
pass
14+
1015

1116
# MS name
1217
MS = "meerkat_simulation_example.ms"
@@ -21,6 +26,7 @@
2126
# singularity_image_dir=SINGULARTITY_IMAGE_DIR,
2227
)
2328

29+
pipeline.JOB_TYPE = "udocker"
2430
# 1: Make empty MS
2531
pipeline.add("cab/simms", # Executor image to start container from
2632
"simms_example", # Container name

setup.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,22 @@
11
#!/usr/bin/env python
22

33
import os
4+
import sys
45
from setuptools import setup
56

67

8+
requirements = ["pyyaml",
9+
"nose>=1.3.7",
10+
"future",
11+
],
12+
13+
if sys.version_info <= (3, 0):
14+
requirements += [
15+
"udocker @ git+https://github.com/indigo-dc/udocker@master#egg=udocker=1.1.2",
16+
],
17+
718
PACKAGE_NAME = "stimela"
8-
__version__ = "1.0.6"
19+
__version__ = "1.0.7"
920

1021
setup(name = PACKAGE_NAME,
1122
version = __version__,
@@ -25,9 +36,7 @@
2536
"cab/*/src/tdlconf.profiles",
2637
"cab/singularity_run",
2738
]},
28-
install_requires = ["pyyaml",
29-
"nose>=1.3.7",
30-
"future"],
39+
install_requires = requirements,
3140
scripts = ["bin/" + i for i in os.listdir("bin")],
3241
classifiers = [],
3342
)

stimela/__init__.py

Lines changed: 32 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from stimela.cargo import cab
1414
from stimela.recipe import Recipe as Pipeline
1515
from stimela.recipe import Recipe, PipelineException
16-
from stimela import docker, singularity
16+
from stimela import docker, singularity, udocker
1717
import pkg_resources
1818
import warnings
1919

@@ -317,10 +317,25 @@ def pull(argv):
317317
help="Tag")
318318

319319
add("-s", "--singularity", action="store_true",
320-
help="Use singularity instead of docker."
320+
help="Pull base images using singularity."
321321
"Images will be pulled into the directory specified by the enviroment varaible, SINGULARITY_PULLFOLDER. $PWD by default")
322322

323+
add("-d", "--docker", action="store_true",
324+
help="Pull base images using docker.")
325+
326+
add("-pf", "--pull-folder", help="Images will be placed in this folder. Else, if the environmnental variable 'SINGULARITY_PULLFOLDER' is set, then images will be placed there. "
327+
"Else, images will be placed in the current directory")
328+
323329
args = parser.parse_args(argv)
330+
331+
if args.pull_folder:
332+
pull_folder = args.pull_folder
333+
else:
334+
try:
335+
pull_folder = os.environ["SINGULARITY_PULLFOLDER"]
336+
except KeyError:
337+
pull_folder = "."
338+
324339
log = logger.StimelaLogger(LOG_FILE)
325340
images = log.read()['images']
326341

@@ -330,10 +345,13 @@ def pull(argv):
330345
simage = image.replace("/", "_")
331346
simage = simage.replace(":", "_") + ".img"
332347
if args.singularity:
333-
singularity.pull(image, simage)
334-
else:
348+
singularity.pull(image, simage, directory=pull_folder)
349+
elif args.docker:
335350
docker.pull(image)
336351
log.log_image(image, 'pulled')
352+
else:
353+
udocker.pull(image)
354+
log.log_image(image, 'pulled')
337355
else:
338356

339357
base = []
@@ -344,14 +362,16 @@ def pull(argv):
344362
base = set(base)
345363

346364
for image in base:
347-
if image not in ["stimela/ddfacet", "radioastro/ddfacet"]:
348-
if args.singularity:
349-
simage = image.replace("/", "_")
350-
simage = simage.replace(":", "_") + ".img"
351-
singularity.pull(image, simage)
352-
else:
353-
docker.pull(image)
354-
log.log_image(image, 'pulled')
365+
if args.singularity:
366+
simage = image.replace("/", "_")
367+
simage = simage.replace(":", "_") + ".img"
368+
singularity.pull(image, simage, directory=pull_folder)
369+
elif args.docker:
370+
docker.pull(image)
371+
log.log_image(image, 'pulled')
372+
else:
373+
udocker.pull(image)
374+
log.log_image(image, 'pulled')
355375

356376
log.write()
357377

stimela/cargo/cab/aimfast/parameters.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"prefix": "--",
77
"binary": "aimfast",
88
"msdir": false,
9+
"use_graphics": true,
910
"parameters": [
1011
{
1112
"info": "Residual image to extract the four (4) statistical moments of distribution",

stimela/cargo/cab/casa_plotants/parameters.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"prefix": "",
77
"binary": "plotants",
88
"msdir": true,
9+
"use_graphics": true,
910
"parameters": [
1011
{
1112
"info": "Name of measurement set",
@@ -23,4 +24,4 @@
2324
"dtype": "file"
2425
}
2526
]
26-
}
27+
}

stimela/cargo/cab/casa_plotcal/parameters.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"prefix": "-",
77
"binary": "plotcal",
88
"msdir": false,
9+
"use_graphics": true,
910
"parameters": [
1011
{
1112
"info": "Name of input calibration table",
@@ -173,4 +174,4 @@
173174
"name": "showgui"
174175
}
175176
]
176-
}
177+
}

stimela/cargo/cab/casa_plotms/parameters.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"prefix": " ",
77
"binary": "plotms",
88
"msdir": true,
9+
"use_graphics": true,
910
"parameters": [
1011
{
1112
"info": "MS name",
@@ -517,4 +518,4 @@
517518
"name": "showgui"
518519
}
519520
]
520-
}
521+
}

0 commit comments

Comments
 (0)