Skip to content

Commit 435ec22

Browse files
authored
Merge branch 'master' into udocker
2 parents 663f1aa + 028c883 commit 435ec22

20 files changed

+248
-133
lines changed

MANIFEST.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ include gittaggers.py Makefile cwltool.py
22
include tests/*
33
include tests/tmp1/tmp2/tmp3/.gitkeep
44
include tests/wf/*
5+
include tests/override/*
56
include cwltool/schemas/v1.0/*.yml
67
include cwltool/schemas/draft-2/*.yml
78
include cwltool/schemas/draft-3/*.yml

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ mypy2: ${PYSOURCES}
160160
rm -Rf typeshed/2and3/schema_salad
161161
ln -s $(shell python -c 'from __future__ import print_function; import schema_salad; import os.path; print(os.path.dirname(schema_salad.__file__))') \
162162
typeshed/2and3/schema_salad
163-
MYPYPATH=$MYPYPATH:typeshed/2.7:typeshed/2and3 mypy --py2 --disallow-untyped-calls \
163+
MYPYPATH=$$MYPYPATH:typeshed/2.7:typeshed/2and3 mypy --py2 --disallow-untyped-calls \
164164
--warn-redundant-casts \
165165
cwltool
166166

@@ -171,7 +171,7 @@ mypy3: ${PYSOURCES}
171171
rm -Rf typeshed/2and3/schema_salad
172172
ln -s $(shell python3 -c 'from __future__ import print_function; import schema_salad; import os.path; print(os.path.dirname(schema_salad.__file__))') \
173173
typeshed/2and3/schema_salad
174-
MYPYPATH=$MYPYPATH:typeshed/3:typeshed/2and3 mypy --disallow-untyped-calls \
174+
MYPYPATH=$$MYPYPATH:typeshed/3:typeshed/2and3 mypy --disallow-untyped-calls \
175175
--warn-redundant-casts \
176176
cwltool
177177

README.rst

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ Running tests locally
6565
To run the basis tests after installing `cwltool` execute the following:
6666

6767
.. code:: bash
68-
68+
6969
pip install pytest mock
7070
py.test --ignore cwltool/schemas/ --pyarg cwltool
7171
@@ -235,7 +235,7 @@ the correct module environment before executing the above tool would simply be:
235235

236236
.. code:: yaml
237237
238-
- type: module
238+
- type: modules
239239
240240
The outer list indicates that one plugin is being enabled, the plugin parameters are
241241
defined as a dictionary for this one list item. There is only one required parameter
@@ -410,17 +410,16 @@ environment or with a particular dataset. To avoid the need to modify the
410410
underlying workflow, cwltool supports requirement "overrides".
411411

412412
The format of the "overrides" object is a mapping of item identifier (workflow,
413-
workflow step, or command line tool) followed by a list of ProcessRequirements
414-
that should be applied.
413+
workflow step, or command line tool) to the process requirements that should be applied.
415414

416415
.. code:: yaml
417416
418417
cwltool:overrides:
419418
echo.cwl:
420-
- class: EnvVarRequirement
421-
envDef:
422-
MESSAGE: override_value
423-
419+
requirements:
420+
EnvVarRequirement:
421+
envDef:
422+
MESSAGE: override_value
424423
425424
Overrides can be specified either on the command line, or as part of the job
426425
input document. Workflow steps are identified using the name of the workflow
@@ -437,9 +436,10 @@ Override identifiers are relative to the toplevel workflow document.
437436
input_parameter2: value2
438437
cwltool:overrides:
439438
workflow.cwl#step1:
440-
- class: EnvVarRequirement
441-
envDef:
442-
MESSAGE: override_value
439+
requirements:
440+
EnvVarRequirement:
441+
envDef:
442+
MESSAGE: override_value
443443
444444
.. code:: bash
445445

cwltool/draft2tool.py

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
from __future__ import absolute_import
22
import copy
33
import hashlib
4+
import locale
45
import json
56
import logging
67
import os
78
import re
89
import shutil
910
import tempfile
10-
from functools import partial
11-
from typing import Any, Callable, Dict, Generator, List, Optional, Set, Text, Union, cast
11+
from functools import partial, cmp_to_key
12+
from typing import (Any, Callable, Dict, Generator, List, Optional, Set, Text,
13+
Union, cast)
1214

1315
from six import string_types, u
1416

@@ -208,7 +210,7 @@ def makeJobRunner(self, use_container=True, **kwargs): # type: (Optional[bool],
208210
})
209211
dockerReq = self.requirements[0]
210212
if default_container == windows_default_container_id and use_container and onWindows():
211-
_logger.warning(DEFAULT_CONTAINER_MSG%(windows_default_container_id, windows_default_container_id))
213+
_logger.warning(DEFAULT_CONTAINER_MSG % (windows_default_container_id, windows_default_container_id))
212214

213215
if dockerReq and use_container:
214216
return DockerCommandLineJob()
@@ -523,8 +525,8 @@ def collect_output_ports(self, ports, builder, outdir, compute_checksum=True, jo
523525
for i, port in enumerate(ports):
524526
def makeWorkflowException(msg):
525527
return WorkflowException(
526-
u"Error collecting output for parameter '%s':\n%s"
527-
% (shortname(port["id"]), msg))
528+
u"Error collecting output for parameter '%s':\n%s"
529+
% (shortname(port["id"]), msg))
528530
with SourceLine(ports, i, makeWorkflowException, debug):
529531
fragment = shortname(port["id"])
530532
ret[fragment] = self.collect_output(port, builder, outdir, fs_access,
@@ -575,16 +577,25 @@ def collect_output(self, schema, builder, outdir, fs_access, compute_checksum=Tr
575577
elif gb == ".":
576578
gb = outdir
577579
elif gb.startswith("/"):
578-
raise WorkflowException("glob patterns must not start with '/'")
580+
raise WorkflowException(
581+
"glob patterns must not start with '/'")
579582
try:
580583
prefix = fs_access.glob(outdir)
581584
r.extend([{"location": g,
582-
"path": fs_access.join(builder.outdir, g[len(prefix[0])+1:]),
585+
"path": fs_access.join(builder.outdir,
586+
g[len(prefix[0])+1:]),
583587
"basename": os.path.basename(g),
584-
"nameroot": os.path.splitext(os.path.basename(g))[0],
585-
"nameext": os.path.splitext(os.path.basename(g))[1],
586-
"class": "File" if fs_access.isfile(g) else "Directory"}
587-
for g in fs_access.glob(fs_access.join(outdir, gb))])
588+
"nameroot": os.path.splitext(
589+
os.path.basename(g))[0],
590+
"nameext": os.path.splitext(
591+
os.path.basename(g))[1],
592+
"class": "File" if fs_access.isfile(g)
593+
else "Directory"}
594+
for g in sorted(fs_access.glob(
595+
fs_access.join(outdir, gb)),
596+
key=cmp_to_key(cast(
597+
Callable[[Text, Text],
598+
int], locale.strcoll)))])
588599
except (OSError, IOError) as e:
589600
_logger.warning(Text(e))
590601
except:

cwltool/job.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from __future__ import absolute_import
2+
import codecs
23
import functools
34
import io
45
import json
@@ -549,14 +550,14 @@ def _job_popen(
549550
stdin_path=stdin_path,
550551
)
551552
with open(os.path.join(job_dir, "job.json"), "wb") as f:
552-
json.dump(job_description, f)
553+
json.dump(job_description, codecs.getwriter('utf-8')(f), ensure_ascii=False) # type: ignore
553554
try:
554555
job_script = os.path.join(job_dir, "run_job.bash")
555556
with open(job_script, "wb") as f:
556557
f.write(job_script_contents.encode('utf-8'))
557558
job_run = os.path.join(job_dir, "run_job.py")
558559
with open(job_run, "wb") as f:
559-
f.write(PYTHON_RUN_SCRIPT)
560+
f.write(PYTHON_RUN_SCRIPT.encode('utf-8'))
560561
sp = subprocess.Popen(
561562
["bash", job_script.encode("utf-8")],
562563
shell=False,

0 commit comments

Comments
 (0)