-
-
Notifications
You must be signed in to change notification settings - Fork 232
sandboxjs.py: check for valid version of node/nodejs engine #337
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
Conversation
manu-chroma
commented
Mar 16, 2017
- raises runtime exception if install node version is below a threshold version.
- Fixes check for valid version of node / nodejs #254
- added tests
Can one of the admins verify this patch? |
cd9b6e2
to
cea0de1
Compare
the build is failing for python2 because of dependency tests were passing locally when running |
cwltool/sandboxjs.py
Outdated
v1, v2, v3 = [int(v) for v in subprocess.check_output( | ||
[working_alias, "-v"]).decode('ascii').strip().strip('v').split('.')] | ||
|
||
print(v1, v2, v3) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be removed
cwltool/sandboxjs.py
Outdated
print(v1, v2, v3) | ||
|
||
if v1 == 0 and v2 <= 10 and v3 <= 25: | ||
return "Failed" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please return a boolean
Jenkins, okay to test FYI, @manu-chroma no need to tag me in issues or pull requests, I subscribe to the entire repository |
got it. sorry for unnecessary tagging. |
i've made the necessary changes. conflicting requirement for
i tested locally by bumping up |
@manu-chroma Can you examine the conformance test failures at https://ci.commonwl.org/job/cwltool-pr-conformance-multiver/208/version=v1.0/console ? |
67219c8
to
653aacb
Compare
hey @mr-c, i've encountered this rather weird error:
travis gave me error: https://travis-ci.org/common-workflow-language/cwltool/jobs/211874138
travis passed without any errors. I'm having look at jenkins log. I'll try to figure out and see what's going wrong with that. thanks. |
also, im not able to dissect error log from the jenkins build: https://ci.commonwl.org/job/cwltool-pr-conformance-multiver/219/version=v1.0/console this expression evaluation error in the build log is the error for almost all failing tests.
|
Try running a single test with For example: |
cwltool/sandboxjs.py
Outdated
""" parse node version: 'v4.2.6\n' -> ['4', '2', '6'], | ||
https://github.com/nodejs/node/blob/master/CHANGELOG.md#nodejs-changelog """ | ||
|
||
v1, v2, v3 = [int(v) for v in subprocess.check_output( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mr-c after lot's of debugging, I've come to understand that calling subprocess.check_output
is the reason for failure. can I not invoke subprocess
here?
count-lines3-wf.cwl
count-lines3-job.json
Running (venv) manu@hp:~/github/cwltool$ cwltool --debug v1.0/count-lines3-wf.cwl v1.0/count-lines3-job.json
/home/manu/github/cwltool/venv/bin/cwltool 1.0.20170322174222
Resolved 'v1.0/count-lines3-wf.cwl' to 'file:///home/manu/github/cwltool/v1.0/count-lines3-wf.cwl'
[workflow count-lines3-wf.cwl] initialized from file:///home/manu/github/cwltool/v1.0/count-lines3-wf.cwl
[workflow count-lines3-wf.cwl] workflow starting
[workflow count-lines3-wf.cwl] starting step step1
[job step1] initializing from file:///home/manu/github/cwltool/v1.0/wc2-tool.cwl as part of step step1
[job step1] {
"file1": {
"class": "File",
"location": "file:///home/manu/github/cwltool/v1.0/whale.txt",
"basename": "whale.txt"
}
}
[job step1] path mappings is {
"file:///home/manu/github/cwltool/v1.0/whale.txt": [
"/home/manu/github/cwltool/v1.0/whale.txt",
"/tmp/tmpJgFzXN/stg068a1b3b-e7d1-4e1b-8dcf-d14380ab892a/whale.txt",
"File",
true
]
}
[job step1] command line bindings is [
{
"position": [
-1000000,
0
],
"datum": "wc"
},
{
"position": [
0,
"file1"
],
"datum": {
"class": "File",
"location": "file:///home/manu/github/cwltool/v1.0/whale.txt",
"basename": "whale.txt",
"path": "/tmp/tmpJgFzXN/stg068a1b3b-e7d1-4e1b-8dcf-d14380ab892a/whale.txt",
"dirname": "/tmp/tmpJgFzXN/stg068a1b3b-e7d1-4e1b-8dcf-d14380ab892a",
"nameroot": "whale",
"nameext": ".txt"
}
}
]
[job step1] /tmp/tmpDHty4M$ wc \
/tmp/tmpJgFzXN/stg068a1b3b-e7d1-4e1b-8dcf-d14380ab892a/whale.txt > /tmp/tmpDHty4M/output.txt
Error collecting output for parameter 'output'
Traceback (most recent call last):
File "/home/manu/github/cwltool/cwltool/draft2tool.py", line 412, in collect_output_ports
compute_checksum=compute_checksum)
File "/home/manu/github/cwltool/cwltool/draft2tool.py", line 507, in collect_output
r = builder.do_eval(binding["outputEval"], context=r)
File "build/bdist.linux-x86_64/egg/schema_salad/sourceline.py", line 150, in __exit__
raise self.makeError(unicode(exc_value))
WorkflowException: v1.0/wc2-tool.cwl:15:9: Expression evaluation error:
v1.0/wc2-tool.cwl:15:9: [Errno 2] No such file or directory
[job step1] Job error:
v1.0/wc2-tool.cwl:10:7: Error collecting output for parameter 'output':
v1.0/wc2-tool.cwl:15:9: Expression evaluation error:
v1.0/wc2-tool.cwl:15:9: [Errno 2] No such file or directory
[job step1] completed permanentFail
[job step1] {}
[job step1] Removing input staging directory /tmp/tmpJgFzXN
[job step1] Removing temporary directory /tmp/tmpI28oH8
Workflow cannot make any more progress.
Removing intermediate output directory /tmp/tmpeEQn7D
Final process status is permanentFail im afraid the traceback wasn't very useful. I tried making changes to |
|
60f1a25
to
a2af80a
Compare
mock is used to mock output from subprocess in tests. this is a standard module in py3 but no present in py27, that's why this dependency
- raises runtime exception if install node version is below a threshold version. - Fixes common-workflow-language#254
cwltool/sandboxjs.py
Outdated
raise Runtime Exception. Such a test won't be required for docker nodejs""" | ||
if nodejs is not None: | ||
if check_js_threshold_version(working_alias) is False: | ||
raise JavascriptException(u"cwltool requires updated version of Node.js engine. " |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
refactor out required version of node.js engine and share the required version with the user
tests/test_js_sandbox.py
Outdated
|
||
def test_node_version(self): | ||
subprocess.check_output = Mock(return_value=b'v0.8.26\n') | ||
self.assertEquals(check_js_threshold_version('node'), False) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably need to undo the monkey patching at the end of this test
cwltool/sandboxjs.py
Outdated
except Exception as e: | ||
_logger.debug(str(e)) | ||
_logger.debug("Calling subprocess failed") | ||
return True |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't return true in the event of an exception
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
exception is from working_alias = None
cwltool/sandboxjs.py
Outdated
for n in trynodes: | ||
try: | ||
if subprocess.check_output([n, "--eval", "process.stdout.write('t')"]) != "t": | ||
working_alias = n |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this branch means that node wasn't found (or found to be working for the trivial example)
I'd put your check for the correct version as the else
to this if
using n
as your working_alias
@mr-c, thanks for the review. I'll fix these errors tomo. I tried re-running this workflow mentioned in prev comments (from the (venv) [venv] ~/github/common-workflow-language/v1.0 · (master±) $
cwl-runner --debug count-lines3-wf.cwl count-lines3-job.json
/home/manu/Desktop/cwltool/venv/bin/cwl-runner 1.0.20170524155638
Resolved 'count-lines3-wf.cwl' to 'file:///home/manu/github/common-workflow-language/v1.0/count-lines3-wf.cwl'
Tool definition failed validation:
count-lines3-wf.cwl:17:1: checking field `steps`
count-lines3-wf.cwl:18:3: checking object `count-lines3-wf.cwl#step1`
count-lines3-wf.cwl:19:5: Field `run` contains undefined reference to `file:///home/manu/github/common-workflow-language/v1.0/wc2-tool.cwl`
Traceback (most recent call last):
File "build/bdist.linux-x86_64/egg/cwltool/main.py", line 692, in main
fetcher_constructor=fetcher_constructor)
File "build/bdist.linux-x86_64/egg/cwltool/load_tool.py", line 183, in validate_document
processobj, metadata = document_loader.resolve_all(workflowobj, fileuri)
File "build/bdist.linux-x86_64/egg/schema_salad/ref_resolver.py", line 828, in resolve_all
self.validate_links(document, u"", all_doc_ids)
File "build/bdist.linux-x86_64/egg/schema_salad/ref_resolver.py", line 988, in validate_links
raise errors[0]
ValidationException: count-lines3-wf.cwl:17:1: checking field `steps`
count-lines3-wf.cwl:18:3: checking object `count-lines3-wf.cwl#step1`
count-lines3-wf.cwl:19:5: Field `run` contains undefined reference to `file:///home/manu/github/common-workflow-language/v1.0/wc2-tool.cwl` Is this a potential issue or am I doing something wrong? |
@manu-chroma Did you move some files around? The path to that workflow is |
Yes, I had moved these files one folder up for some reason and was running them from there. I'm able to get the correct output now. Didn't check the backtrace properly to realize there was missing workflow file which caused the error. Thanks! |
- better method to cmp versions - remove tests monkey patch - better condition checking while raising exceptions
@mr-c, I've made some changes here. Few notes:
|
cwltool/main.py
Outdated
else: | ||
_logger.info(versionfunc()) | ||
# else: | ||
# _logger.info(versionfunc()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed this in later commit.
Thanks! |
@mr-c you could've have squashed and merged the PR. Some of the commit messages were poorly written this time. |