Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

merge new changes #1

Merged
merged 4 commits into from
Mar 3, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions cwltool/cwlNodeEngine.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"use strict";
process.stdin.setEncoding('utf8');
process.stdin.setEncoding("utf8");
var incoming = "";
process.stdin.on('data', function(chunk) {
process.stdin.on("data", function(chunk) {
incoming += chunk;
var i = incoming.indexOf("\n");
if (i > -1) {
Expand All @@ -10,4 +10,4 @@ process.stdin.on('data', function(chunk) {
process.stdout.write(JSON.stringify(require("vm").runInNewContext(fn, {})) + "\n");
}
});
process.stdin.on('end', process.exit);
process.stdin.on("end", process.exit);
25 changes: 16 additions & 9 deletions cwltool/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,15 +135,22 @@ def run(self, dry_run=False, pull_image=True, rm_container=True,

img_id = None
env = None # type: Union[MutableMapping[Text, Text], MutableMapping[str, str]]
if docker_req and kwargs.get("use_container") is not False:
env = os.environ
img_id = docker.get_from_requirements(docker_req, docker_is_req, pull_image)
elif kwargs.get("default_container", None) is not None:
env = os.environ
img_id = kwargs.get("default_container")

if docker_is_req and img_id is None:
raise WorkflowException("Docker is required for running this tool.")
try:
if docker_req and kwargs.get("use_container") is not False:
env = os.environ
img_id = docker.get_from_requirements(docker_req, True, pull_image)
elif kwargs.get("default_container", None) is not None:
env = os.environ
img_id = kwargs.get("default_container")

if docker_req and img_id is None and kwargs.get("use_container"):
raise Exception("Docker image not available")
except Exception as e:
_logger.debug("Docker error", exc_info=True)
if docker_is_req:
raise WorkflowException("Docker is required to run this tool: %s" % e)
else:
raise WorkflowException("Docker is not available for this tool, try --no-container to disable Docker: %s" % e)

if img_id:
runtime = ["docker", "run", "-i"]
Expand Down
50 changes: 30 additions & 20 deletions cwltool/sandboxjs.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,15 @@ def new_js_proc():
trynodes = ("nodejs", "node")
for n in trynodes:
try:
nodejs = subprocess.Popen([n, "--eval", nodecode], stdin=subprocess.PIPE, stdout=subprocess.PIPE,
if subprocess.check_output([n, "--eval", "process.stdout.write('t')"]) != "t":
continue
nodejs = subprocess.Popen([n, "--eval", nodecode],
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
break
except subprocess.CalledProcessError:
pass
except OSError as e:
if e.errno == errno.ENOENT:
pass
Expand Down Expand Up @@ -103,26 +109,28 @@ def term():
stdout_buf = BytesIO()
stderr_buf = BytesIO()

completed = [] # type: List[BytesIO]
while len(completed) < 3:
rready, wready, _ = select.select([nodejs.stdout, nodejs.stderr], [nodejs.stdin], [])
if nodejs.stdin in wready:
b = stdin_buf.read(select.PIPE_BUF)
if b:
os.write(nodejs.stdin.fileno(), b)
elif stdin_buf not in completed:
completed.append(stdin_buf)
for pipes in ((nodejs.stdout, stdout_buf), (nodejs.stderr, stderr_buf)):
if pipes[0] in rready:
b = os.read(pipes[0].fileno(), select.PIPE_BUF)
rselect = [nodejs.stdout, nodejs.stderr] # type: List[BytesIO]
wselect = [nodejs.stdin] # type: List[BytesIO]
while (len(wselect) + len(rselect)) > 0:
rready, wready, _ = select.select(rselect, wselect, [])
try:
if nodejs.stdin in wready:
b = stdin_buf.read(select.PIPE_BUF)
if b:
pipes[1].write(b)
elif pipes[1] not in completed:
completed.append(pipes[1])
if stdout_buf.getvalue().endswith("\n"):
for buf in (stdout_buf, stderr_buf):
if buf not in completed:
completed.append(buf)
os.write(nodejs.stdin.fileno(), b)
else:
wselect = []
for pipes in ((nodejs.stdout, stdout_buf), (nodejs.stderr, stderr_buf)):
if pipes[0] in rready:
b = os.read(pipes[0].fileno(), select.PIPE_BUF)
if b:
pipes[1].write(b)
else:
rselect.remove(pipes[0])
if stdout_buf.getvalue().endswith("\n"):
rselect = []
except OSError as e:
break
tm.cancel()

stdin_buf.close()
Expand All @@ -143,6 +151,8 @@ def stdfmt(data): # type: (unicode) -> unicode
return "\n" + data.strip()
return data

nodejs.poll()

if debug:
info = u"returncode was: %s\nscript was:\n%s\nstdout was: %s\nstderr was: %s\n" %\
(nodejs.returncode, fn_linenum(), stdfmt(stdoutdata), stdfmt(stderrdata))
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ ruamel.yaml==0.13.7
rdflib==4.2.1
rdflib-jsonld==0.4.0
shellescape==3.4.1
schema-salad>=2.1.20170208112505,<3
schema-salad>=2.3.20170302225134,<3
typing==3.5.2.2 ; python_version>="2.7"
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
'ruamel.yaml >= 0.12.4',
'rdflib >= 4.2.2, < 4.3.0',
'shellescape >= 3.4.1, < 3.5',
'schema-salad >= 2.2.20170222151604, < 3',
'schema-salad >= 2.3.20170302225134, < 3',
'typing >= 3.5.2, < 3.6',
'six >= 1.10.0',

Expand Down
6 changes: 6 additions & 0 deletions tests/test_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import cwltool.process
import cwltool.workflow
from .util import get_data
from cwltool.main import main

class TestParamMatching(unittest.TestCase):
def test_params(self):
Expand Down Expand Up @@ -336,6 +337,11 @@ def test_lifting(self):
echo = f.make(get_data("tests/test_bad_outputs_wf.cwl"))
self.assertEqual(echo(inp="foo"), {"out": "foo\n"})

class TestPrintDot(unittest.TestCase):
def test_print_dot(self):
# Require that --enable-ext is provided.
self.assertEquals(main(["--print-dot", get_data('tests/wf/revsort.cwl')]), 0)


if __name__ == '__main__':
unittest.main()
4 changes: 2 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ deps = -rrequirements.txt
commands = make mypy
whitelist_externals = make
deps =
mypy>=0.470
mypy==0.470
typed-ast==0.6.3
-rrequirements.txt

[testenv:py35-mypy]
commands = make mypy3
whitelist_externals = make
deps =
mypy>=0.470
mypy==0.470
typed-ast==0.6.3
-rrequirements.txt

Expand Down