Skip to content

Commit c167389

Browse files
committed
Merge remote-tracking branch 'origin/master' into prov_secondary_files
2 parents dc75a78 + c71deb9 commit c167389

13 files changed

+113
-57
lines changed

Makefile

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,12 @@ install-deb-dep:
5959

6060
## install : install the ${MODULE} module and schema-salad-tool
6161
install: FORCE
62-
pip install .
62+
pip install .[deps]
63+
64+
## dev : install the ${MODULE} module in dev mode
65+
dev: install-dep
66+
pip install -e .[deps]
67+
6368

6469
## dist : create a module package for distribution
6570
dist: dist/${MODULE}-$(VERSION).tar.gz

cwltool/context.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ def __init__(self, kwargs=None):
8888
self.rm_tmpdir = True # type: bool
8989
self.pull_image = True # type: bool
9090
self.rm_container = True # type: bool
91-
self.move_outputs = "" # type: Text
91+
self.move_outputs = "move" # type: Text
9292

9393
self.singularity = False # type: bool
9494
self.disable_net = None

cwltool/job.py

Lines changed: 29 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
# move to a regular typing import when Python 3.3-3.6 is no longer supported
2121
import shellescape
2222
from schema_salad.sourceline import SourceLine
23+
import six
2324
from six import with_metaclass
2425
from prov.model import PROV
2526

@@ -41,11 +42,11 @@
4142

4243
FORCE_SHELLED_POPEN = os.getenv("CWLTOOL_FORCE_SHELL_POPEN", "0") == "1"
4344

44-
SHELL_COMMAND_TEMPLATE = """#!/bin/bash
45+
SHELL_COMMAND_TEMPLATE = u"""#!/bin/bash
4546
python "run_job.py" "job.json"
4647
"""
4748

48-
PYTHON_RUN_SCRIPT = """
49+
PYTHON_RUN_SCRIPT = u"""
4950
import json
5051
import os
5152
import sys
@@ -78,9 +79,15 @@
7879
stderr = open(stderr_path, "wb")
7980
else:
8081
stderr = sys.stderr
82+
if os.name == 'nt':
83+
close_fds = False
84+
for key, value in env.items():
85+
env[key] = str(value)
86+
else:
87+
close_fds = True
8188
sp = subprocess.Popen(commands,
8289
shell=False,
83-
close_fds=True,
90+
close_fds=close_fds,
8491
stdin=stdin,
8592
stdout=stdout,
8693
stderr=stderr,
@@ -367,11 +374,11 @@ def run(self,
367374
runtimeContext # type: RuntimeContext
368375
): # type: (...) -> None
369376

377+
if not os.path.exists(self.tmpdir):
378+
os.makedirs(self.tmpdir)
370379
self._setup(runtimeContext)
371380

372381
env = self.environment
373-
if not os.path.exists(self.tmpdir):
374-
os.makedirs(self.tmpdir)
375382
vars_to_preserve = runtimeContext.preserve_environment
376383
if runtimeContext.preserve_entire_environment:
377384
vars_to_preserve = os.environ
@@ -420,7 +427,8 @@ def create_runtime(self, env, runtimeContext):
420427

421428
def run(self, runtimeContext):
422429
# type: (RuntimeContext) -> None
423-
430+
if not os.path.exists(self.tmpdir):
431+
os.makedirs(self.tmpdir)
424432
(docker_req, docker_is_req) = self.get_requirement("DockerRequirement")
425433
self.prov_obj = runtimeContext.prov_obj
426434
img_id = None
@@ -564,17 +572,21 @@ def terminate():
564572
for key in env:
565573
env_copy[key] = env[key]
566574

567-
job_description = dict(
568-
commands=commands,
569-
cwd=cwd,
570-
env=env_copy,
571-
stdout_path=stdout_path,
572-
stderr_path=stderr_path,
573-
stdin_path=stdin_path,
574-
)
575-
with open(os.path.join(job_dir, "job.json"), encoding='utf-8',
576-
mode="wb") as job_file:
577-
json_dump(job_description, job_file, ensure_ascii=False)
575+
job_description = {
576+
u"commands": commands,
577+
u"cwd": cwd,
578+
u"env": env_copy,
579+
u"stdout_path": stdout_path,
580+
u"stderr_path": stderr_path,
581+
u"stdin_path": stdin_path}
582+
583+
if six.PY2:
584+
with open(os.path.join(job_dir, "job.json"), mode="wb") as job_file:
585+
json_dump(job_description, job_file, ensure_ascii=False)
586+
else:
587+
with open(os.path.join(job_dir, "job.json"), mode="w",
588+
encoding='utf-8') as job_file:
589+
json_dump(job_description, job_file, ensure_ascii=False)
578590
try:
579591
job_script = os.path.join(job_dir, "run_job.bash")
580592
with open(job_script, "wb") as _:

cwltool/main.py

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ def load_job_order(args, # type: argparse.Namespace
261261

262262
def init_job_order(job_order_object, # type: Optional[MutableMapping[Text, Any]]
263263
args, # type: argparse.Namespace
264-
t, # type: Process
264+
process, # type: Process
265265
loader, # type: Loader
266266
stdout, # type: Union[TextIO, StreamWriter]
267267
print_input_deps=False, # type: bool
@@ -270,12 +270,12 @@ def init_job_order(job_order_object, # type: Optional[MutableMapping[Text
270270
input_basedir="", # type: Text
271271
secret_store=None # type: SecretStore
272272
): # type: (...) -> MutableMapping[Text, Any]
273-
secrets_req, _ = t.get_requirement("http://commonwl.org/cwltool#Secrets")
273+
secrets_req, _ = process.get_requirement("http://commonwl.org/cwltool#Secrets")
274274
if not job_order_object:
275275
namemap = {} # type: Dict[Text, Text]
276276
records = [] # type: List[Text]
277277
toolparser = generate_parser(
278-
argparse.ArgumentParser(prog=args.workflow), t, namemap, records)
278+
argparse.ArgumentParser(prog=args.workflow), process, namemap, records)
279279
if toolparser:
280280
if args.tool_help:
281281
toolparser.print_help()
@@ -295,8 +295,8 @@ def init_job_order(job_order_object, # type: Optional[MutableMapping[Text
295295
try:
296296
job_order_object = cast(
297297
MutableMapping, loader.resolve_ref(cmd_line["job_order"])[0])
298-
except Exception as e:
299-
_logger.error(Text(e), exc_info=args.debug)
298+
except Exception as err:
299+
_logger.error(Text(err), exc_info=args.debug)
300300
exit(1)
301301
else:
302302
job_order_object = {"id": args.workflow}
@@ -315,15 +315,15 @@ def init_job_order(job_order_object, # type: Optional[MutableMapping[Text
315315
else:
316316
job_order_object = None
317317

318-
for inp in t.tool["inputs"]:
318+
for inp in process.tool["inputs"]:
319319
if "default" in inp and (
320320
not job_order_object or shortname(inp["id"]) not in job_order_object):
321321
if not job_order_object:
322322
job_order_object = {}
323323
job_order_object[shortname(inp["id"])] = inp["default"]
324324

325325
if not job_order_object:
326-
if len(t.tool["inputs"]) > 0:
326+
if process.tool["inputs"]:
327327
if toolparser:
328328
print(u"\nOptions for {} ".format(args.workflow))
329329
toolparser.print_help()
@@ -344,7 +344,7 @@ def path_to_loc(p):
344344
del p["path"]
345345

346346
ns = {} # type: Dict[Text, Union[Dict[Any, Any], Text, Iterable[Text]]]
347-
ns.update(t.metadata.get("$namespaces", {}))
347+
ns.update(process.metadata.get("$namespaces", {}))
348348
ld = Loader(ns)
349349

350350
def expand_formats(p):
@@ -655,7 +655,7 @@ def my_represent_none(self, data): # pylint: disable=unused-argument
655655
for dirprefix in ("tmpdir_prefix", "tmp_outdir_prefix", "cachedir"):
656656
if getattr(runtimeContext, dirprefix) and getattr(runtimeContext, dirprefix) != DEFAULT_TMP_PREFIX:
657657
sl = "/" if getattr(runtimeContext, dirprefix).endswith("/") or dirprefix == "cachedir" \
658-
else ""
658+
else ""
659659
setattr(runtimeContext, dirprefix,
660660
os.path.abspath(getattr(runtimeContext, dirprefix)) + sl)
661661
if not os.path.exists(os.path.dirname(getattr(runtimeContext, dirprefix))):
@@ -701,11 +701,12 @@ def my_represent_none(self, data): # pylint: disable=unused-argument
701701

702702
if conf_file or use_conda_dependencies:
703703
runtimeContext.job_script_provider = DependenciesConfiguration(args)
704+
else:
705+
runtimeContext.find_default_container = functools.partial(
706+
find_default_container,
707+
default_container=runtimeContext.default_container,
708+
use_biocontainers=args.beta_use_biocontainers)
704709

705-
runtimeContext.find_default_container = functools.partial(
706-
find_default_container,
707-
default_container=runtimeContext.default_container,
708-
use_biocontainers=args.beta_use_biocontainers)
709710
(out, status) = executor(tool,
710711
initialized_job_order_object,
711712
runtimeContext,

release-test.sh

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ package=cwltool
99
module=cwltool
1010
slug=${TRAVIS_PULL_REQUEST_SLUG:=common-workflow-language/cwltool}
1111
repo=https://github.com/${slug}.git
12-
run_tests="bin/py.test --ignore ${module}/schemas/ --pyarg cwltool -n$(nproc) --dist=loadfile"
12+
run_tests="bin/py.test --ignore ${module}/schemas/ --pyarg -x cwltool -n$(nproc) --dist=loadfile"
1313
pipver=7.0.2 # minimum required version of pip
1414
setuptoolsver=24.2.0 # required to generate correct metadata for
1515
# python_requires
@@ -29,6 +29,7 @@ then
2929
&& pip install --force-reinstall -U pip==${pipver} \
3030
&& pip install setuptools==${setuptoolsver} wheel
3131
make install-dep
32+
#pip install 'galaxy-lib>=17.09.3'
3233
make test
3334
pip uninstall -y ${package} || true; pip uninstall -y ${package} || true; make install
3435
mkdir testenv1/not-${module}
@@ -52,7 +53,8 @@ source bin/activate
5253
rm lib/python-wheels/setuptools* \
5354
&& pip install --force-reinstall -U pip==${pipver} \
5455
&& pip install setuptools==${setuptoolsver} wheel
55-
pip install -e "git+${repo}@${HEAD}#egg=${package}"
56+
#pip install 'galaxy-lib==17.09.3'
57+
pip install -e "git+${repo}@${HEAD}#egg=${package}" #[deps]
5658
cd src/${package}
5759
make install-dep
5860
make dist
@@ -72,8 +74,10 @@ source bin/activate
7274
rm lib/python-wheels/setuptools* \
7375
&& pip install --force-reinstall -U pip==${pipver} \
7476
&& pip install setuptools==${setuptoolsver} wheel
75-
pip install ${package}*tar.gz
77+
package_tar=${package}*tar.gz
7678
pip install "-r${DIR}/test-requirements.txt"
79+
#pip install 'galaxy-lib==17.09.3'
80+
pip install ${package_tar} # [deps]
7781
mkdir out
7882
tar --extract --directory=out -z -f ${package}*.tar.gz
7983
cd out/${package}*

setup.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,14 @@
5050
include_package_data=True,
5151
install_requires=[
5252
'setuptools',
53-
'requests >= 2.4.3',
53+
'requests >= 2.6.1', # >= 2.6.1 to workaround
54+
# https://github.com/ionrock/cachecontrol/issues/137
5455
'ruamel.yaml >= 0.12.4, <= 0.15.51',
5556
'rdflib >= 4.2.2, < 4.3.0',
5657
'shellescape >= 3.4.1, < 3.5',
5758
'schema-salad >= 2.7.20180719125426, < 3',
5859
'mypy-extensions',
59-
'six >= 1.8.0',
60+
'six >= 1.9.0', # >= 1.9.0 required by prov
6061
'psutil',
6162
'prov == 1.5.1',
6263
'bagit >= 1.6.4',

tests/test_check.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,6 @@
22

33
import unittest
44

5-
import cwltool.expression as expr
6-
import cwltool.factory
7-
import cwltool.pathmapper
8-
import cwltool.process
9-
import cwltool.workflow
105
from cwltool.main import main
116

127
from .util import get_data, needs_docker

tests/test_cwl_version.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
from .util import get_data
88

99

10-
class CWL_Version_Checks(unittest.TestCase):
11-
# no cwlVersion in the workflow
10+
class CWLVersionChecks(unittest.TestCase):
1211
def test_missing_cwl_version(self):
12+
"""no cwlVersion in the workflow"""
1313
self.assertEqual(main([get_data('tests/wf/missing_cwlVersion.cwl')]), 1)
14-
# using cwlVersion: v0.1 in the workflow
1514
def test_incorrect_cwl_version(self):
15+
"""using cwlVersion: v0.1 in the workflow"""
1616
self.assertEqual(main([get_data('tests/wf/wrong_cwlVersion.cwl')]), 1)

tests/test_default_path.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88

99

1010
class TestDefaultPath(unittest.TestCase):
11-
# Testing that error is not raised when default path is not present
1211
def test_default_path(self):
12+
"""Testing that error is not raised when default path is not present"""
1313
document_loader, workflowobj, uri = fetch_document(
1414
get_data("tests/wf/default_path.cwl"))
1515
document_loader, avsc_names, processobj, metadata, uri = validate_document(

tests/test_dependencies.py

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
from __future__ import absolute_import
2+
3+
from cwltool.utils import onWindows
4+
5+
from .util import get_data, needs_docker
6+
from .test_examples import TestCmdLine
7+
8+
import pytest
9+
10+
try:
11+
from galaxy.tools.deps.requirements import ToolRequirement, ToolRequirements
12+
from galaxy.tools import deps
13+
except ImportError:
14+
deps = None
15+
16+
class TestBetaDependenciesResolver(TestCmdLine):
17+
18+
@needs_docker
19+
def test_biocontainers(self):
20+
if not deps:
21+
pytest.skip("galaxy-lib is not installed.")
22+
wflow = get_data("tests/seqtk_seq.cwl")
23+
job = get_data("tests/seqtk_seq_job.json")
24+
error_code, stdout, stderr = self.get_main_output(
25+
["--beta-use-biocontainers", wflow, job])
26+
print(stderr)
27+
print(stdout)
28+
assert error_code is 0
29+
30+
def test_bioconda(self):
31+
if onWindows() or not deps:
32+
pytest.skip("bioconda currently not working on MS Windows.")
33+
elif not deps:
34+
pytest.skip("galaxy-lib is not installed.")
35+
wflow = get_data("tests/seqtk_seq.cwl")
36+
job = get_data("tests/seqtk_seq_job.json")
37+
error_code, stdout, stderr = self.get_main_output(
38+
["--beta-conda-dependencies", "--debug", wflow, job])
39+
print(stderr)
40+
print(stdout)
41+
assert error_code is 0

0 commit comments

Comments
 (0)