Skip to content

Commit bb6fe86

Browse files
committed
podman/singularity + nodejs
Fixes #803
1 parent 52e1ebe commit bb6fe86

16 files changed

+277
-83
lines changed

Makefile

+3-3
Original file line numberDiff line numberDiff line change
@@ -148,11 +148,11 @@ diff-cover.html: coverage.xml
148148

149149
## test : run the ${MODULE} test suite
150150
test: check-python3 $(PYSOURCES)
151-
python -m pytest ${PYTEST_EXTRA}
151+
python -m pytest -rs ${PYTEST_EXTRA}
152152

153153
## testcov : run the ${MODULE} test suite and collect coverage
154154
testcov: check-python3 $(PYSOURCES)
155-
python -m pytest --cov --cov-config=.coveragerc --cov-report= ${PYTEST_EXTRA}
155+
python -m pytest -rs --cov --cov-config=.coveragerc --cov-report= ${PYTEST_EXTRA}
156156

157157
sloccount.sc: $(PYSOURCES) Makefile
158158
sloccount --duplicates --wide --details $^ > $@
@@ -177,7 +177,7 @@ mypy: $(filter-out setup.py gittagger.py,$(PYSOURCES))
177177

178178
mypyc: $(PYSOURCES)
179179
MYPYPATH=typeshed CWLTOOL_USE_MYPYC=1 pip install --verbose -e . \
180-
&& pytest -vv ${PYTEST_EXTRA}
180+
&& pytest -rs -vv ${PYTEST_EXTRA}
181181

182182
shellcheck: FORCE
183183
shellcheck build-cwltool-docker.sh cwl-docker.sh release-test.sh conformance-test.sh \

cwltool/builder.py

+3
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ def __init__(
179179
tmpdir: str,
180180
stagedir: str,
181181
cwlVersion: str,
182+
container_engine: str,
182183
) -> None:
183184
"""Initialize this Builder."""
184185
self.job = job
@@ -215,6 +216,7 @@ def __init__(
215216
self.pathmapper = None # type: Optional[PathMapper]
216217
self.prov_obj = None # type: Optional[ProvenanceProfile]
217218
self.find_default_container = None # type: Optional[Callable[[], str]]
219+
self.container_engine = container_engine
218220

219221
def build_job_script(self, commands: List[str]) -> Optional[str]:
220222
if self.job_script_provider is not None:
@@ -746,4 +748,5 @@ def do_eval(
746748
force_docker_pull=self.force_docker_pull,
747749
strip_whitespace=strip_whitespace,
748750
cwlVersion=self.cwlVersion,
751+
container_engine=self.container_engine,
749752
)

cwltool/context.py

+2
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ def __init__(self, kwargs: Optional[Dict[str, Any]] = None) -> None:
7575
self.jobdefaults = None # type: Optional[CommentedMap]
7676
self.doc_cache = True # type: bool
7777
self.relax_path_checks = False # type: bool
78+
self.singularity = False # type: bool
79+
self.podman = False # type: bool
7880

7981
super().__init__(kwargs)
8082

cwltool/expression.py

+6
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,7 @@ def evaluator(
204204
force_docker_pull: bool = False,
205205
debug: bool = False,
206206
js_console: bool = False,
207+
container_engine: str = "docker",
207208
) -> Optional[CWLOutputType]:
208209
match = param_re.match(ex)
209210

@@ -238,6 +239,7 @@ def evaluator(
238239
force_docker_pull=force_docker_pull,
239240
debug=debug,
240241
js_console=js_console,
242+
container_engine=container_engine,
241243
)
242244
else:
243245
if expression_parse_exception is not None:
@@ -270,6 +272,7 @@ def interpolate(
270272
strip_whitespace: bool = True,
271273
escaping_behavior: int = 2,
272274
convert_to_expression: bool = False,
275+
container_engine: str = "docker",
273276
) -> Optional[CWLOutputType]:
274277
"""
275278
Interpolate and evaluate.
@@ -303,6 +306,7 @@ def interpolate(
303306
force_docker_pull=force_docker_pull,
304307
debug=debug,
305308
js_console=js_console,
309+
container_engine=container_engine,
306310
)
307311
if w[0] == 0 and w[1] == len(scan) and len(parts) <= 1:
308312
return e
@@ -367,6 +371,7 @@ def do_eval(
367371
js_console: bool = False,
368372
strip_whitespace: bool = True,
369373
cwlVersion: str = "",
374+
container_engine: str = "docker",
370375
) -> Optional[CWLOutputType]:
371376

372377
runtime = cast(MutableMapping[str, Union[int, str, None]], copy.deepcopy(resources))
@@ -409,6 +414,7 @@ def do_eval(
409414
"v1.2.0-dev3",
410415
)
411416
else 2,
417+
container_engine=container_engine,
412418
)
413419

414420
except Exception as e:

cwltool/factory.py

+9-3
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ def __call__(self, **kwargs):
4040
class Factory:
4141
"""Easy way to load a CWL document for execution."""
4242

43+
loading_context: LoadingContext
44+
runtime_context: RuntimeContext
45+
4346
def __init__(
4447
self,
4548
executor: Optional[JobExecutor] = None,
@@ -51,13 +54,16 @@ def __init__(
5154
if executor is None:
5255
executor = SingleJobExecutor()
5356
self.executor = executor
54-
self.loading_context = loading_context
55-
if loading_context is None:
56-
self.loading_context = LoadingContext()
5757
if runtime_context is None:
5858
self.runtime_context = RuntimeContext()
5959
else:
6060
self.runtime_context = runtime_context
61+
if loading_context is None:
62+
self.loading_context = LoadingContext()
63+
self.loading_context.singularity = self.runtime_context.singularity
64+
self.loading_context.podman = self.runtime_context.podman
65+
else:
66+
self.loading_context = loading_context
6167

6268
def make(self, cwl: Union[str, Dict[str, Any]]) -> Callable:
6369
"""Instantiate a CWL object from a CWl document."""

cwltool/loghandler.py

+31
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,38 @@
11
"""Shared logger for cwltool."""
22
import logging
33

4+
import coloredlogs
5+
46
_logger = logging.getLogger("cwltool") # pylint: disable=invalid-name
57
defaultStreamHandler = logging.StreamHandler() # pylint: disable=invalid-name
68
_logger.addHandler(defaultStreamHandler)
79
_logger.setLevel(logging.INFO)
10+
11+
12+
def configure_logging(
13+
stderr_handler: logging.Handler,
14+
quiet: bool,
15+
debug: bool,
16+
enable_color: bool,
17+
timestamps: bool,
18+
base_logger: logging.Logger = _logger,
19+
) -> None:
20+
"""Configure logging."""
21+
rdflib_logger = logging.getLogger("rdflib.term")
22+
rdflib_logger.addHandler(stderr_handler)
23+
rdflib_logger.setLevel(logging.ERROR)
24+
if quiet:
25+
# Silence STDERR, not an eventual provenance log file
26+
stderr_handler.setLevel(logging.WARN)
27+
if debug:
28+
# Increase to debug for both stderr and provenance log file
29+
base_logger.setLevel(logging.DEBUG)
30+
stderr_handler.setLevel(logging.DEBUG)
31+
rdflib_logger.setLevel(logging.DEBUG)
32+
fmtclass = coloredlogs.ColoredFormatter if enable_color else logging.Formatter
33+
formatter = fmtclass("%(levelname)s %(message)s")
34+
if timestamps:
35+
formatter = fmtclass(
36+
"[%(asctime)s] %(levelname)s %(message)s", "%Y-%m-%d %H:%M:%S"
37+
)
38+
stderr_handler.setFormatter(formatter)

cwltool/main.py

+10-27
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
resolve_overrides,
6161
resolve_tool_uri,
6262
)
63-
from .loghandler import _logger, defaultStreamHandler
63+
from .loghandler import _logger, configure_logging, defaultStreamHandler
6464
from .mpi import MpiConfig
6565
from .mutation import MutationManager
6666
from .pack import pack
@@ -624,31 +624,6 @@ def supported_cwl_versions(enable_dev: bool) -> List[str]:
624624
return versions
625625

626626

627-
def configure_logging(
628-
args: argparse.Namespace,
629-
stderr_handler: logging.Handler,
630-
runtimeContext: RuntimeContext,
631-
) -> None:
632-
rdflib_logger = logging.getLogger("rdflib.term")
633-
rdflib_logger.addHandler(stderr_handler)
634-
rdflib_logger.setLevel(logging.ERROR)
635-
if args.quiet:
636-
# Silence STDERR, not an eventual provenance log file
637-
stderr_handler.setLevel(logging.WARN)
638-
if runtimeContext.debug:
639-
# Increase to debug for both stderr and provenance log file
640-
_logger.setLevel(logging.DEBUG)
641-
stderr_handler.setLevel(logging.DEBUG)
642-
rdflib_logger.setLevel(logging.DEBUG)
643-
fmtclass = coloredlogs.ColoredFormatter if args.enable_color else logging.Formatter
644-
formatter = fmtclass("%(levelname)s %(message)s")
645-
if args.timestamps:
646-
formatter = fmtclass(
647-
"[%(asctime)s] %(levelname)s %(message)s", "%Y-%m-%d %H:%M:%S"
648-
)
649-
stderr_handler.setFormatter(formatter)
650-
651-
652627
def setup_schema(
653628
args: argparse.Namespace, custom_schema_callback: Optional[Callable[[], None]]
654629
) -> None:
@@ -724,6 +699,8 @@ def setup_loadingContext(
724699
) -> LoadingContext:
725700
if loadingContext is None:
726701
loadingContext = LoadingContext(vars(args))
702+
loadingContext.singularity = runtimeContext.singularity
703+
loadingContext.podman = runtimeContext.podman
727704
else:
728705
loadingContext = loadingContext.copy()
729706
loadingContext.loader = default_loader(
@@ -966,7 +943,13 @@ def main(
966943
if not hasattr(args, key):
967944
setattr(args, key, val)
968945

969-
configure_logging(args, stderr_handler, runtimeContext)
946+
configure_logging(
947+
stderr_handler,
948+
args.quiet,
949+
runtimeContext.debug,
950+
args.enable_color,
951+
args.timestamps,
952+
)
970953

971954
if args.version:
972955
print(versionfunc())

cwltool/process.py

+8
Original file line numberDiff line numberDiff line change
@@ -697,6 +697,12 @@ def __init__(
697697
)
698698
make_avsc_object(convert_to_dict(self.outputs_record_schema), self.names)
699699

700+
self.container_engine = "docker"
701+
if loadingContext.podman:
702+
self.container_engine = "podman"
703+
elif loadingContext.singularity:
704+
self.container_engine = "singularity"
705+
700706
if toolpath_object.get("class") is not None and not getdefault(
701707
loadingContext.disable_js_validation, False
702708
):
@@ -722,6 +728,7 @@ def __init__(
722728
toolpath_object,
723729
self.doc_schema.names[avroname],
724730
validate_js_options,
731+
self.container_engine,
725732
)
726733

727734
dockerReq, is_req = self.get_requirement("DockerRequirement")
@@ -903,6 +910,7 @@ def inc(d): # type: (List[int]) -> None
903910
tmpdir,
904911
stagedir,
905912
cwl_version,
913+
self.container_engine,
906914
)
907915

908916
bindings.extend(

0 commit comments

Comments
 (0)