Skip to content

Commit 802969a

Browse files
committed
Merge remote-tracking branch 'origin/master' into bad_type_error
2 parents c7dbb9f + 1b04970 commit 802969a

File tree

13 files changed

+385
-86
lines changed

13 files changed

+385
-86
lines changed

cwltool/builder.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,12 @@ def checkFormat(actualFile, inputFormats, ontology):
7676
if not af:
7777
continue
7878
if "format" not in af:
79-
raise validate.ValidationException(u"Missing required 'format' for File %s" % af)
79+
raise validate.ValidationException(u"File has no 'format' defined: %s" % json.dumps(af, indent=4))
8080
for inpf in aslist(inputFormats):
8181
if af["format"] == inpf or formatSubclassOf(af["format"], inpf, ontology, set()):
8282
return
8383
raise validate.ValidationException(
84-
u"Incompatible file format, expected format(s) %s but file object is: %s" % (inputFormats, json.dumps(af, indent=4)))
84+
u"File has an incompatible format: %s" % json.dumps(af, indent=4))
8585

8686
class Builder(object):
8787
def __init__(self): # type: () -> None
@@ -237,7 +237,10 @@ def bind_input(self, schema, datum, lead_pos=None, tail_pos=None, discover_secon
237237
normalizeFilesDirs(datum["secondaryFiles"])
238238

239239
if "format" in schema:
240-
checkFormat(datum, self.do_eval(schema["format"]), self.formatgraph)
240+
try:
241+
checkFormat(datum, self.do_eval(schema["format"]), self.formatgraph)
242+
except validate.ValidationException as ve:
243+
raise WorkflowException("Expected value of '%s' to have format %s but\n %s" % (schema["name"], schema["format"], ve))
241244

242245
def _capture_files(f):
243246
self.files.append(f)

cwltool/docker.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,25 @@
44
import os
55
import re
66
import shutil
7-
import subprocess
87
import sys
98
import tempfile
109
from io import open
11-
1210
import datetime
11+
import threading
12+
1313
import requests
1414
from typing import (Dict, List, Text, Any, MutableMapping, Set)
15-
import threading
1615

1716
from .docker_id import docker_vm_id
1817
from .errors import WorkflowException
1918
from .job import ContainerCommandLineJob
2019
from .pathmapper import PathMapper, ensure_writable
2120
from .secrets import SecretStore
2221
from .utils import docker_windows_path_adjust, onWindows
22+
if os.name == 'posix' and sys.version_info[0] < 3:
23+
import subprocess32 as subprocess # type: ignore
24+
else:
25+
import subprocess # type: ignore
2326

2427
_logger = logging.getLogger("cwltool")
2528

cwltool/docker_id.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
from __future__ import print_function
22
from __future__ import absolute_import
3-
4-
import subprocess
3+
import os
4+
import sys
55
from typing import List, Text, Tuple
6+
if os.name == 'posix' and sys.version_info[0] < 3:
7+
import subprocess32 as subprocess # type: ignore
8+
else:
9+
import subprocess # type: ignore
610

711

812
def docker_vm_id(): # type: () -> Tuple[int, int]

cwltool/executors.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from abc import ABCMeta, abstractmethod
77

88
from typing import Dict, Text, Any, Tuple, Set, List
9+
from schema_salad.validate import ValidationException
910

1011
from .builder import Builder
1112
from .errors import WorkflowException
@@ -14,6 +15,7 @@
1415
from .process import relocateOutputs, cleanIntermediate, Process
1516
from . import loghandler
1617

18+
1719
_logger = logging.getLogger("cwltool")
1820

1921
class JobExecutor(object):
@@ -107,7 +109,7 @@ def run_jobs(self,
107109
else:
108110
logger.error("Workflow cannot make any more progress.")
109111
break
110-
except WorkflowException:
112+
except (ValidationException, WorkflowException):
111113
raise
112114
except Exception as e:
113115
logger.exception("Got workflow error")

cwltool/job.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
import re
1010
import shutil
1111
import stat
12-
import subprocess
1312
import sys
1413
import tempfile
1514
from abc import ABCMeta, abstractmethod
@@ -28,6 +27,11 @@
2827
from .secrets import SecretStore
2928
from .utils import bytes2str_in_dicts
3029
from .utils import copytree_with_merge, onWindows
30+
if os.name == 'posix' and sys.version_info[0] < 3:
31+
import subprocess32 as subprocess # type: ignore
32+
else:
33+
import subprocess # type: ignore
34+
3135

3236
_logger = logging.getLogger("cwltool")
3337

cwltool/resolver.py

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,38 @@
11
from __future__ import absolute_import
22
import logging
33
import os
4+
import sys
45

6+
if sys.version_info < (3, 4):
7+
from pathlib2 import Path
8+
else:
9+
from pathlib import Path
510
from six.moves import urllib
611

7-
from schema_salad.ref_resolver import file_uri
812

913
_logger = logging.getLogger("cwltool")
1014

1115

1216
def resolve_local(document_loader, uri):
13-
if uri.startswith("/"):
14-
return None
15-
shares = [os.environ.get("XDG_DATA_HOME", os.path.join(os.path.expanduser('~'), ".local", "share"))]
16-
shares.extend(os.environ.get("XDG_DATA_DIRS", "/usr/local/share/:/usr/share/").split(":"))
17-
shares = [os.path.join(s, "commonwl", uri) for s in shares]
18-
shares.insert(0, os.path.join(os.getcwd(), uri))
17+
if uri.startswith("/") and os.path.exists(uri):
18+
return Path(uri).as_uri()
19+
if os.path.exists(urllib.parse.urlparse(
20+
urllib.parse.urldefrag(
21+
"{}/{}".format(Path.cwd().as_uri(), uri))[0])[2]):
22+
return "{}/{}".format(Path.cwd().as_uri(), uri)
23+
sharepaths = [os.environ.get("XDG_DATA_HOME", os.path.join(
24+
os.path.expanduser('~'), ".local", "share"))]
25+
sharepaths.extend(os.environ.get(
26+
"XDG_DATA_DIRS", "/usr/local/share/:/usr/share/").split(":"))
27+
shares = [os.path.join(s, "commonwl", uri) for s in sharepaths]
1928

2029
_logger.debug("Search path is %s", shares)
2130

22-
for s in shares:
23-
if os.path.exists(s):
24-
return file_uri(s)
25-
if os.path.exists("%s.cwl" % s):
26-
return file_uri(s)
31+
for path in shares:
32+
if os.path.exists(path):
33+
return Path(uri).as_uri()
34+
if os.path.exists("{}.cwl".format(path)):
35+
return Path("{}.cwl".format(path)).as_uri()
2736
return None
2837

2938

@@ -32,7 +41,6 @@ def tool_resolver(document_loader, uri):
3241
ret = r(document_loader, uri)
3342
if ret is not None:
3443
return ret
35-
return file_uri(os.path.abspath(uri), split_frag=True)
3644

3745

3846
ga4gh_tool_registries = ["https://dockstore.org:8443"]

cwltool/sandboxjs.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,23 @@
55
import os
66
import re
77
import select
8-
import subprocess
98
import threading
109
import sys
1110
from io import BytesIO
1211
from typing import Any, Dict, List, Mapping, Text, Tuple, Union
13-
from .utils import onWindows
14-
from pkg_resources import resource_stream
15-
1612
import six
13+
from pkg_resources import resource_stream
14+
from .utils import onWindows
1715

1816
try:
1917
import queue # type: ignore
2018
except ImportError:
2119
import Queue as queue # type: ignore
20+
if os.name == 'posix' and sys.version_info[0] < 3:
21+
import subprocess32 as subprocess # type: ignore
22+
else:
23+
import subprocess # type: ignore
24+
2225

2326
class JavascriptException(Exception):
2427
pass
@@ -194,7 +197,7 @@ def terminate():
194197

195198
PROCESS_FINISHED_STR = "r1cepzbhUTxtykz5XTC4\n"
196199

197-
def process_finished(): # type: () -> bool
200+
def process_finished(): # type: () -> bool
198201
return stdout_buf.getvalue().decode('utf-8').endswith(PROCESS_FINISHED_STR) and \
199202
stderr_buf.getvalue().decode('utf-8').endswith(PROCESS_FINISHED_STR)
200203

@@ -363,4 +366,4 @@ def fn_linenum(): # type: () -> Text
363366
return json.loads(stdout)
364367
except ValueError as e:
365368
raise JavascriptException(u"%s\nscript was:\n%s\nstdout was: '%s'\nstderr was: '%s'\n" %
366-
(e, fn_linenum(), stdout, stderr))
369+
(e, fn_linenum(), stdout, stderr))

0 commit comments

Comments
 (0)