1 # Copyright (C) The Arvados Authors. All rights reserved.
3 # SPDX-License-Identifier: Apache-2.0
5 from builtins import str
6 from builtins import object
9 import arvados_cwl.context
10 import arvados_cwl.util
11 from arvados_cwl.arvdocker import arv_docker_clear_cache
20 import cwltool.process
21 import cwltool.secrets
22 import cwltool.load_tool
23 from cwltool.update import INTERNAL_VERSION
24 from schema_salad.ref_resolver import Loader
25 from schema_salad.sourceline import cmap
27 from .matcher import JsonDiffMatcher, StripYAMLComments
28 from .mock_discovery import get_rootDesc
30 if not os.getenv('ARVADOS_DEBUG'):
31 logging.getLogger('arvados.cwl-runner').setLevel(logging.WARN)
32 logging.getLogger('arvados.arv-run').setLevel(logging.WARN)
34 class CollectionMock(object):
35 def __init__(self, vwdmock, *args, **kwargs):
36 self.vwdmock = vwdmock
39 def open(self, *args, **kwargs):
41 return self.vwdmock.open(*args, **kwargs)
43 def copy(self, *args, **kwargs):
45 self.vwdmock.copy(*args, **kwargs)
47 def save_new(self, *args, **kwargs):
53 def portable_data_hash(self):
55 return arvados.config.EMPTY_BLOCK_LOCATOR
57 return "99999999999999999999999999999996+99"
60 class TestContainer(unittest.TestCase):
63 cwltool.process._names = set()
64 arv_docker_clear_cache()
67 root_logger = logging.getLogger('')
69 # Remove existing RuntimeStatusLoggingHandlers if they exist
70 handlers = [h for h in root_logger.handlers if not isinstance(h, arvados_cwl.executor.RuntimeStatusLoggingHandler)]
71 root_logger.handlers = handlers
73 def helper(self, runner, enable_reuse=True):
74 document_loader, avsc_names, schema_metadata, metaschema_loader = cwltool.process.get_schema(INTERNAL_VERSION)
76 make_fs_access=functools.partial(arvados_cwl.CollectionFsAccess,
77 collection_cache=arvados_cwl.CollectionCache(runner.api, None, 0))
78 fs_access = mock.MagicMock()
79 fs_access.exists.return_value = True
81 loadingContext = arvados_cwl.context.ArvLoadingContext(
82 {"avsc_names": avsc_names,
84 "make_fs_access": make_fs_access,
85 "construct_tool_object": runner.arv_make_tool,
86 "fetcher_constructor": functools.partial(arvados_cwl.CollectionFetcher, api_client=runner.api, fs_access=fs_access),
88 "metadata": cmap({"cwlVersion": INTERNAL_VERSION, "http://commonwl.org/cwltool#original_cwlVersion": "v1.0"})
90 runtimeContext = arvados_cwl.context.ArvRuntimeContext(
91 {"work_api": "containers",
93 "name": "test_run_"+str(enable_reuse),
94 "make_fs_access": make_fs_access,
97 "enable_reuse": enable_reuse,
99 "project_uuid": "zzzzz-8i9sb-zzzzzzzzzzzzzzz",
100 "workflow_eval_lock": threading.Condition(threading.RLock())
103 if isinstance(runner, mock.MagicMock):
104 def make_tool(toolpath_object, loadingContext):
105 return arvados_cwl.ArvadosCommandTool(runner, toolpath_object, loadingContext)
106 runner.arv_make_tool.side_effect = make_tool
108 return loadingContext, runtimeContext
110 # Helper function to set up the ArvCwlExecutor to use the containers api
111 # and test that the RuntimeStatusLoggingHandler is set up correctly
112 def setup_and_test_container_executor_and_logging(self, gcc_mock) :
113 api = mock.MagicMock()
114 api._rootDesc = copy.deepcopy(get_rootDesc())
116 # Make sure ArvCwlExecutor thinks it's running inside a container so it
117 # adds the logging handler that will call runtime_status_update() mock
118 self.assertFalse(gcc_mock.called)
119 runner = arvados_cwl.ArvCwlExecutor(api)
120 self.assertEqual(runner.work_api, 'containers')
121 root_logger = logging.getLogger('')
122 handlerClasses = [h.__class__ for h in root_logger.handlers]
123 self.assertTrue(arvados_cwl.RuntimeStatusLoggingHandler in handlerClasses)
126 # The test passes no builder.resources
127 # Hence the default resources will apply: {'cores': 1, 'ram': 1024, 'outdirSize': 1024, 'tmpdirSize': 1024}
128 @mock.patch("arvados.commands.keepdocker.list_images_in_arv")
129 def test_run(self, keepdocker):
130 for enable_reuse in (True, False):
131 arv_docker_clear_cache()
133 runner = mock.MagicMock()
134 runner.ignore_docker_for_reuse = False
135 runner.intermediate_output_ttl = 0
136 runner.secret_store = cwltool.secrets.SecretStore()
137 runner.api._rootDesc = {"revision": "20210628"}
139 keepdocker.return_value = [("zzzzz-4zz18-zzzzzzzzzzzzzz3", "")]
140 runner.api.collections().get().execute.return_value = {
141 "portable_data_hash": "99999999999999999999999999999993+99"}
147 "arguments": [{"valueFrom": "$(runtime.outdir)"}],
149 "class": "CommandLineTool",
153 loadingContext, runtimeContext = self.helper(runner, enable_reuse)
155 arvtool = cwltool.load_tool.load_tool(tool, loadingContext)
156 arvtool.formatgraph = None
158 for j in arvtool.job({}, mock.MagicMock(), runtimeContext):
159 j.run(runtimeContext)
160 runner.api.container_requests().create.assert_called_with(
161 body=JsonDiffMatcher({
163 'HOME': '/var/spool/cwl',
166 'name': 'test_run_'+str(enable_reuse),
167 'runtime_constraints': {
171 'use_existing': enable_reuse,
174 '/tmp': {'kind': 'tmp',
175 "capacity": 1073741824
177 '/var/spool/cwl': {'kind': 'tmp',
178 "capacity": 1073741824 }
180 'state': 'Committed',
181 'output_name': 'Output for step test_run_'+str(enable_reuse),
182 'owner_uuid': 'zzzzz-8i9sb-zzzzzzzzzzzzzzz',
183 'output_path': '/var/spool/cwl',
185 'container_image': '99999999999999999999999999999993+99',
186 'command': ['ls', '/var/spool/cwl'],
187 'cwd': '/var/spool/cwl',
188 'scheduling_parameters': {},
191 'output_storage_classes': ["default"]
194 # The test passes some fields in builder.resources
195 # For the remaining fields, the defaults will apply: {'cores': 1, 'ram': 1024, 'outdirSize': 1024, 'tmpdirSize': 1024}
196 @mock.patch("arvados.commands.keepdocker.list_images_in_arv")
197 def test_resource_requirements(self, keepdocker):
198 arvados_cwl.add_arv_hints()
199 runner = mock.MagicMock()
200 runner.ignore_docker_for_reuse = False
201 runner.intermediate_output_ttl = 3600
202 runner.secret_store = cwltool.secrets.SecretStore()
203 runner.api._rootDesc = {"revision": "20210628"}
205 keepdocker.return_value = [("zzzzz-4zz18-zzzzzzzzzzzzzz3", "")]
206 runner.api.collections().get().execute.return_value = {
207 "portable_data_hash": "99999999999999999999999999999993+99"}
213 "class": "ResourceRequirement",
219 "class": "http://arvados.org/cwl#RuntimeConstraints",
222 "class": "http://arvados.org/cwl#APIRequirement",
224 "class": "http://arvados.org/cwl#PartitionRequirement",
227 "class": "http://arvados.org/cwl#IntermediateOutput",
230 "class": "WorkReuse",
235 "class": "CommandLineTool",
239 loadingContext, runtimeContext = self.helper(runner)
240 runtimeContext.name = "test_resource_requirements"
242 arvtool = cwltool.load_tool.load_tool(tool, loadingContext)
243 arvtool.formatgraph = None
244 for j in arvtool.job({}, mock.MagicMock(), runtimeContext):
245 j.run(runtimeContext)
247 call_args, call_kwargs = runner.api.container_requests().create.call_args
249 call_body_expected = {
251 'HOME': '/var/spool/cwl',
254 'name': 'test_resource_requirements',
255 'runtime_constraints': {
258 'keep_cache_ram': 536870912,
261 'use_existing': False,
264 '/tmp': {'kind': 'tmp',
265 "capacity": 4194304000 },
266 '/var/spool/cwl': {'kind': 'tmp',
267 "capacity": 5242880000 }
269 'state': 'Committed',
270 'output_name': 'Output for step test_resource_requirements',
271 'owner_uuid': 'zzzzz-8i9sb-zzzzzzzzzzzzzzz',
272 'output_path': '/var/spool/cwl',
274 'container_image': '99999999999999999999999999999993+99',
276 'cwd': '/var/spool/cwl',
277 'scheduling_parameters': {
278 'partitions': ['blurb']
282 'output_storage_classes': ["default"]
285 call_body = call_kwargs.get('body', None)
286 self.assertNotEqual(None, call_body)
287 for key in call_body:
288 self.assertEqual(call_body_expected.get(key), call_body.get(key))
291 # The test passes some fields in builder.resources
292 # For the remaining fields, the defaults will apply: {'cores': 1, 'ram': 1024, 'outdirSize': 1024, 'tmpdirSize': 1024}
293 @mock.patch("arvados.commands.keepdocker.list_images_in_arv")
294 @mock.patch("arvados.collection.Collection")
295 def test_initial_work_dir(self, collection_mock, keepdocker):
296 runner = mock.MagicMock()
297 runner.ignore_docker_for_reuse = False
298 runner.intermediate_output_ttl = 0
299 runner.secret_store = cwltool.secrets.SecretStore()
300 runner.api._rootDesc = {"revision": "20210628"}
302 keepdocker.return_value = [("zzzzz-4zz18-zzzzzzzzzzzzzz3", "")]
303 runner.api.collections().get().execute.return_value = {
304 "portable_data_hash": "99999999999999999999999999999993+99"}
306 sourcemock = mock.MagicMock()
307 def get_collection_mock(p):
309 return (sourcemock, p.split("/", 1)[1])
311 return (sourcemock, "")
312 runner.fs_access.get_collection.side_effect = get_collection_mock
314 vwdmock = mock.MagicMock()
315 collection_mock.side_effect = lambda *args, **kwargs: CollectionMock(vwdmock, *args, **kwargs)
321 "class": "InitialWorkDirRequirement",
325 "location": "keep:99999999999999999999999999999995+99/bar"
328 "class": "Directory",
330 "location": "keep:99999999999999999999999999999995+99"
334 "basename": "filename",
335 "location": "keep:99999999999999999999999999999995+99/baz/filename"
338 "class": "Directory",
339 "basename": "subdir",
340 "location": "keep:99999999999999999999999999999995+99/subdir"
344 "class": "CommandLineTool",
345 "cwlVersion": "v1.2",
349 loadingContext, runtimeContext = self.helper(runner)
350 runtimeContext.name = "test_initial_work_dir"
352 arvtool = cwltool.load_tool.load_tool(tool, loadingContext)
354 arvtool.formatgraph = None
355 for j in arvtool.job({}, mock.MagicMock(), runtimeContext):
356 j.run(runtimeContext)
358 call_args, call_kwargs = runner.api.container_requests().create.call_args
360 vwdmock.copy.assert_has_calls([mock.call('bar', 'foo', source_collection=sourcemock)])
361 vwdmock.copy.assert_has_calls([mock.call('.', 'foo2', source_collection=sourcemock)])
362 vwdmock.copy.assert_has_calls([mock.call('baz/filename', 'filename', source_collection=sourcemock)])
363 vwdmock.copy.assert_has_calls([mock.call('subdir', 'subdir', source_collection=sourcemock)])
365 call_body_expected = {
367 'HOME': '/var/spool/cwl',
370 'name': 'test_initial_work_dir',
371 'runtime_constraints': {
375 'use_existing': True,
378 '/tmp': {'kind': 'tmp',
379 "capacity": 1073741824 },
380 '/var/spool/cwl': {'kind': 'tmp',
381 "capacity": 1073741824 },
382 '/var/spool/cwl/foo': {
383 'kind': 'collection',
385 'portable_data_hash': '99999999999999999999999999999996+99'
387 '/var/spool/cwl/foo2': {
388 'kind': 'collection',
390 'portable_data_hash': '99999999999999999999999999999996+99'
392 '/var/spool/cwl/filename': {
393 'kind': 'collection',
395 'portable_data_hash': '99999999999999999999999999999996+99'
397 '/var/spool/cwl/subdir': {
398 'kind': 'collection',
400 'portable_data_hash': '99999999999999999999999999999996+99'
403 'state': 'Committed',
404 'output_name': 'Output for step test_initial_work_dir',
405 'owner_uuid': 'zzzzz-8i9sb-zzzzzzzzzzzzzzz',
406 'output_path': '/var/spool/cwl',
408 'container_image': '99999999999999999999999999999993+99',
410 'cwd': '/var/spool/cwl',
411 'scheduling_parameters': {
415 'output_storage_classes': ["default"]
418 call_body = call_kwargs.get('body', None)
419 self.assertNotEqual(None, call_body)
420 for key in call_body:
421 self.assertEqual(call_body_expected.get(key), call_body.get(key))
424 # Test redirecting stdin/stdout/stderr
425 @mock.patch("arvados.commands.keepdocker.list_images_in_arv")
426 def test_redirects(self, keepdocker):
427 runner = mock.MagicMock()
428 runner.ignore_docker_for_reuse = False
429 runner.intermediate_output_ttl = 0
430 runner.secret_store = cwltool.secrets.SecretStore()
431 runner.api._rootDesc = {"revision": "20210628"}
433 keepdocker.return_value = [("zzzzz-4zz18-zzzzzzzzzzzzzz3", "")]
434 runner.api.collections().get().execute.return_value = {
435 "portable_data_hash": "99999999999999999999999999999993+99"}
437 document_loader, avsc_names, schema_metadata, metaschema_loader = cwltool.process.get_schema(INTERNAL_VERSION)
443 "stdout": "stdout.txt",
444 "stderr": "stderr.txt",
445 "stdin": "/keep/99999999999999999999999999999996+99/file.txt",
446 "arguments": [{"valueFrom": "$(runtime.outdir)"}],
448 "class": "CommandLineTool",
452 loadingContext, runtimeContext = self.helper(runner)
453 runtimeContext.name = "test_run_redirect"
455 arvtool = cwltool.load_tool.load_tool(tool, loadingContext)
456 arvtool.formatgraph = None
457 for j in arvtool.job({}, mock.MagicMock(), runtimeContext):
458 j.run(runtimeContext)
459 runner.api.container_requests().create.assert_called_with(
460 body=JsonDiffMatcher({
462 'HOME': '/var/spool/cwl',
465 'name': 'test_run_redirect',
466 'runtime_constraints': {
470 'use_existing': True,
473 '/tmp': {'kind': 'tmp',
474 "capacity": 1073741824 },
475 '/var/spool/cwl': {'kind': 'tmp',
476 "capacity": 1073741824 },
479 "path": "/var/spool/cwl/stderr.txt"
482 "kind": "collection",
484 "portable_data_hash": "99999999999999999999999999999996+99"
488 "path": "/var/spool/cwl/stdout.txt"
491 'state': 'Committed',
492 "output_name": "Output for step test_run_redirect",
493 'owner_uuid': 'zzzzz-8i9sb-zzzzzzzzzzzzzzz',
494 'output_path': '/var/spool/cwl',
496 'container_image': '99999999999999999999999999999993+99',
497 'command': ['ls', '/var/spool/cwl'],
498 'cwd': '/var/spool/cwl',
499 'scheduling_parameters': {},
502 'output_storage_classes': ["default"]
505 @mock.patch("arvados.collection.Collection")
506 def test_done(self, col):
507 api = mock.MagicMock()
509 runner = mock.MagicMock()
511 runner.num_retries = 0
512 runner.ignore_docker_for_reuse = False
513 runner.intermediate_output_ttl = 0
514 runner.secret_store = cwltool.secrets.SecretStore()
516 runner.api.containers().get().execute.return_value = {"state":"Complete",
520 col().open.return_value = []
522 loadingContext, runtimeContext = self.helper(runner)
524 arvjob = arvados_cwl.ArvadosContainer(runner,
532 arvjob.output_callback = mock.MagicMock()
533 arvjob.collect_outputs = mock.MagicMock()
534 arvjob.successCodes = [0]
535 arvjob.outdir = "/var/spool/cwl"
536 arvjob.output_ttl = 3600
538 arvjob.collect_outputs.return_value = {"out": "stuff"}
542 "log_uuid": "zzzzz-4zz18-zzzzzzzzzzzzzz1",
543 "output_uuid": "zzzzz-4zz18-zzzzzzzzzzzzzz2",
544 "uuid": "zzzzz-xvhdp-zzzzzzzzzzzzzzz",
545 "container_uuid": "zzzzz-8i9sb-zzzzzzzzzzzzzzz",
546 "modified_at": "2017-05-26T12:01:22Z"
549 self.assertFalse(api.collections().create.called)
550 self.assertFalse(runner.runtime_status_error.called)
552 arvjob.collect_outputs.assert_called_with("keep:abc+123", 0)
553 arvjob.output_callback.assert_called_with({"out": "stuff"}, "success")
554 runner.add_intermediate_output.assert_called_with("zzzzz-4zz18-zzzzzzzzzzzzzz2")
556 # Test to make sure we dont call runtime_status_update if we already did
557 # some where higher up in the call stack
558 @mock.patch("arvados_cwl.util.get_current_container")
559 def test_recursive_runtime_status_update(self, gcc_mock):
560 self.setup_and_test_container_executor_and_logging(gcc_mock)
561 root_logger = logging.getLogger('')
563 # get_current_container is invoked when we call runtime_status_update
564 # so try and log again!
565 gcc_mock.side_effect = lambda *args: root_logger.error("Second Error")
567 root_logger.error("First Error")
569 self.fail("RuntimeStatusLoggingHandler should not be called recursively")
572 # Test to make sure that an exception raised from
573 # get_current_container doesn't cause the logger to raise an
575 @mock.patch("arvados_cwl.util.get_current_container")
576 def test_runtime_status_get_current_container_exception(self, gcc_mock):
577 self.setup_and_test_container_executor_and_logging(gcc_mock)
578 root_logger = logging.getLogger('')
580 # get_current_container is invoked when we call
581 # runtime_status_update, it is going to also raise an
583 gcc_mock.side_effect = Exception("Second Error")
585 root_logger.error("First Error")
587 self.fail("Exception in logger should not propagate")
588 self.assertTrue(gcc_mock.called)
590 @mock.patch("arvados_cwl.ArvCwlExecutor.runtime_status_update")
591 @mock.patch("arvados_cwl.util.get_current_container")
592 @mock.patch("arvados.collection.CollectionReader")
593 @mock.patch("arvados.collection.Collection")
594 def test_child_failure(self, col, reader, gcc_mock, rts_mock):
595 runner = self.setup_and_test_container_executor_and_logging(gcc_mock)
597 gcc_mock.return_value = {"uuid" : "zzzzz-dz642-zzzzzzzzzzzzzzz"}
598 self.assertTrue(gcc_mock.called)
600 runner.num_retries = 0
601 runner.ignore_docker_for_reuse = False
602 runner.intermediate_output_ttl = 0
603 runner.secret_store = cwltool.secrets.SecretStore()
604 runner.label = mock.MagicMock()
605 runner.label.return_value = '[container testjob]'
607 runner.api.containers().get().execute.return_value = {
614 col().open.return_value = []
616 loadingContext, runtimeContext = self.helper(runner)
618 arvjob = arvados_cwl.ArvadosContainer(runner,
626 arvjob.output_callback = mock.MagicMock()
627 arvjob.collect_outputs = mock.MagicMock()
628 arvjob.successCodes = [0]
629 arvjob.outdir = "/var/spool/cwl"
630 arvjob.output_ttl = 3600
631 arvjob.collect_outputs.return_value = {"out": "stuff"}
635 "log_uuid": "zzzzz-4zz18-zzzzzzzzzzzzzz1",
636 "output_uuid": "zzzzz-4zz18-zzzzzzzzzzzzzz2",
637 "uuid": "zzzzz-xvhdp-zzzzzzzzzzzzzzz",
638 "container_uuid": "zzzzz-8i9sb-zzzzzzzzzzzzzzz",
639 "modified_at": "2017-05-26T12:01:22Z"
642 rts_mock.assert_called_with(
644 'arvados.cwl-runner: [container testjob] (zzzzz-xvhdp-zzzzzzzzzzzzzzz) error log:',
645 ' ** log is empty **'
647 arvjob.output_callback.assert_called_with({"out": "stuff"}, "permanentFail")
649 # The test passes no builder.resources
650 # Hence the default resources will apply: {'cores': 1, 'ram': 1024, 'outdirSize': 1024, 'tmpdirSize': 1024}
651 @mock.patch("arvados.commands.keepdocker.list_images_in_arv")
652 def test_mounts(self, keepdocker):
653 runner = mock.MagicMock()
654 runner.ignore_docker_for_reuse = False
655 runner.intermediate_output_ttl = 0
656 runner.secret_store = cwltool.secrets.SecretStore()
657 runner.api._rootDesc = {"revision": "20210628"}
659 keepdocker.return_value = [("zzzzz-4zz18-zzzzzzzzzzzzzz3", "")]
660 runner.api.collections().get().execute.return_value = {
661 "portable_data_hash": "99999999999999999999999999999994+99",
662 "manifest_text": ". 99999999999999999999999999999994+99 0:0:file1 0:0:file2"}
664 document_loader, avsc_names, schema_metadata, metaschema_loader = cwltool.process.get_schema("v1.1")
673 "arguments": [{"valueFrom": "$(runtime.outdir)"}],
675 "class": "CommandLineTool",
679 loadingContext, runtimeContext = self.helper(runner)
680 runtimeContext.name = "test_run_mounts"
682 arvtool = cwltool.load_tool.load_tool(tool, loadingContext)
683 arvtool.formatgraph = None
686 "class": "Directory",
687 "location": "keep:99999999999999999999999999999994+44",
688 "http://arvados.org/cwl#collectionUUID": "zzzzz-4zz18-zzzzzzzzzzzzzzz",
692 "location": "keep:99999999999999999999999999999994+44/file1",
696 "location": "keep:99999999999999999999999999999994+44/file2",
701 for j in arvtool.job(job_order, mock.MagicMock(), runtimeContext):
702 j.run(runtimeContext)
703 runner.api.container_requests().create.assert_called_with(
704 body=JsonDiffMatcher({
706 'HOME': '/var/spool/cwl',
709 'name': 'test_run_mounts',
710 'runtime_constraints': {
714 'use_existing': True,
717 "/keep/99999999999999999999999999999994+44": {
718 "kind": "collection",
719 "portable_data_hash": "99999999999999999999999999999994+44",
720 "uuid": "zzzzz-4zz18-zzzzzzzzzzzzzzz"
722 '/tmp': {'kind': 'tmp',
723 "capacity": 1073741824 },
724 '/var/spool/cwl': {'kind': 'tmp',
725 "capacity": 1073741824 }
727 'state': 'Committed',
728 'output_name': 'Output for step test_run_mounts',
729 'owner_uuid': 'zzzzz-8i9sb-zzzzzzzzzzzzzzz',
730 'output_path': '/var/spool/cwl',
732 'container_image': '99999999999999999999999999999994+99',
733 'command': ['ls', '/var/spool/cwl'],
734 'cwd': '/var/spool/cwl',
735 'scheduling_parameters': {},
738 'output_storage_classes': ["default"]
741 # The test passes no builder.resources
742 # Hence the default resources will apply: {'cores': 1, 'ram': 1024, 'outdirSize': 1024, 'tmpdirSize': 1024}
743 @mock.patch("arvados.commands.keepdocker.list_images_in_arv")
744 def test_secrets(self, keepdocker):
745 arvados_cwl.add_arv_hints()
746 runner = mock.MagicMock()
747 runner.ignore_docker_for_reuse = False
748 runner.intermediate_output_ttl = 0
749 runner.secret_store = cwltool.secrets.SecretStore()
750 runner.api._rootDesc = {"revision": "20210628"}
752 keepdocker.return_value = [("zzzzz-4zz18-zzzzzzzzzzzzzz3", "")]
753 runner.api.collections().get().execute.return_value = {
754 "portable_data_hash": "99999999999999999999999999999993+99"}
756 document_loader, avsc_names, schema_metadata, metaschema_loader = cwltool.process.get_schema("v1.1")
758 tool = cmap({"arguments": ["md5sum", "example.conf"],
759 "class": "CommandLineTool",
760 "cwlVersion": "v1.2",
763 "class": "http://commonwl.org/cwltool#Secrets",
772 "id": "#secret_job.cwl/pw",
780 "class": "InitialWorkDirRequirement",
783 "entry": "username: user\npassword: $(inputs.pw)\n",
784 "entryname": "example.conf"
790 loadingContext, runtimeContext = self.helper(runner)
791 runtimeContext.name = "test_secrets"
793 arvtool = cwltool.load_tool.load_tool(tool, loadingContext)
794 arvtool.formatgraph = None
796 job_order = {"pw": "blorp"}
797 runner.secret_store.store(["pw"], job_order)
799 for j in arvtool.job(job_order, mock.MagicMock(), runtimeContext):
800 j.run(runtimeContext)
801 runner.api.container_requests().create.assert_called_with(
802 body=JsonDiffMatcher({
804 'HOME': '/var/spool/cwl',
807 'name': 'test_secrets',
808 'runtime_constraints': {
812 'use_existing': True,
815 '/tmp': {'kind': 'tmp',
816 "capacity": 1073741824
818 '/var/spool/cwl': {'kind': 'tmp',
819 "capacity": 1073741824 }
821 'state': 'Committed',
822 'output_name': 'Output for step test_secrets',
823 'owner_uuid': 'zzzzz-8i9sb-zzzzzzzzzzzzzzz',
824 'output_path': '/var/spool/cwl',
826 'container_image': '99999999999999999999999999999993+99',
827 'command': ['md5sum', 'example.conf'],
828 'cwd': '/var/spool/cwl',
829 'scheduling_parameters': {},
832 "/var/spool/cwl/example.conf": {
833 "content": "username: user\npassword: blorp\n",
837 'output_storage_classes': ["default"]
840 # The test passes no builder.resources
841 # Hence the default resources will apply: {'cores': 1, 'ram': 1024, 'outdirSize': 1024, 'tmpdirSize': 1024}
842 @mock.patch("arvados.commands.keepdocker.list_images_in_arv")
843 def test_timelimit(self, keepdocker):
844 runner = mock.MagicMock()
845 runner.ignore_docker_for_reuse = False
846 runner.intermediate_output_ttl = 0
847 runner.secret_store = cwltool.secrets.SecretStore()
848 runner.api._rootDesc = {"revision": "20210628"}
850 keepdocker.return_value = [("zzzzz-4zz18-zzzzzzzzzzzzzz3", "")]
851 runner.api.collections().get().execute.return_value = {
852 "portable_data_hash": "99999999999999999999999999999993+99"}
858 "arguments": [{"valueFrom": "$(runtime.outdir)"}],
860 "cwlVersion": "v1.2",
861 "class": "CommandLineTool",
864 "class": "ToolTimeLimit",
870 loadingContext, runtimeContext = self.helper(runner)
871 runtimeContext.name = "test_timelimit"
873 arvtool = cwltool.load_tool.load_tool(tool, loadingContext)
874 arvtool.formatgraph = None
876 for j in arvtool.job({}, mock.MagicMock(), runtimeContext):
877 j.run(runtimeContext)
879 _, kwargs = runner.api.container_requests().create.call_args
880 self.assertEqual(42, kwargs['body']['scheduling_parameters'].get('max_run_time'))
883 # The test passes no builder.resources
884 # Hence the default resources will apply: {'cores': 1, 'ram': 1024, 'outdirSize': 1024, 'tmpdirSize': 1024}
885 @mock.patch("arvados.commands.keepdocker.list_images_in_arv")
886 def test_setting_storage_class(self, keepdocker):
887 arv_docker_clear_cache()
889 runner = mock.MagicMock()
890 runner.ignore_docker_for_reuse = False
891 runner.intermediate_output_ttl = 0
892 runner.secret_store = cwltool.secrets.SecretStore()
893 runner.api._rootDesc = {"revision": "20210628"}
895 keepdocker.return_value = [("zzzzz-4zz18-zzzzzzzzzzzzzz3", "")]
896 runner.api.collections().get().execute.return_value = {
897 "portable_data_hash": "99999999999999999999999999999993+99"}
903 "arguments": [{"valueFrom": "$(runtime.outdir)"}],
905 "cwlVersion": "v1.2",
906 "class": "CommandLineTool",
909 "class": "http://arvados.org/cwl#OutputStorageClass",
910 "finalStorageClass": ["baz_sc", "qux_sc"],
911 "intermediateStorageClass": ["foo_sc", "bar_sc"]
916 loadingContext, runtimeContext = self.helper(runner, True)
918 arvtool = cwltool.load_tool.load_tool(tool, loadingContext)
919 arvtool.formatgraph = None
921 for j in arvtool.job({}, mock.MagicMock(), runtimeContext):
922 j.run(runtimeContext)
923 runner.api.container_requests().create.assert_called_with(
924 body=JsonDiffMatcher({
926 'HOME': '/var/spool/cwl',
929 'name': 'test_run_True',
930 'runtime_constraints': {
934 'use_existing': True,
937 '/tmp': {'kind': 'tmp',
938 "capacity": 1073741824
940 '/var/spool/cwl': {'kind': 'tmp',
941 "capacity": 1073741824 }
943 'state': 'Committed',
944 'output_name': 'Output for step test_run_True',
945 'owner_uuid': 'zzzzz-8i9sb-zzzzzzzzzzzzzzz',
946 'output_path': '/var/spool/cwl',
948 'container_image': '99999999999999999999999999999993+99',
949 'command': ['ls', '/var/spool/cwl'],
950 'cwd': '/var/spool/cwl',
951 'scheduling_parameters': {},
954 'output_storage_classes': ["foo_sc", "bar_sc"]
958 # The test passes no builder.resources
959 # Hence the default resources will apply: {'cores': 1, 'ram': 1024, 'outdirSize': 1024, 'tmpdirSize': 1024}
960 @mock.patch("arvados.commands.keepdocker.list_images_in_arv")
961 def test_setting_process_properties(self, keepdocker):
962 arv_docker_clear_cache()
964 runner = mock.MagicMock()
965 runner.ignore_docker_for_reuse = False
966 runner.intermediate_output_ttl = 0
967 runner.secret_store = cwltool.secrets.SecretStore()
968 runner.api._rootDesc = {"revision": "20210628"}
970 keepdocker.return_value = [("zzzzz-4zz18-zzzzzzzzzzzzzz3", "")]
971 runner.api.collections().get().execute.return_value = {
972 "portable_data_hash": "99999999999999999999999999999993+99"}
976 {"id": "x", "type": "string"}],
979 "arguments": [{"valueFrom": "$(runtime.outdir)"}],
981 "class": "CommandLineTool",
982 "cwlVersion": "v1.2",
985 "class": "http://arvados.org/cwl#ProcessProperties",
986 "processProperties": [
987 {"propertyName": "foo",
988 "propertyValue": "bar"},
989 {"propertyName": "baz",
990 "propertyValue": "$(inputs.x)"},
991 {"propertyName": "quux",
1002 loadingContext, runtimeContext = self.helper(runner, True)
1004 arvtool = cwltool.load_tool.load_tool(tool, loadingContext)
1005 arvtool.formatgraph = None
1007 for j in arvtool.job({"x": "blorp"}, mock.MagicMock(), runtimeContext):
1008 j.run(runtimeContext)
1009 runner.api.container_requests().create.assert_called_with(
1010 body=JsonDiffMatcher({
1012 'HOME': '/var/spool/cwl',
1015 'name': 'test_run_True',
1016 'runtime_constraints': {
1020 'use_existing': True,
1023 '/tmp': {'kind': 'tmp',
1024 "capacity": 1073741824
1026 '/var/spool/cwl': {'kind': 'tmp',
1027 "capacity": 1073741824 }
1029 'state': 'Committed',
1030 'output_name': 'Output for step test_run_True',
1031 'owner_uuid': 'zzzzz-8i9sb-zzzzzzzzzzzzzzz',
1032 'output_path': '/var/spool/cwl',
1034 'container_image': '99999999999999999999999999999993+99',
1035 'command': ['ls', '/var/spool/cwl'],
1036 'cwd': '/var/spool/cwl',
1037 'scheduling_parameters': {},
1046 'secret_mounts': {},
1047 'output_storage_classes': ["default"]
1051 # The test passes no builder.resources
1052 # Hence the default resources will apply: {'cores': 1, 'ram': 1024, 'outdirSize': 1024, 'tmpdirSize': 1024}
1053 @mock.patch("arvados.commands.keepdocker.list_images_in_arv")
1054 def test_cuda_requirement(self, keepdocker):
1055 arvados_cwl.add_arv_hints()
1056 arv_docker_clear_cache()
1058 runner = mock.MagicMock()
1059 runner.ignore_docker_for_reuse = False
1060 runner.intermediate_output_ttl = 0
1061 runner.secret_store = cwltool.secrets.SecretStore()
1062 runner.api._rootDesc = {"revision": "20210628"}
1064 keepdocker.return_value = [("zzzzz-4zz18-zzzzzzzzzzzzzz3", "")]
1065 runner.api.collections().get().execute.return_value = {
1066 "portable_data_hash": "99999999999999999999999999999993+99"}
1069 "class": "http://commonwl.org/cwltool#CUDARequirement",
1070 "cudaVersionMin": "11.0",
1071 "cudaComputeCapability": "9.0",
1073 "class": "http://commonwl.org/cwltool#CUDARequirement",
1074 "cudaVersionMin": "11.0",
1075 "cudaComputeCapability": "9.0",
1076 "cudaDeviceCountMin": 2
1078 "class": "http://commonwl.org/cwltool#CUDARequirement",
1079 "cudaVersionMin": "11.0",
1080 "cudaComputeCapability": ["4.0", "5.0"],
1081 "cudaDeviceCountMin": 2
1086 'driver_version': "11.0",
1087 'hardware_capability': "9.0"
1090 'driver_version': "11.0",
1091 'hardware_capability': "9.0"
1094 'driver_version': "11.0",
1095 'hardware_capability': "4.0"
1098 for test_case in range(0, len(test_cwl_req)):
1103 "baseCommand": "nvidia-smi",
1106 "cwlVersion": "v1.2",
1107 "class": "CommandLineTool",
1108 "requirements": [test_cwl_req[test_case]]
1111 loadingContext, runtimeContext = self.helper(runner, True)
1113 arvtool = cwltool.load_tool.load_tool(tool, loadingContext)
1114 arvtool.formatgraph = None
1116 for j in arvtool.job({}, mock.MagicMock(), runtimeContext):
1117 j.run(runtimeContext)
1118 runner.api.container_requests().create.assert_called_with(
1119 body=JsonDiffMatcher({
1121 'HOME': '/var/spool/cwl',
1124 'name': 'test_run_True' + ("" if test_case == 0 else "_"+str(test_case+1)),
1125 'runtime_constraints': {
1128 'cuda': test_arv_req[test_case]
1130 'use_existing': True,
1133 '/tmp': {'kind': 'tmp',
1134 "capacity": 1073741824
1136 '/var/spool/cwl': {'kind': 'tmp',
1137 "capacity": 1073741824 }
1139 'state': 'Committed',
1140 'output_name': 'Output for step test_run_True' + ("" if test_case == 0 else "_"+str(test_case+1)),
1141 'owner_uuid': 'zzzzz-8i9sb-zzzzzzzzzzzzzzz',
1142 'output_path': '/var/spool/cwl',
1144 'container_image': '99999999999999999999999999999993+99',
1145 'command': ['nvidia-smi'],
1146 'cwd': '/var/spool/cwl',
1147 'scheduling_parameters': {},
1149 'secret_mounts': {},
1150 'output_storage_classes': ["default"]
1154 # The test passes no builder.resources
1155 # Hence the default resources will apply: {'cores': 1, 'ram': 1024, 'outdirSize': 1024, 'tmpdirSize': 1024}
1156 @mock.patch("arvados_cwl.arvdocker.determine_image_id")
1157 @mock.patch("arvados.commands.keepdocker.list_images_in_arv")
1158 def test_match_local_docker(self, keepdocker, determine_image_id):
1159 arvados_cwl.add_arv_hints()
1160 arv_docker_clear_cache()
1162 runner = mock.MagicMock()
1163 runner.ignore_docker_for_reuse = False
1164 runner.intermediate_output_ttl = 0
1165 runner.secret_store = cwltool.secrets.SecretStore()
1166 runner.api._rootDesc = {"revision": "20210628"}
1168 keepdocker.return_value = [("zzzzz-4zz18-zzzzzzzzzzzzzz4", {"dockerhash": "456"}),
1169 ("zzzzz-4zz18-zzzzzzzzzzzzzz3", {"dockerhash": "123"})]
1170 determine_image_id.side_effect = lambda x: "123"
1172 ex = mock.MagicMock()
1173 lookup = {"zzzzz-4zz18-zzzzzzzzzzzzzz4": {"portable_data_hash": "99999999999999999999999999999994+99"},
1174 "zzzzz-4zz18-zzzzzzzzzzzzzz3": {"portable_data_hash": "99999999999999999999999999999993+99"}}
1175 ex.execute.return_value = lookup[uuid]
1177 runner.api.collections().get.side_effect = execute
1182 "baseCommand": "echo",
1185 "cwlVersion": "v1.0",
1186 "class": "org.w3id.cwl.cwl.CommandLineTool"
1189 loadingContext, runtimeContext = self.helper(runner, True)
1191 arvtool = arvados_cwl.ArvadosCommandTool(runner, tool, loadingContext)
1192 arvtool.formatgraph = None
1194 container_request = {
1196 'HOME': '/var/spool/cwl',
1199 'name': 'test_run_True',
1200 'runtime_constraints': {
1204 'use_existing': True,
1207 '/tmp': {'kind': 'tmp',
1208 "capacity": 1073741824
1210 '/var/spool/cwl': {'kind': 'tmp',
1211 "capacity": 1073741824 }
1213 'state': 'Committed',
1214 'output_name': 'Output for step test_run_True',
1215 'owner_uuid': 'zzzzz-8i9sb-zzzzzzzzzzzzzzz',
1216 'output_path': '/var/spool/cwl',
1218 'container_image': '99999999999999999999999999999994+99',
1219 'command': ['echo'],
1220 'cwd': '/var/spool/cwl',
1221 'scheduling_parameters': {},
1223 'secret_mounts': {},
1224 'output_storage_classes': ["default"]
1227 runtimeContext.match_local_docker = False
1228 for j in arvtool.job({}, mock.MagicMock(), runtimeContext):
1229 j.run(runtimeContext)
1230 runner.api.container_requests().create.assert_called_with(
1231 body=JsonDiffMatcher(container_request))
1233 arv_docker_clear_cache()
1234 runtimeContext.match_local_docker = True
1235 container_request['container_image'] = '99999999999999999999999999999993+99'
1236 container_request['name'] = 'test_run_True_2'
1237 container_request['output_name'] = 'Output for step test_run_True_2'
1238 for j in arvtool.job({}, mock.MagicMock(), runtimeContext):
1239 j.run(runtimeContext)
1240 runner.api.container_requests().create.assert_called_with(
1241 body=JsonDiffMatcher(container_request))
1244 # The test passes no builder.resources
1245 # Hence the default resources will apply: {'cores': 1, 'ram': 1024, 'outdirSize': 1024, 'tmpdirSize': 1024}
1246 @mock.patch("arvados.commands.keepdocker.list_images_in_arv")
1247 def test_run_preemptible_hint(self, keepdocker):
1248 arvados_cwl.add_arv_hints()
1249 for enable_preemptible in (None, True, False):
1250 for preemptible_hint in (None, True, False):
1251 arv_docker_clear_cache()
1253 runner = mock.MagicMock()
1254 runner.ignore_docker_for_reuse = False
1255 runner.intermediate_output_ttl = 0
1256 runner.secret_store = cwltool.secrets.SecretStore()
1257 runner.api._rootDesc = {"revision": "20210628"}
1259 keepdocker.return_value = [("zzzzz-4zz18-zzzzzzzzzzzzzz3", "")]
1260 runner.api.collections().get().execute.return_value = {
1261 "portable_data_hash": "99999999999999999999999999999993+99"}
1263 if preemptible_hint is not None:
1265 "class": "http://arvados.org/cwl#UsePreemptible",
1266 "usePreemptible": preemptible_hint
1274 "baseCommand": "ls",
1275 "arguments": [{"valueFrom": "$(runtime.outdir)"}],
1277 "class": "CommandLineTool",
1278 "cwlVersion": "v1.2",
1282 loadingContext, runtimeContext = self.helper(runner)
1284 runtimeContext.name = 'test_run_enable_preemptible_'+str(enable_preemptible)+str(preemptible_hint)
1285 runtimeContext.enable_preemptible = enable_preemptible
1287 arvtool = cwltool.load_tool.load_tool(tool, loadingContext)
1288 arvtool.formatgraph = None
1290 # Test the interactions between --enable/disable-preemptible
1291 # and UsePreemptible hint
1293 if enable_preemptible is None:
1294 if preemptible_hint is None:
1297 sched = {'preemptible': preemptible_hint}
1299 if preemptible_hint is None:
1300 sched = {'preemptible': enable_preemptible}
1302 sched = {'preemptible': enable_preemptible and preemptible_hint}
1304 for j in arvtool.job({}, mock.MagicMock(), runtimeContext):
1305 j.run(runtimeContext)
1306 runner.api.container_requests().create.assert_called_with(
1307 body=JsonDiffMatcher({
1309 'HOME': '/var/spool/cwl',
1312 'name': runtimeContext.name,
1313 'runtime_constraints': {
1317 'use_existing': True,
1320 '/tmp': {'kind': 'tmp',
1321 "capacity": 1073741824
1323 '/var/spool/cwl': {'kind': 'tmp',
1324 "capacity": 1073741824 }
1326 'state': 'Committed',
1327 'output_name': 'Output for step '+runtimeContext.name,
1328 'owner_uuid': 'zzzzz-8i9sb-zzzzzzzzzzzzzzz',
1329 'output_path': '/var/spool/cwl',
1331 'container_image': '99999999999999999999999999999993+99',
1332 'command': ['ls', '/var/spool/cwl'],
1333 'cwd': '/var/spool/cwl',
1334 'scheduling_parameters': sched,
1336 'secret_mounts': {},
1337 'output_storage_classes': ["default"]
1342 class TestWorkflow(unittest.TestCase):
1344 cwltool.process._names = set()
1345 arv_docker_clear_cache()
1347 def helper(self, runner, enable_reuse=True):
1348 document_loader, avsc_names, schema_metadata, metaschema_loader = cwltool.process.get_schema("v1.0")
1350 make_fs_access=functools.partial(arvados_cwl.CollectionFsAccess,
1351 collection_cache=arvados_cwl.CollectionCache(runner.api, None, 0))
1353 document_loader.fetcher_constructor = functools.partial(arvados_cwl.CollectionFetcher, api_client=runner.api, fs_access=make_fs_access(""))
1354 document_loader.fetcher = document_loader.fetcher_constructor(document_loader.cache, document_loader.session)
1355 document_loader.fetch_text = document_loader.fetcher.fetch_text
1356 document_loader.check_exists = document_loader.fetcher.check_exists
1358 loadingContext = arvados_cwl.context.ArvLoadingContext(
1359 {"avsc_names": avsc_names,
1361 "make_fs_access": make_fs_access,
1362 "loader": document_loader,
1363 "metadata": {"cwlVersion": INTERNAL_VERSION, "http://commonwl.org/cwltool#original_cwlVersion": "v1.0"},
1364 "construct_tool_object": runner.arv_make_tool})
1365 runtimeContext = arvados_cwl.context.ArvRuntimeContext(
1366 {"work_api": "containers",
1368 "name": "test_run_wf_"+str(enable_reuse),
1369 "make_fs_access": make_fs_access,
1371 "enable_reuse": enable_reuse,
1374 return loadingContext, runtimeContext
1376 # The test passes no builder.resources
1377 # Hence the default resources will apply: {'cores': 1, 'ram': 1024, 'outdirSize': 1024, 'tmpdirSize': 1024}
1378 @mock.patch("arvados.collection.CollectionReader")
1379 @mock.patch("arvados.collection.Collection")
1380 @mock.patch('arvados.commands.keepdocker.list_images_in_arv')
1381 def test_run(self, list_images_in_arv, mockcollection, mockcollectionreader):
1382 arvados_cwl.add_arv_hints()
1384 api = mock.MagicMock()
1385 api._rootDesc = get_rootDesc()
1387 runner = arvados_cwl.executor.ArvCwlExecutor(api)
1388 self.assertEqual(runner.work_api, 'containers')
1390 list_images_in_arv.return_value = [["zzzzz-4zz18-zzzzzzzzzzzzzzz"]]
1391 runner.api.collections().get().execute.return_value = {"portable_data_hash": "99999999999999999999999999999993+99"}
1392 runner.api.collections().list().execute.return_value = {"items": [{"uuid": "zzzzz-4zz18-zzzzzzzzzzzzzzz",
1393 "portable_data_hash": "99999999999999999999999999999993+99"}]}
1395 runner.api.containers().current().execute.return_value = {}
1397 runner.project_uuid = "zzzzz-8i9sb-zzzzzzzzzzzzzzz"
1398 runner.ignore_docker_for_reuse = False
1399 runner.num_retries = 0
1400 runner.secret_store = cwltool.secrets.SecretStore()
1402 loadingContext, runtimeContext = self.helper(runner)
1403 runner.fs_access = runtimeContext.make_fs_access(runtimeContext.basedir)
1405 mockcollectionreader().exists.return_value = True
1407 tool, metadata = loadingContext.loader.resolve_ref("tests/wf/scatter2.cwl")
1408 metadata["cwlVersion"] = tool["cwlVersion"]
1410 mockc = mock.MagicMock()
1411 mockcollection.side_effect = lambda *args, **kwargs: CollectionMock(mockc, *args, **kwargs)
1412 mockcollectionreader().find.return_value = arvados.arvfile.ArvadosFile(mock.MagicMock(), "token.txt")
1414 arvtool = arvados_cwl.ArvadosWorkflow(runner, tool, loadingContext)
1415 arvtool.formatgraph = None
1416 it = arvtool.job({}, mock.MagicMock(), runtimeContext)
1418 next(it).run(runtimeContext)
1419 next(it).run(runtimeContext)
1421 with open("tests/wf/scatter2_subwf.cwl") as f:
1422 subwf = StripYAMLComments(f.read()).rstrip()
1424 runner.api.container_requests().create.assert_called_with(
1425 body=JsonDiffMatcher({
1430 "--preserve-entire-environment",
1434 "container_image": "99999999999999999999999999999993+99",
1435 "cwd": "/var/spool/cwl",
1437 "HOME": "/var/spool/cwl",
1441 "/keep/99999999999999999999999999999999+118": {
1442 "kind": "collection",
1443 "portable_data_hash": "99999999999999999999999999999999+118"
1446 "capacity": 1073741824,
1450 "capacity": 1073741824,
1453 "/var/spool/cwl/cwl.input.yml": {
1454 "kind": "collection",
1455 "path": "cwl.input.yml",
1456 "portable_data_hash": "99999999999999999999999999999996+99"
1458 "/var/spool/cwl/workflow.cwl": {
1459 "kind": "collection",
1460 "path": "workflow.cwl",
1461 "portable_data_hash": "99999999999999999999999999999996+99"
1465 "path": "/var/spool/cwl/cwl.output.json"
1468 "name": "scatterstep",
1469 "output_name": "Output for step scatterstep",
1470 "output_path": "/var/spool/cwl",
1474 "runtime_constraints": {
1478 "scheduling_parameters": {},
1479 "secret_mounts": {},
1480 "state": "Committed",
1481 "use_existing": True,
1482 'output_storage_classes': ["default"]
1484 mockc.open().__enter__().write.assert_has_calls([mock.call(subwf)])
1485 mockc.open().__enter__().write.assert_has_calls([mock.call(
1488 "basename": "token.txt",
1490 "location": "/keep/99999999999999999999999999999999+118/token.txt",
1496 # The test passes no builder.resources
1497 # Hence the default resources will apply: {'cores': 1, 'ram': 1024, 'outdirSize': 1024, 'tmpdirSize': 1024}
1498 @mock.patch("arvados.collection.CollectionReader")
1499 @mock.patch("arvados.collection.Collection")
1500 @mock.patch('arvados.commands.keepdocker.list_images_in_arv')
1501 def test_overall_resource_singlecontainer(self, list_images_in_arv, mockcollection, mockcollectionreader):
1502 arvados_cwl.add_arv_hints()
1504 api = mock.MagicMock()
1505 api._rootDesc = get_rootDesc()
1507 runner = arvados_cwl.executor.ArvCwlExecutor(api)
1508 self.assertEqual(runner.work_api, 'containers')
1510 list_images_in_arv.return_value = [["zzzzz-4zz18-zzzzzzzzzzzzzzz"]]
1511 runner.api.collections().get().execute.return_value = {"uuid": "zzzzz-4zz18-zzzzzzzzzzzzzzz",
1512 "portable_data_hash": "99999999999999999999999999999993+99"}
1513 runner.api.collections().list().execute.return_value = {"items": [{"uuid": "zzzzz-4zz18-zzzzzzzzzzzzzzz",
1514 "portable_data_hash": "99999999999999999999999999999993+99"}]}
1516 runner.project_uuid = "zzzzz-8i9sb-zzzzzzzzzzzzzzz"
1517 runner.ignore_docker_for_reuse = False
1518 runner.num_retries = 0
1519 runner.secret_store = cwltool.secrets.SecretStore()
1521 loadingContext, runtimeContext = self.helper(runner)
1522 runner.fs_access = runtimeContext.make_fs_access(runtimeContext.basedir)
1523 loadingContext.do_update = True
1524 tool, metadata = loadingContext.loader.resolve_ref("tests/wf/echo-wf.cwl")
1526 mockcollection.side_effect = lambda *args, **kwargs: CollectionMock(mock.MagicMock(), *args, **kwargs)
1528 arvtool = arvados_cwl.ArvadosWorkflow(runner, tool, loadingContext)
1529 arvtool.formatgraph = None
1530 it = arvtool.job({}, mock.MagicMock(), runtimeContext)
1532 next(it).run(runtimeContext)
1533 next(it).run(runtimeContext)
1535 with open("tests/wf/echo-subwf.cwl") as f:
1536 subwf = StripYAMLComments(f.read())
1538 runner.api.container_requests().create.assert_called_with(
1539 body=JsonDiffMatcher({
1541 'environment': {'HOME': '/var/spool/cwl', 'TMPDIR': '/tmp'},
1542 'scheduling_parameters': {},
1543 'name': u'echo-subwf',
1544 'secret_mounts': {},
1545 'runtime_constraints': {'API': True, 'vcpus': 3, 'ram': 1073741824},
1549 '/var/spool/cwl/cwl.input.yml': {
1550 'portable_data_hash': '99999999999999999999999999999996+99',
1551 'kind': 'collection',
1552 'path': 'cwl.input.yml'
1554 '/var/spool/cwl/workflow.cwl': {
1555 'portable_data_hash': '99999999999999999999999999999996+99',
1556 'kind': 'collection',
1557 'path': 'workflow.cwl'
1560 'path': '/var/spool/cwl/cwl.output.json',
1565 'capacity': 1073741824
1566 }, '/var/spool/cwl': {
1568 'capacity': 3221225472
1571 'state': 'Committed',
1572 'output_path': '/var/spool/cwl',
1573 'container_image': '99999999999999999999999999999993+99',
1578 u'--preserve-entire-environment',
1582 'use_existing': True,
1583 'output_name': u'Output for step echo-subwf',
1584 'cwd': '/var/spool/cwl',
1585 'output_storage_classes': ["default"]
1588 def test_default_work_api(self):
1589 arvados_cwl.add_arv_hints()
1591 api = mock.MagicMock()
1592 api._rootDesc = copy.deepcopy(get_rootDesc())
1593 runner = arvados_cwl.executor.ArvCwlExecutor(api)
1594 self.assertEqual(runner.work_api, 'containers')