1 # Copyright (C) The Arvados Authors. All rights reserved.
3 # SPDX-License-Identifier: Apache-2.0
16 import arvados.collection
18 import arvados_cwl.runner
21 from .matcher import JsonDiffMatcher, StripYAMLComments
22 from .mock_discovery import get_rootDesc
24 import ruamel.yaml as yaml
29 @functools.wraps(func)
30 @mock.patch("arvados.commands.keepdocker.list_images_in_arv")
31 @mock.patch("arvados.collection.KeepClient")
32 @mock.patch("arvados.keep.KeepClient")
33 @mock.patch("arvados.events.subscribe")
34 def wrapped(self, events, keep_client1, keep_client2, keepdocker, *args, **kwargs):
39 stubs.keepdocker = keepdocker
41 def putstub(p, **kwargs):
42 return "%s+%i" % (hashlib.md5(p).hexdigest(), len(p))
43 keep_client1().put.side_effect = putstub
44 keep_client1.put.side_effect = putstub
45 keep_client2().put.side_effect = putstub
46 keep_client2.put.side_effect = putstub
48 stubs.keep_client = keep_client2
49 stubs.keepdocker.return_value = [("zzzzz-4zz18-zzzzzzzzzzzzzz3", "")]
50 stubs.fake_user_uuid = "zzzzz-tpzed-zzzzzzzzzzzzzzz"
52 stubs.api = mock.MagicMock()
53 stubs.api._rootDesc = get_rootDesc()
55 stubs.api.users().current().execute.return_value = {
56 "uuid": stubs.fake_user_uuid,
58 stubs.api.collections().list().execute.return_value = {"items": []}
60 class CollectionExecute(object):
61 def __init__(self, exe):
63 def execute(self, num_retries=None):
66 def collection_createstub(created_collections, body, ensure_unique_name=None):
67 mt = body["manifest_text"]
68 uuid = "zzzzz-4zz18-zzzzzzzzzzzzzz%d" % len(created_collections)
69 pdh = "%s+%i" % (hashlib.md5(mt).hexdigest(), len(mt))
70 created_collections[uuid] = {
72 "portable_data_hash": pdh,
75 return CollectionExecute(created_collections[uuid])
77 def collection_getstub(created_collections, uuid):
78 for v in created_collections.itervalues():
79 if uuid in (v["uuid"], v["portable_data_hash"]):
80 return CollectionExecute(v)
82 created_collections = {
83 "99999999999999999999999999999998+99": {
85 "portable_data_hash": "99999999999999999999999999999998+99",
86 "manifest_text": ". 99999999999999999999999999999998+99 0:0:file1.txt"
88 "99999999999999999999999999999994+99": {
90 "portable_data_hash": "99999999999999999999999999999994+99",
91 "manifest_text": ". 99999999999999999999999999999994+99 0:0:expect_arvworkflow.cwl"
94 stubs.api.collections().create.side_effect = functools.partial(collection_createstub, created_collections)
95 stubs.api.collections().get.side_effect = functools.partial(collection_getstub, created_collections)
97 stubs.expect_job_uuid = "zzzzz-8i9sb-zzzzzzzzzzzzzzz"
98 stubs.api.jobs().create().execute.return_value = {
99 "uuid": stubs.expect_job_uuid,
103 stubs.expect_container_request_uuid = "zzzzz-xvhdp-zzzzzzzzzzzzzzz"
104 stubs.api.container_requests().create().execute.return_value = {
105 "uuid": stubs.expect_container_request_uuid,
106 "container_uuid": "zzzzz-dz642-zzzzzzzzzzzzzzz",
110 stubs.expect_pipeline_template_uuid = "zzzzz-d1hrv-zzzzzzzzzzzzzzz"
111 stubs.api.pipeline_templates().create().execute.return_value = {
112 "uuid": stubs.expect_pipeline_template_uuid,
114 stubs.expect_job_spec = {
115 'runtime_constraints': {
116 'docker_image': 'arvados/jobs:'+arvados_cwl.__version__,
117 'min_ram_mb_per_node': 1024
119 'script_parameters': {
121 'basename': 'blorp.txt',
122 'location': 'keep:169f39d466a5438ac4a90e779bf750c7+53/blorp.txt',
126 'basename': '99999999999999999999999999999998+99',
127 'location': 'keep:99999999999999999999999999999998+99',
131 'basename': 'anonymous',
133 "basename": "renamed.txt",
135 "location": "keep:99999999999999999999999999999998+99/file1.txt"
139 'cwl:tool': '3fffdeaa75e018172e1b583425f4ebff+60/workflow.cwl#main'
141 'repository': 'arvados',
142 'script_version': 'master',
143 'minimum_script_version': '570509ab4d2ef93d870fd2b1f2eab178afb1bad9',
144 'script': 'cwl-runner'
146 stubs.pipeline_component = stubs.expect_job_spec.copy()
147 stubs.expect_pipeline_instance = {
148 'name': 'submit_wf.cwl',
149 'state': 'RunningOnServer',
153 'runtime_constraints': {'docker_image': 'arvados/jobs:'+arvados_cwl.__version__, 'min_ram_mb_per_node': 1024},
154 'script_parameters': {
155 'y': {"value": {'basename': '99999999999999999999999999999998+99', 'location': 'keep:99999999999999999999999999999998+99', 'class': 'Directory'}},
157 'basename': 'blorp.txt',
159 'location': 'keep:169f39d466a5438ac4a90e779bf750c7+53/blorp.txt',
162 'z': {"value": {'basename': 'anonymous', 'class': 'Directory',
165 'basename': 'renamed.txt',
166 'class': 'File', 'location':
167 'keep:99999999999999999999999999999998+99/file1.txt'
170 'cwl:tool': '3fffdeaa75e018172e1b583425f4ebff+60/workflow.cwl#main',
171 'arv:enable_reuse': True,
172 'arv:on_error': 'continue'
174 'repository': 'arvados',
175 'script_version': 'master',
176 'minimum_script_version': '570509ab4d2ef93d870fd2b1f2eab178afb1bad9',
177 'script': 'cwl-runner',
178 'job': {'state': 'Queued', 'uuid': 'zzzzz-8i9sb-zzzzzzzzzzzzzzz'}
182 stubs.pipeline_create = copy.deepcopy(stubs.expect_pipeline_instance)
183 stubs.expect_pipeline_uuid = "zzzzz-d1hrv-zzzzzzzzzzzzzzz"
184 stubs.pipeline_create["uuid"] = stubs.expect_pipeline_uuid
185 stubs.pipeline_with_job = copy.deepcopy(stubs.pipeline_create)
186 stubs.pipeline_with_job["components"]["cwl-runner"]["job"] = {
187 "uuid": "zzzzz-8i9sb-zzzzzzzzzzzzzzz",
190 stubs.api.pipeline_instances().create().execute.return_value = stubs.pipeline_create
191 stubs.api.pipeline_instances().get().execute.return_value = stubs.pipeline_with_job
193 with open("tests/wf/submit_wf_packed.cwl") as f:
194 expect_packed_workflow = yaml.round_trip_load(f)
196 stubs.expect_container_spec = {
203 '/var/lib/cwl/workflow.json': {
204 'content': expect_packed_workflow,
208 'path': '/var/spool/cwl/cwl.output.json',
211 '/var/lib/cwl/cwl.input.json': {
215 'basename': '99999999999999999999999999999998+99',
216 'location': 'keep:99999999999999999999999999999998+99',
217 'class': 'Directory'},
219 'basename': u'blorp.txt',
221 'location': u'keep:169f39d466a5438ac4a90e779bf750c7+53/blorp.txt',
224 'z': {'basename': 'anonymous', 'class': 'Directory', 'listing': [
225 {'basename': 'renamed.txt',
227 'location': 'keep:99999999999999999999999999999998+99/file1.txt'
234 'state': 'Committed',
236 'command': ['arvados-cwl-runner', '--local', '--api=containers', '--no-log-timestamps',
237 '--enable-reuse', '--on-error=continue',
238 '/var/lib/cwl/workflow.json#main', '/var/lib/cwl/cwl.input.json'],
239 'name': 'submit_wf.cwl',
240 'container_image': 'arvados/jobs:'+arvados_cwl.__version__,
241 'output_path': '/var/spool/cwl',
242 'cwd': '/var/spool/cwl',
243 'runtime_constraints': {
246 'ram': 1024*1024*1024
248 'use_existing': True,
252 stubs.expect_workflow_uuid = "zzzzz-7fd4e-zzzzzzzzzzzzzzz"
253 stubs.api.workflows().create().execute.return_value = {
254 "uuid": stubs.expect_workflow_uuid,
256 def update_mock(**kwargs):
257 stubs.updated_uuid = kwargs.get('uuid')
259 stubs.api.workflows().update.side_effect = update_mock
260 stubs.api.workflows().update().execute.side_effect = lambda **kwargs: {
261 "uuid": stubs.updated_uuid,
264 return func(self, stubs, *args, **kwargs)
268 class TestSubmit(unittest.TestCase):
269 @mock.patch("arvados_cwl.runner.arv_docker_get_image")
270 @mock.patch("time.sleep")
272 def test_submit(self, stubs, tm, arvdock):
273 capture_stdout = cStringIO.StringIO()
274 exited = arvados_cwl.main(
275 ["--submit", "--no-wait", "--api=jobs", "--debug",
276 "tests/wf/submit_wf.cwl", "tests/submit_test_job.json"],
277 capture_stdout, sys.stderr, api_client=stubs.api)
278 self.assertEqual(exited, 0)
280 stubs.api.collections().create.assert_has_calls([
281 mock.call(body=JsonDiffMatcher({
283 '. 5bcc9fe8f8d5992e6cf418dc7ce4dbb3+16 0:16:blub.txt\n',
284 'replication_desired': None,
285 'name': 'submit_tool.cwl dependencies',
286 }), ensure_unique_name=True),
287 mock.call(body=JsonDiffMatcher({
289 '. 979af1245a12a1fed634d4222473bfdc+16 0:16:blorp.txt\n',
290 'replication_desired': None,
291 'name': 'submit_wf.cwl input',
292 }), ensure_unique_name=True),
293 mock.call(body=JsonDiffMatcher({
295 '. 61df2ed9ee3eb7dd9b799e5ca35305fa+1217 0:1217:workflow.cwl\n',
296 'replication_desired': None,
297 'name': 'submit_wf.cwl',
298 }), ensure_unique_name=True) ])
300 arvdock.assert_has_calls([
301 mock.call(stubs.api, {"class": "DockerRequirement", "dockerPull": "debian:8"}, True, None),
302 mock.call(stubs.api, {'dockerPull': 'arvados/jobs:'+arvados_cwl.__version__}, True, None)
305 expect_pipeline = copy.deepcopy(stubs.expect_pipeline_instance)
306 stubs.api.pipeline_instances().create.assert_called_with(
307 body=JsonDiffMatcher(expect_pipeline))
308 self.assertEqual(capture_stdout.getvalue(),
309 stubs.expect_pipeline_uuid + '\n')
312 @mock.patch("time.sleep")
314 def test_submit_no_reuse(self, stubs, tm):
315 capture_stdout = cStringIO.StringIO()
316 exited = arvados_cwl.main(
317 ["--submit", "--no-wait", "--api=jobs", "--debug", "--disable-reuse",
318 "tests/wf/submit_wf.cwl", "tests/submit_test_job.json"],
319 capture_stdout, sys.stderr, api_client=stubs.api)
320 self.assertEqual(exited, 0)
322 expect_pipeline = copy.deepcopy(stubs.expect_pipeline_instance)
323 expect_pipeline["components"]["cwl-runner"]["script_parameters"]["arv:enable_reuse"] = {"value": False}
324 expect_pipeline["properties"] = {"run_options": {"enable_job_reuse": False}}
326 stubs.api.pipeline_instances().create.assert_called_with(
327 body=JsonDiffMatcher(expect_pipeline))
328 self.assertEqual(capture_stdout.getvalue(),
329 stubs.expect_pipeline_uuid + '\n')
331 @mock.patch("time.sleep")
333 def test_submit_on_error(self, stubs, tm):
334 capture_stdout = cStringIO.StringIO()
335 exited = arvados_cwl.main(
336 ["--submit", "--no-wait", "--api=jobs", "--debug", "--on-error=stop",
337 "tests/wf/submit_wf.cwl", "tests/submit_test_job.json"],
338 capture_stdout, sys.stderr, api_client=stubs.api)
339 self.assertEqual(exited, 0)
341 expect_pipeline = copy.deepcopy(stubs.expect_pipeline_instance)
342 expect_pipeline["components"]["cwl-runner"]["script_parameters"]["arv:on_error"] = "stop"
344 stubs.api.pipeline_instances().create.assert_called_with(
345 body=JsonDiffMatcher(expect_pipeline))
346 self.assertEqual(capture_stdout.getvalue(),
347 stubs.expect_pipeline_uuid + '\n')
350 @mock.patch("time.sleep")
352 def test_submit_runner_ram(self, stubs, tm):
353 capture_stdout = cStringIO.StringIO()
354 exited = arvados_cwl.main(
355 ["--submit", "--no-wait", "--debug", "--submit-runner-ram=2048",
356 "tests/wf/submit_wf.cwl", "tests/submit_test_job.json"],
357 capture_stdout, sys.stderr, api_client=stubs.api)
358 self.assertEqual(exited, 0)
360 expect_pipeline = copy.deepcopy(stubs.expect_pipeline_instance)
361 expect_pipeline["components"]["cwl-runner"]["runtime_constraints"]["min_ram_mb_per_node"] = 2048
363 stubs.api.pipeline_instances().create.assert_called_with(
364 body=JsonDiffMatcher(expect_pipeline))
365 self.assertEqual(capture_stdout.getvalue(),
366 stubs.expect_pipeline_uuid + '\n')
369 @mock.patch("time.sleep")
371 def test_submit_invalid_runner_ram(self, stubs, tm):
372 capture_stdout = cStringIO.StringIO()
373 exited = arvados_cwl.main(
374 ["--submit", "--no-wait", "--debug", "--submit-runner-ram=-2048",
375 "tests/wf/submit_wf.cwl", "tests/submit_test_job.json"],
376 capture_stdout, sys.stderr, api_client=stubs.api)
377 self.assertEqual(exited, 1)
379 @mock.patch("time.sleep")
381 def test_submit_output_name(self, stubs, tm):
382 output_name = "test_output_name"
384 capture_stdout = cStringIO.StringIO()
385 exited = arvados_cwl.main(
386 ["--submit", "--no-wait", "--debug", "--output-name", output_name,
387 "tests/wf/submit_wf.cwl", "tests/submit_test_job.json"],
388 capture_stdout, sys.stderr, api_client=stubs.api)
389 self.assertEqual(exited, 0)
391 expect_pipeline = copy.deepcopy(stubs.expect_pipeline_instance)
392 expect_pipeline["components"]["cwl-runner"]["script_parameters"]["arv:output_name"] = output_name
394 stubs.api.pipeline_instances().create.assert_called_with(
395 body=JsonDiffMatcher(expect_pipeline))
396 self.assertEqual(capture_stdout.getvalue(),
397 stubs.expect_pipeline_uuid + '\n')
400 @mock.patch("time.sleep")
402 def test_submit_pipeline_name(self, stubs, tm):
403 capture_stdout = cStringIO.StringIO()
404 exited = arvados_cwl.main(
405 ["--submit", "--no-wait", "--debug", "--name=hello job 123",
406 "tests/wf/submit_wf.cwl", "tests/submit_test_job.json"],
407 capture_stdout, sys.stderr, api_client=stubs.api)
408 self.assertEqual(exited, 0)
410 expect_pipeline = copy.deepcopy(stubs.expect_pipeline_instance)
411 expect_pipeline["name"] = "hello job 123"
413 stubs.api.pipeline_instances().create.assert_called_with(
414 body=JsonDiffMatcher(expect_pipeline))
415 self.assertEqual(capture_stdout.getvalue(),
416 stubs.expect_pipeline_uuid + '\n')
418 @mock.patch("time.sleep")
420 def test_submit_output_tags(self, stubs, tm):
421 output_tags = "tag0,tag1,tag2"
423 capture_stdout = cStringIO.StringIO()
424 exited = arvados_cwl.main(
425 ["--submit", "--no-wait", "--debug", "--output-tags", output_tags,
426 "tests/wf/submit_wf.cwl", "tests/submit_test_job.json"],
427 capture_stdout, sys.stderr, api_client=stubs.api)
428 self.assertEqual(exited, 0)
430 expect_pipeline = copy.deepcopy(stubs.expect_pipeline_instance)
431 expect_pipeline["components"]["cwl-runner"]["script_parameters"]["arv:output_tags"] = output_tags
433 stubs.api.pipeline_instances().create.assert_called_with(
434 body=JsonDiffMatcher(expect_pipeline))
435 self.assertEqual(capture_stdout.getvalue(),
436 stubs.expect_pipeline_uuid + '\n')
438 @mock.patch("time.sleep")
440 def test_submit_with_project_uuid(self, stubs, tm):
441 project_uuid = 'zzzzz-j7d0g-zzzzzzzzzzzzzzz'
443 exited = arvados_cwl.main(
444 ["--submit", "--no-wait",
445 "--project-uuid", project_uuid,
446 "tests/wf/submit_wf.cwl", "tests/submit_test_job.json"],
447 sys.stdout, sys.stderr, api_client=stubs.api)
448 self.assertEqual(exited, 0)
450 expect_pipeline = copy.deepcopy(stubs.expect_pipeline_instance)
451 expect_pipeline["owner_uuid"] = project_uuid
452 stubs.api.pipeline_instances().create.assert_called_with(
453 body=JsonDiffMatcher(expect_pipeline))
456 def test_submit_container(self, stubs):
457 capture_stdout = cStringIO.StringIO()
459 exited = arvados_cwl.main(
460 ["--submit", "--no-wait", "--api=containers", "--debug",
461 "tests/wf/submit_wf.cwl", "tests/submit_test_job.json"],
462 capture_stdout, sys.stderr, api_client=stubs.api, keep_client=stubs.keep_client)
463 self.assertEqual(exited, 0)
465 logging.exception("")
467 stubs.api.collections().create.assert_has_calls([
468 mock.call(body=JsonDiffMatcher({
470 '. 5bcc9fe8f8d5992e6cf418dc7ce4dbb3+16 0:16:blub.txt\n',
471 'replication_desired': None,
472 'name': 'submit_tool.cwl dependencies',
473 }), ensure_unique_name=True),
474 mock.call(body=JsonDiffMatcher({
476 '. 979af1245a12a1fed634d4222473bfdc+16 0:16:blorp.txt\n',
477 'replication_desired': None,
478 'name': 'submit_wf.cwl input',
479 }), ensure_unique_name=True)])
481 expect_container = copy.deepcopy(stubs.expect_container_spec)
482 stubs.api.container_requests().create.assert_called_with(
483 body=JsonDiffMatcher(expect_container))
484 self.assertEqual(capture_stdout.getvalue(),
485 stubs.expect_container_request_uuid + '\n')
488 def test_submit_container_no_reuse(self, stubs):
489 capture_stdout = cStringIO.StringIO()
491 exited = arvados_cwl.main(
492 ["--submit", "--no-wait", "--api=containers", "--debug", "--disable-reuse",
493 "tests/wf/submit_wf.cwl", "tests/submit_test_job.json"],
494 capture_stdout, sys.stderr, api_client=stubs.api, keep_client=stubs.keep_client)
495 self.assertEqual(exited, 0)
497 logging.exception("")
499 expect_container = copy.deepcopy(stubs.expect_container_spec)
500 expect_container["command"] = [
501 'arvados-cwl-runner', '--local', '--api=containers', '--no-log-timestamps',
502 '--disable-reuse', '--on-error=continue',
503 '/var/lib/cwl/workflow.json#main', '/var/lib/cwl/cwl.input.json']
504 expect_container["use_existing"] = False
506 stubs.api.container_requests().create.assert_called_with(
507 body=JsonDiffMatcher(expect_container))
508 self.assertEqual(capture_stdout.getvalue(),
509 stubs.expect_container_request_uuid + '\n')
513 def test_submit_container_reuse_disabled_by_workflow(self, stubs):
514 capture_stdout = cStringIO.StringIO()
516 exited = arvados_cwl.main(
517 ["--submit", "--no-wait", "--api=containers", "--debug",
518 "tests/wf/submit_wf_no_reuse.cwl", "tests/submit_test_job.json"],
519 capture_stdout, sys.stderr, api_client=stubs.api, keep_client=stubs.keep_client)
520 self.assertEqual(exited, 0)
522 expect_container = copy.deepcopy(stubs.expect_container_spec)
523 expect_container["command"] = [
524 'arvados-cwl-runner', '--local', '--api=containers', '--no-log-timestamps',
525 '--disable-reuse', '--on-error=continue',
526 '/var/lib/cwl/workflow.json#main', '/var/lib/cwl/cwl.input.json']
527 expect_container["use_existing"] = False
528 expect_container["name"] = "submit_wf_no_reuse.cwl"
529 expect_container["mounts"]["/var/lib/cwl/workflow.json"]["content"]["$graph"][1]["hints"] = [
531 "class": "http://arvados.org/cwl#ReuseRequirement",
532 "enableReuse": False,
535 expect_container["mounts"]["/var/lib/cwl/workflow.json"]["content"]["$graph"][0]["$namespaces"] = {
536 "arv": "http://arvados.org/cwl#",
537 "cwltool": "http://commonwl.org/cwltool#"
540 stubs.api.container_requests().create.assert_called_with(
541 body=JsonDiffMatcher(expect_container))
542 self.assertEqual(capture_stdout.getvalue(),
543 stubs.expect_container_request_uuid + '\n')
547 def test_submit_container_on_error(self, stubs):
548 capture_stdout = cStringIO.StringIO()
550 exited = arvados_cwl.main(
551 ["--submit", "--no-wait", "--api=containers", "--debug", "--on-error=stop",
552 "tests/wf/submit_wf.cwl", "tests/submit_test_job.json"],
553 capture_stdout, sys.stderr, api_client=stubs.api, keep_client=stubs.keep_client)
554 self.assertEqual(exited, 0)
556 logging.exception("")
558 expect_container = copy.deepcopy(stubs.expect_container_spec)
559 expect_container["command"] = ['arvados-cwl-runner', '--local', '--api=containers', '--no-log-timestamps',
560 '--enable-reuse', '--on-error=stop',
561 '/var/lib/cwl/workflow.json#main', '/var/lib/cwl/cwl.input.json']
563 stubs.api.container_requests().create.assert_called_with(
564 body=JsonDiffMatcher(expect_container))
565 self.assertEqual(capture_stdout.getvalue(),
566 stubs.expect_container_request_uuid + '\n')
569 def test_submit_container_output_name(self, stubs):
570 output_name = "test_output_name"
572 capture_stdout = cStringIO.StringIO()
574 exited = arvados_cwl.main(
575 ["--submit", "--no-wait", "--api=containers", "--debug", "--output-name", output_name,
576 "tests/wf/submit_wf.cwl", "tests/submit_test_job.json"],
577 capture_stdout, sys.stderr, api_client=stubs.api, keep_client=stubs.keep_client)
578 self.assertEqual(exited, 0)
580 logging.exception("")
582 expect_container = copy.deepcopy(stubs.expect_container_spec)
583 expect_container["command"] = ['arvados-cwl-runner', '--local', '--api=containers', '--no-log-timestamps',
584 "--output-name="+output_name, '--enable-reuse', '--on-error=continue',
585 '/var/lib/cwl/workflow.json#main', '/var/lib/cwl/cwl.input.json']
586 expect_container["output_name"] = output_name
588 stubs.api.container_requests().create.assert_called_with(
589 body=JsonDiffMatcher(expect_container))
590 self.assertEqual(capture_stdout.getvalue(),
591 stubs.expect_container_request_uuid + '\n')
595 def test_submit_container_output_ttl(self, stubs):
596 capture_stdout = cStringIO.StringIO()
598 exited = arvados_cwl.main(
599 ["--submit", "--no-wait", "--api=containers", "--debug", "--intermediate-output-ttl", "3600",
600 "tests/wf/submit_wf.cwl", "tests/submit_test_job.json"],
601 capture_stdout, sys.stderr, api_client=stubs.api, keep_client=stubs.keep_client)
602 self.assertEqual(exited, 0)
604 logging.exception("")
606 expect_container = copy.deepcopy(stubs.expect_container_spec)
607 expect_container["command"] = ['arvados-cwl-runner', '--local', '--api=containers', '--no-log-timestamps',
608 '--enable-reuse', '--on-error=continue',
609 "--intermediate-output-ttl=3600",
610 '/var/lib/cwl/workflow.json#main', '/var/lib/cwl/cwl.input.json']
612 stubs.api.container_requests().create.assert_called_with(
613 body=JsonDiffMatcher(expect_container))
614 self.assertEqual(capture_stdout.getvalue(),
615 stubs.expect_container_request_uuid + '\n')
618 def test_submit_container_trash_intermediate(self, stubs):
619 capture_stdout = cStringIO.StringIO()
621 exited = arvados_cwl.main(
622 ["--submit", "--no-wait", "--api=containers", "--debug", "--trash-intermediate",
623 "tests/wf/submit_wf.cwl", "tests/submit_test_job.json"],
624 capture_stdout, sys.stderr, api_client=stubs.api, keep_client=stubs.keep_client)
625 self.assertEqual(exited, 0)
627 logging.exception("")
629 expect_container = copy.deepcopy(stubs.expect_container_spec)
630 expect_container["command"] = ['arvados-cwl-runner', '--local', '--api=containers', '--no-log-timestamps',
631 '--enable-reuse', '--on-error=continue',
632 "--trash-intermediate",
633 '/var/lib/cwl/workflow.json#main', '/var/lib/cwl/cwl.input.json']
635 stubs.api.container_requests().create.assert_called_with(
636 body=JsonDiffMatcher(expect_container))
637 self.assertEqual(capture_stdout.getvalue(),
638 stubs.expect_container_request_uuid + '\n')
641 def test_submit_container_output_tags(self, stubs):
642 output_tags = "tag0,tag1,tag2"
644 capture_stdout = cStringIO.StringIO()
646 exited = arvados_cwl.main(
647 ["--submit", "--no-wait", "--api=containers", "--debug", "--output-tags", output_tags,
648 "tests/wf/submit_wf.cwl", "tests/submit_test_job.json"],
649 capture_stdout, sys.stderr, api_client=stubs.api, keep_client=stubs.keep_client)
650 self.assertEqual(exited, 0)
652 logging.exception("")
654 expect_container = copy.deepcopy(stubs.expect_container_spec)
655 expect_container["command"] = ['arvados-cwl-runner', '--local', '--api=containers', '--no-log-timestamps',
656 "--output-tags="+output_tags, '--enable-reuse', '--on-error=continue',
657 '/var/lib/cwl/workflow.json#main', '/var/lib/cwl/cwl.input.json']
659 stubs.api.container_requests().create.assert_called_with(
660 body=JsonDiffMatcher(expect_container))
661 self.assertEqual(capture_stdout.getvalue(),
662 stubs.expect_container_request_uuid + '\n')
665 def test_submit_container_runner_ram(self, stubs):
666 capture_stdout = cStringIO.StringIO()
668 exited = arvados_cwl.main(
669 ["--submit", "--no-wait", "--api=containers", "--debug", "--submit-runner-ram=2048",
670 "tests/wf/submit_wf.cwl", "tests/submit_test_job.json"],
671 capture_stdout, sys.stderr, api_client=stubs.api, keep_client=stubs.keep_client)
672 self.assertEqual(exited, 0)
674 logging.exception("")
676 expect_container = copy.deepcopy(stubs.expect_container_spec)
677 expect_container["runtime_constraints"]["ram"] = 2048*1024*1024
679 stubs.api.container_requests().create.assert_called_with(
680 body=JsonDiffMatcher(expect_container))
681 self.assertEqual(capture_stdout.getvalue(),
682 stubs.expect_container_request_uuid + '\n')
684 @mock.patch("arvados.collection.CollectionReader")
685 @mock.patch("time.sleep")
687 def test_submit_file_keepref(self, stubs, tm, collectionReader):
688 capture_stdout = cStringIO.StringIO()
689 exited = arvados_cwl.main(
690 ["--submit", "--no-wait", "--api=containers", "--debug",
691 "tests/wf/submit_keepref_wf.cwl"],
692 capture_stdout, sys.stderr, api_client=stubs.api)
693 self.assertEqual(exited, 0)
696 @mock.patch("arvados.collection.CollectionReader")
697 @mock.patch("time.sleep")
699 def test_submit_keepref(self, stubs, tm, reader):
700 capture_stdout = cStringIO.StringIO()
702 with open("tests/wf/expect_arvworkflow.cwl") as f:
703 reader().open().__enter__().read.return_value = f.read()
705 exited = arvados_cwl.main(
706 ["--submit", "--no-wait", "--api=containers", "--debug",
707 "keep:99999999999999999999999999999994+99/expect_arvworkflow.cwl#main", "-x", "XxX"],
708 capture_stdout, sys.stderr, api_client=stubs.api)
709 self.assertEqual(exited, 0)
719 'path': '/var/spool/cwl/cwl.output.json',
722 '/var/lib/cwl/workflow': {
723 'portable_data_hash': '99999999999999999999999999999994+99',
726 '/var/lib/cwl/cwl.input.json': {
732 }, 'state': 'Committed',
734 'output_path': '/var/spool/cwl',
735 'name': 'expect_arvworkflow.cwl#main',
736 'container_image': 'arvados/jobs:'+arvados_cwl.__version__,
737 'command': ['arvados-cwl-runner', '--local', '--api=containers', '--no-log-timestamps',
738 '--enable-reuse', '--on-error=continue',
739 '/var/lib/cwl/workflow/expect_arvworkflow.cwl#main', '/var/lib/cwl/cwl.input.json'],
740 'cwd': '/var/spool/cwl',
741 'runtime_constraints': {
746 'use_existing': True,
750 stubs.api.container_requests().create.assert_called_with(
751 body=JsonDiffMatcher(expect_container))
752 self.assertEqual(capture_stdout.getvalue(),
753 stubs.expect_container_request_uuid + '\n')
756 @mock.patch("arvados.collection.CollectionReader")
757 @mock.patch("time.sleep")
759 def test_submit_jobs_keepref(self, stubs, tm, reader):
760 capture_stdout = cStringIO.StringIO()
762 with open("tests/wf/expect_arvworkflow.cwl") as f:
763 reader().open().__enter__().read.return_value = f.read()
765 exited = arvados_cwl.main(
766 ["--submit", "--no-wait", "--api=jobs", "--debug",
767 "keep:99999999999999999999999999999994+99/expect_arvworkflow.cwl#main", "-x", "XxX"],
768 capture_stdout, sys.stderr, api_client=stubs.api)
769 self.assertEqual(exited, 0)
771 expect_pipeline = copy.deepcopy(stubs.expect_pipeline_instance)
772 expect_pipeline["components"]["cwl-runner"]["script_parameters"]["x"] = "XxX"
773 del expect_pipeline["components"]["cwl-runner"]["script_parameters"]["y"]
774 del expect_pipeline["components"]["cwl-runner"]["script_parameters"]["z"]
775 expect_pipeline["components"]["cwl-runner"]["script_parameters"]["cwl:tool"] = "99999999999999999999999999999994+99/expect_arvworkflow.cwl#main"
776 expect_pipeline["name"] = "expect_arvworkflow.cwl#main"
777 stubs.api.pipeline_instances().create.assert_called_with(
778 body=JsonDiffMatcher(expect_pipeline))
780 @mock.patch("time.sleep")
782 def test_submit_arvworkflow(self, stubs, tm):
783 capture_stdout = cStringIO.StringIO()
785 with open("tests/wf/expect_arvworkflow.cwl") as f:
786 stubs.api.workflows().get().execute.return_value = {"definition": f.read(), "name": "a test workflow"}
788 exited = arvados_cwl.main(
789 ["--submit", "--no-wait", "--api=containers", "--debug",
790 "962eh-7fd4e-gkbzl62qqtfig37", "-x", "XxX"],
791 capture_stdout, sys.stderr, api_client=stubs.api)
792 self.assertEqual(exited, 0)
802 'path': '/var/spool/cwl/cwl.output.json',
805 '/var/lib/cwl/workflow.json': {
808 'cwlVersion': 'v1.0',
813 {'type': 'string', 'id': '#main/x'}
816 {'in': [{'source': '#main/x', 'id': '#main/step1/x'}],
817 'run': '#submit_tool.cwl',
827 'inputBinding': {'position': 1},
829 'id': '#submit_tool.cwl/x'}
832 {'dockerPull': 'debian:8', 'class': 'DockerRequirement'}
834 'id': '#submit_tool.cwl',
836 'baseCommand': 'cat',
837 'class': 'CommandLineTool'
842 '/var/lib/cwl/cwl.input.json': {
848 }, 'state': 'Committed',
850 'output_path': '/var/spool/cwl',
851 'name': 'a test workflow',
852 'container_image': 'arvados/jobs:'+arvados_cwl.__version__,
853 'command': ['arvados-cwl-runner', '--local', '--api=containers', '--no-log-timestamps',
854 '--enable-reuse', '--on-error=continue',
855 '/var/lib/cwl/workflow.json#main', '/var/lib/cwl/cwl.input.json'],
856 'cwd': '/var/spool/cwl',
857 'runtime_constraints': {
862 'use_existing': True,
864 "template_uuid": "962eh-7fd4e-gkbzl62qqtfig37"
868 stubs.api.container_requests().create.assert_called_with(
869 body=JsonDiffMatcher(expect_container))
870 self.assertEqual(capture_stdout.getvalue(),
871 stubs.expect_container_request_uuid + '\n')
875 def test_submit_container_name(self, stubs):
876 capture_stdout = cStringIO.StringIO()
878 exited = arvados_cwl.main(
879 ["--submit", "--no-wait", "--api=containers", "--debug", "--name=hello container 123",
880 "tests/wf/submit_wf.cwl", "tests/submit_test_job.json"],
881 capture_stdout, sys.stderr, api_client=stubs.api, keep_client=stubs.keep_client)
882 self.assertEqual(exited, 0)
884 logging.exception("")
886 expect_container = copy.deepcopy(stubs.expect_container_spec)
887 expect_container["name"] = "hello container 123"
889 stubs.api.container_requests().create.assert_called_with(
890 body=JsonDiffMatcher(expect_container))
891 self.assertEqual(capture_stdout.getvalue(),
892 stubs.expect_container_request_uuid + '\n')
896 def test_submit_container_project(self, stubs):
897 project_uuid = 'zzzzz-j7d0g-zzzzzzzzzzzzzzz'
898 capture_stdout = cStringIO.StringIO()
900 exited = arvados_cwl.main(
901 ["--submit", "--no-wait", "--api=containers", "--debug", "--project-uuid="+project_uuid,
902 "tests/wf/submit_wf.cwl", "tests/submit_test_job.json"],
903 capture_stdout, sys.stderr, api_client=stubs.api, keep_client=stubs.keep_client)
904 self.assertEqual(exited, 0)
906 logging.exception("")
908 expect_container = copy.deepcopy(stubs.expect_container_spec)
909 expect_container["owner_uuid"] = project_uuid
910 expect_container["command"] = ['arvados-cwl-runner', '--local', '--api=containers', '--no-log-timestamps',
911 '--enable-reuse', '--on-error=continue', '--project-uuid='+project_uuid,
912 '/var/lib/cwl/workflow.json#main', '/var/lib/cwl/cwl.input.json']
914 stubs.api.container_requests().create.assert_called_with(
915 body=JsonDiffMatcher(expect_container))
916 self.assertEqual(capture_stdout.getvalue(),
917 stubs.expect_container_request_uuid + '\n')
921 def test_submit_job_runner_image(self, stubs):
922 capture_stdout = cStringIO.StringIO()
924 exited = arvados_cwl.main(
925 ["--submit", "--no-wait", "--api=jobs", "--debug", "--submit-runner-image=arvados/jobs:123",
926 "tests/wf/submit_wf.cwl", "tests/submit_test_job.json"],
927 capture_stdout, sys.stderr, api_client=stubs.api, keep_client=stubs.keep_client)
928 self.assertEqual(exited, 0)
930 logging.exception("")
932 stubs.expect_pipeline_instance["components"]["cwl-runner"]["runtime_constraints"]["docker_image"] = "arvados/jobs:123"
934 expect_pipeline = copy.deepcopy(stubs.expect_pipeline_instance)
935 stubs.api.pipeline_instances().create.assert_called_with(
936 body=JsonDiffMatcher(expect_pipeline))
937 self.assertEqual(capture_stdout.getvalue(),
938 stubs.expect_pipeline_uuid + '\n')
941 def test_submit_container_runner_image(self, stubs):
942 capture_stdout = cStringIO.StringIO()
944 exited = arvados_cwl.main(
945 ["--submit", "--no-wait", "--api=containers", "--debug", "--submit-runner-image=arvados/jobs:123",
946 "tests/wf/submit_wf.cwl", "tests/submit_test_job.json"],
947 capture_stdout, sys.stderr, api_client=stubs.api, keep_client=stubs.keep_client)
948 self.assertEqual(exited, 0)
950 logging.exception("")
952 stubs.expect_container_spec["container_image"] = "arvados/jobs:123"
954 expect_container = copy.deepcopy(stubs.expect_container_spec)
955 stubs.api.container_requests().create.assert_called_with(
956 body=JsonDiffMatcher(expect_container))
957 self.assertEqual(capture_stdout.getvalue(),
958 stubs.expect_container_request_uuid + '\n')
961 @mock.patch("arvados.commands.keepdocker.find_one_image_hash")
962 @mock.patch("cwltool.docker.get_image")
963 @mock.patch("arvados.api")
964 def test_arvados_jobs_image(self, api, get_image, find_one_image_hash):
965 arvrunner = mock.MagicMock()
966 arvrunner.project_uuid = ""
967 api.return_value = mock.MagicMock()
968 arvrunner.api = api.return_value
969 arvrunner.api.links().list().execute.side_effect = ({"items": [{"created_at": "",
970 "head_uuid": "zzzzz-4zz18-zzzzzzzzzzzzzzb",
971 "link_class": "docker_image_repo+tag",
972 "name": "arvados/jobs:"+arvados_cwl.__version__,
974 "properties": {"image_timestamp": ""}}], "items_available": 1, "offset": 0},
975 {"items": [{"created_at": "",
977 "link_class": "docker_image_hash",
980 "properties": {"image_timestamp": ""}}], "items_available": 1, "offset": 0}
982 find_one_image_hash.return_value = "123456"
984 arvrunner.api.collections().list().execute.side_effect = ({"items": [{"uuid": "zzzzz-4zz18-zzzzzzzzzzzzzzb",
988 }], "items_available": 1, "offset": 0},)
989 arvrunner.api.collections().create().execute.return_value = {"uuid": ""}
990 self.assertEqual("arvados/jobs:"+arvados_cwl.__version__,
991 arvados_cwl.runner.arvados_jobs_image(arvrunner, "arvados/jobs:"+arvados_cwl.__version__))
993 class TestCreateTemplate(unittest.TestCase):
994 existing_template_uuid = "zzzzz-d1hrv-validworkfloyml"
996 def _adjust_script_params(self, expect_component):
997 expect_component['script_parameters']['x'] = {
1001 'value': '169f39d466a5438ac4a90e779bf750c7+53/blorp.txt',
1003 expect_component['script_parameters']['y'] = {
1004 'dataclass': 'Collection',
1006 'type': 'Directory',
1007 'value': '99999999999999999999999999999998+99',
1009 expect_component['script_parameters']['z'] = {
1010 'dataclass': 'Collection',
1012 'type': 'Directory',
1016 def test_create(self, stubs):
1017 project_uuid = 'zzzzz-j7d0g-zzzzzzzzzzzzzzz'
1019 capture_stdout = cStringIO.StringIO()
1021 exited = arvados_cwl.main(
1022 ["--create-workflow", "--debug",
1024 "--project-uuid", project_uuid,
1025 "tests/wf/submit_wf.cwl", "tests/submit_test_job.json"],
1026 capture_stdout, sys.stderr, api_client=stubs.api)
1027 self.assertEqual(exited, 0)
1029 stubs.api.pipeline_instances().create.refute_called()
1030 stubs.api.jobs().create.refute_called()
1032 expect_component = copy.deepcopy(stubs.expect_job_spec)
1033 self._adjust_script_params(expect_component)
1036 "submit_wf.cwl": expect_component,
1038 "name": "submit_wf.cwl",
1039 "owner_uuid": project_uuid,
1041 stubs.api.pipeline_templates().create.assert_called_with(
1042 body=JsonDiffMatcher(expect_template), ensure_unique_name=True)
1044 self.assertEqual(capture_stdout.getvalue(),
1045 stubs.expect_pipeline_template_uuid + '\n')
1049 def test_create_name(self, stubs):
1050 project_uuid = 'zzzzz-j7d0g-zzzzzzzzzzzzzzz'
1052 capture_stdout = cStringIO.StringIO()
1054 exited = arvados_cwl.main(
1055 ["--create-workflow", "--debug",
1056 "--project-uuid", project_uuid,
1058 "--name", "testing 123",
1059 "tests/wf/submit_wf.cwl", "tests/submit_test_job.json"],
1060 capture_stdout, sys.stderr, api_client=stubs.api)
1061 self.assertEqual(exited, 0)
1063 stubs.api.pipeline_instances().create.refute_called()
1064 stubs.api.jobs().create.refute_called()
1066 expect_component = copy.deepcopy(stubs.expect_job_spec)
1067 self._adjust_script_params(expect_component)
1070 "testing 123": expect_component,
1072 "name": "testing 123",
1073 "owner_uuid": project_uuid,
1075 stubs.api.pipeline_templates().create.assert_called_with(
1076 body=JsonDiffMatcher(expect_template), ensure_unique_name=True)
1078 self.assertEqual(capture_stdout.getvalue(),
1079 stubs.expect_pipeline_template_uuid + '\n')
1083 def test_update_name(self, stubs):
1084 project_uuid = 'zzzzz-j7d0g-zzzzzzzzzzzzzzz'
1086 capture_stdout = cStringIO.StringIO()
1088 exited = arvados_cwl.main(
1089 ["--update-workflow", self.existing_template_uuid,
1091 "--project-uuid", project_uuid,
1093 "--name", "testing 123",
1094 "tests/wf/submit_wf.cwl", "tests/submit_test_job.json"],
1095 capture_stdout, sys.stderr, api_client=stubs.api)
1096 self.assertEqual(exited, 0)
1098 stubs.api.pipeline_instances().create.refute_called()
1099 stubs.api.jobs().create.refute_called()
1101 expect_component = copy.deepcopy(stubs.expect_job_spec)
1102 self._adjust_script_params(expect_component)
1105 "testing 123": expect_component,
1107 "name": "testing 123",
1108 "owner_uuid": project_uuid,
1110 stubs.api.pipeline_templates().create.refute_called()
1111 stubs.api.pipeline_templates().update.assert_called_with(
1112 body=JsonDiffMatcher(expect_template), uuid=self.existing_template_uuid)
1114 self.assertEqual(capture_stdout.getvalue(),
1115 self.existing_template_uuid + '\n')
1118 class TestCreateWorkflow(unittest.TestCase):
1119 existing_workflow_uuid = "zzzzz-7fd4e-validworkfloyml"
1120 expect_workflow = StripYAMLComments(
1121 open("tests/wf/expect_packed.cwl").read())
1124 def test_create(self, stubs):
1125 project_uuid = 'zzzzz-j7d0g-zzzzzzzzzzzzzzz'
1127 capture_stdout = cStringIO.StringIO()
1129 exited = arvados_cwl.main(
1130 ["--create-workflow", "--debug",
1132 "--project-uuid", project_uuid,
1133 "tests/wf/submit_wf.cwl", "tests/submit_test_job.json"],
1134 capture_stdout, sys.stderr, api_client=stubs.api)
1135 self.assertEqual(exited, 0)
1137 stubs.api.pipeline_templates().create.refute_called()
1138 stubs.api.container_requests().create.refute_called()
1142 "owner_uuid": project_uuid,
1143 "name": "submit_wf.cwl",
1145 "definition": self.expect_workflow,
1148 stubs.api.workflows().create.assert_called_with(
1149 body=JsonDiffMatcher(body))
1151 self.assertEqual(capture_stdout.getvalue(),
1152 stubs.expect_workflow_uuid + '\n')
1156 def test_create_name(self, stubs):
1157 project_uuid = 'zzzzz-j7d0g-zzzzzzzzzzzzzzz'
1159 capture_stdout = cStringIO.StringIO()
1161 exited = arvados_cwl.main(
1162 ["--create-workflow", "--debug",
1164 "--project-uuid", project_uuid,
1165 "--name", "testing 123",
1166 "tests/wf/submit_wf.cwl", "tests/submit_test_job.json"],
1167 capture_stdout, sys.stderr, api_client=stubs.api)
1168 self.assertEqual(exited, 0)
1170 stubs.api.pipeline_templates().create.refute_called()
1171 stubs.api.container_requests().create.refute_called()
1175 "owner_uuid": project_uuid,
1176 "name": "testing 123",
1178 "definition": self.expect_workflow,
1181 stubs.api.workflows().create.assert_called_with(
1182 body=JsonDiffMatcher(body))
1184 self.assertEqual(capture_stdout.getvalue(),
1185 stubs.expect_workflow_uuid + '\n')
1188 def test_incompatible_api(self, stubs):
1189 capture_stderr = cStringIO.StringIO()
1190 logging.getLogger('arvados.cwl-runner').addHandler(
1191 logging.StreamHandler(capture_stderr))
1193 exited = arvados_cwl.main(
1194 ["--update-workflow", self.existing_workflow_uuid,
1197 "tests/wf/submit_wf.cwl", "tests/submit_test_job.json"],
1198 sys.stderr, sys.stderr, api_client=stubs.api)
1199 self.assertEqual(exited, 1)
1200 self.assertRegexpMatches(
1201 capture_stderr.getvalue(),
1202 "--update-workflow arg '{}' uses 'containers' API, but --api='jobs' specified".format(self.existing_workflow_uuid))
1205 def test_update(self, stubs):
1206 capture_stdout = cStringIO.StringIO()
1208 exited = arvados_cwl.main(
1209 ["--update-workflow", self.existing_workflow_uuid,
1211 "tests/wf/submit_wf.cwl", "tests/submit_test_job.json"],
1212 capture_stdout, sys.stderr, api_client=stubs.api)
1213 self.assertEqual(exited, 0)
1217 "name": "submit_wf.cwl",
1219 "definition": self.expect_workflow,
1222 stubs.api.workflows().update.assert_called_with(
1223 uuid=self.existing_workflow_uuid,
1224 body=JsonDiffMatcher(body))
1225 self.assertEqual(capture_stdout.getvalue(),
1226 self.existing_workflow_uuid + '\n')
1230 def test_update_name(self, stubs):
1231 capture_stdout = cStringIO.StringIO()
1233 exited = arvados_cwl.main(
1234 ["--update-workflow", self.existing_workflow_uuid,
1235 "--debug", "--name", "testing 123",
1236 "tests/wf/submit_wf.cwl", "tests/submit_test_job.json"],
1237 capture_stdout, sys.stderr, api_client=stubs.api)
1238 self.assertEqual(exited, 0)
1242 "name": "testing 123",
1244 "definition": self.expect_workflow,
1247 stubs.api.workflows().update.assert_called_with(
1248 uuid=self.existing_workflow_uuid,
1249 body=JsonDiffMatcher(body))
1250 self.assertEqual(capture_stdout.getvalue(),
1251 self.existing_workflow_uuid + '\n')
1255 def test_create_collection_per_tool(self, stubs):
1256 project_uuid = 'zzzzz-j7d0g-zzzzzzzzzzzzzzz'
1258 capture_stdout = cStringIO.StringIO()
1260 exited = arvados_cwl.main(
1261 ["--create-workflow", "--debug",
1263 "--project-uuid", project_uuid,
1264 "tests/collection_per_tool/collection_per_tool.cwl"],
1265 capture_stdout, sys.stderr, api_client=stubs.api)
1266 self.assertEqual(exited, 0)
1268 toolfile = "tests/collection_per_tool/collection_per_tool_packed.cwl"
1269 expect_workflow = StripYAMLComments(open(toolfile).read())
1273 "owner_uuid": project_uuid,
1274 "name": "collection_per_tool.cwl",
1276 "definition": expect_workflow,
1279 stubs.api.workflows().create.assert_called_with(
1280 body=JsonDiffMatcher(body))
1282 self.assertEqual(capture_stdout.getvalue(),
1283 stubs.expect_workflow_uuid + '\n')
1285 class TestTemplateInputs(unittest.TestCase):
1288 "inputs_test.cwl": {
1289 'runtime_constraints': {
1290 'docker_image': 'arvados/jobs:'+arvados_cwl.__version__,
1291 'min_ram_mb_per_node': 1024
1293 'script_parameters': {
1295 '6c5ee1cd606088106d9f28367cde1e41+60/workflow.cwl#main',
1296 'optionalFloatInput': None,
1299 'dataclass': 'File',
1301 'title': "It's a file; we expect to find some characters in it.",
1302 'description': 'If there were anything further to say, it would be said here,\nor here.'
1306 'dataclass': 'number',
1308 'title': 'Floats like a duck',
1312 'optionalFloatInput': {
1313 'type': ['null', 'float'],
1314 'dataclass': 'number',
1319 'dataclass': 'boolean',
1321 'title': 'True or false?',
1324 'repository': 'arvados',
1325 'script_version': 'master',
1326 'minimum_script_version': '570509ab4d2ef93d870fd2b1f2eab178afb1bad9',
1327 'script': 'cwl-runner',
1330 "name": "inputs_test.cwl",
1334 def test_inputs_empty(self, stubs):
1335 exited = arvados_cwl.main(
1336 ["--create-template",
1337 "tests/wf/inputs_test.cwl", "tests/order/empty_order.json"],
1338 cStringIO.StringIO(), sys.stderr, api_client=stubs.api)
1339 self.assertEqual(exited, 0)
1341 stubs.api.pipeline_templates().create.assert_called_with(
1342 body=JsonDiffMatcher(self.expect_template), ensure_unique_name=True)
1345 def test_inputs(self, stubs):
1346 exited = arvados_cwl.main(
1347 ["--create-template",
1348 "tests/wf/inputs_test.cwl", "tests/order/inputs_test_order.json"],
1349 cStringIO.StringIO(), sys.stderr, api_client=stubs.api)
1350 self.assertEqual(exited, 0)
1352 expect_template = copy.deepcopy(self.expect_template)
1353 params = expect_template[
1354 "components"]["inputs_test.cwl"]["script_parameters"]
1355 params["fileInput"]["value"] = '169f39d466a5438ac4a90e779bf750c7+53/blorp.txt'
1356 params["cwl:tool"] = '6c5ee1cd606088106d9f28367cde1e41+60/workflow.cwl#main'
1357 params["floatInput"]["value"] = 1.234
1358 params["boolInput"]["value"] = True
1360 stubs.api.pipeline_templates().create.assert_called_with(
1361 body=JsonDiffMatcher(expect_template), ensure_unique_name=True)