1 # Copyright (C) The Arvados Authors. All rights reserved.
3 # SPDX-License-Identifier: Apache-2.0
13 from functools import partial
16 from cwltool.errors import WorkflowException
17 import cwltool.workflow
18 from schema_salad.sourceline import SourceLine
19 import schema_salad.validate as validate
23 from arvados.keep import KeepClient
24 from arvados.errors import ApiError
26 import arvados_cwl.util
27 from .arvcontainer import RunnerContainer
28 from .arvjob import RunnerJob, RunnerTemplate
29 from .runner import Runner, upload_docker, upload_job_order, upload_workflow_deps
30 from .arvtool import ArvadosCommandTool, validate_cluster_target
31 from .arvworkflow import ArvadosWorkflow, upload_workflow
32 from .fsaccess import CollectionFsAccess, CollectionFetcher, collectionResolver, CollectionCache, pdh_size
33 from .perf import Perf
34 from .pathmapper import NoFollowPathMapper
35 from .task_queue import TaskQueue
36 from .context import ArvLoadingContext, ArvRuntimeContext
37 from ._version import __version__
39 from cwltool.process import shortname, UnsupportedRequirement, use_custom_schema
40 from cwltool.pathmapper import adjustFileObjs, adjustDirObjs, get_listing, visit_class
41 from cwltool.command_line_tool import compute_checksums
43 logger = logging.getLogger('arvados.cwl-runner')
44 metrics = logging.getLogger('arvados.cwl-runner.metrics')
46 DEFAULT_PRIORITY = 500
48 class RuntimeStatusLoggingHandler(logging.Handler):
50 Intercepts logging calls and report them as runtime statuses on runner
53 def __init__(self, runtime_status_update_func):
54 super(RuntimeStatusLoggingHandler, self).__init__()
55 self.runtime_status_update = runtime_status_update_func
57 def emit(self, record):
59 if record.levelno >= logging.ERROR:
61 elif record.levelno >= logging.WARNING:
64 log_msg = record.getMessage()
66 # If the logged message is multi-line, use its first line as status
67 # and the rest as detail.
68 status, detail = log_msg.split('\n', 1)
69 self.runtime_status_update(
71 "%s: %s" % (record.name, status),
75 self.runtime_status_update(
77 "%s: %s" % (record.name, record.getMessage())
80 class ArvCwlExecutor(object):
81 """Execute a CWL tool or workflow, submit work (using either jobs or
82 containers API), wait for them to complete, and report output.
86 def __init__(self, api_client,
93 arvargs = argparse.Namespace()
94 arvargs.work_api = None
95 arvargs.output_name = None
96 arvargs.output_tags = None
97 arvargs.thread_count = 1
98 arvargs.collection_cache_size = None
100 self.api = api_client
102 self.workflow_eval_lock = threading.Condition(threading.RLock())
103 self.final_output = None
104 self.final_status = None
105 self.num_retries = num_retries
107 self.stop_polling = threading.Event()
110 self.final_output_collection = None
111 self.output_name = arvargs.output_name
112 self.output_tags = arvargs.output_tags
113 self.project_uuid = None
114 self.intermediate_output_ttl = 0
115 self.intermediate_output_collections = []
116 self.trash_intermediate = False
117 self.thread_count = arvargs.thread_count
118 self.poll_interval = 12
119 self.loadingContext = None
121 if keep_client is not None:
122 self.keep_client = keep_client
124 self.keep_client = arvados.keep.KeepClient(api_client=self.api, num_retries=self.num_retries)
126 if arvargs.collection_cache_size:
127 collection_cache_size = arvargs.collection_cache_size*1024*1024
129 collection_cache_size = 256*1024*1024
131 self.collection_cache = CollectionCache(self.api, self.keep_client, self.num_retries,
132 cap=collection_cache_size)
134 self.fetcher_constructor = partial(CollectionFetcher,
136 fs_access=CollectionFsAccess("", collection_cache=self.collection_cache),
137 num_retries=self.num_retries)
140 expected_api = ["jobs", "containers"]
141 for api in expected_api:
143 methods = self.api._rootDesc.get('resources')[api]['methods']
144 if ('httpMethod' in methods['create'] and
145 (arvargs.work_api == api or arvargs.work_api is None)):
151 if not self.work_api:
152 if arvargs.work_api is None:
153 raise Exception("No supported APIs")
155 raise Exception("Unsupported API '%s', expected one of %s" % (arvargs.work_api, expected_api))
157 if self.work_api == "jobs":
159 *******************************
160 Using the deprecated 'jobs' API.
162 To get rid of this warning:
164 Users: read about migrating at
165 http://doc.arvados.org/user/cwl/cwl-style.html#migrate
166 and use the option --api=containers
168 Admins: configure the cluster to disable the 'jobs' API as described at:
169 http://doc.arvados.org/install/install-api-server.html#disable_api_methods
170 *******************************""")
172 self.loadingContext = ArvLoadingContext(vars(arvargs))
173 self.loadingContext.fetcher_constructor = self.fetcher_constructor
174 self.loadingContext.resolver = partial(collectionResolver, self.api, num_retries=self.num_retries)
175 self.loadingContext.construct_tool_object = self.arv_make_tool
177 # Add a custom logging handler to the root logger for runtime status reporting
178 # if running inside a container
179 if arvados_cwl.util.get_current_container(self.api, self.num_retries, logger):
180 root_logger = logging.getLogger('')
181 handler = RuntimeStatusLoggingHandler(self.runtime_status_update)
182 root_logger.addHandler(handler)
184 self.runtimeContext = ArvRuntimeContext(vars(arvargs))
185 self.runtimeContext.make_fs_access = partial(CollectionFsAccess,
186 collection_cache=self.collection_cache)
188 validate_cluster_target(self, self.runtimeContext)
191 def arv_make_tool(self, toolpath_object, loadingContext):
192 if "class" in toolpath_object and toolpath_object["class"] == "CommandLineTool":
193 return ArvadosCommandTool(self, toolpath_object, loadingContext)
194 elif "class" in toolpath_object and toolpath_object["class"] == "Workflow":
195 return ArvadosWorkflow(self, toolpath_object, loadingContext)
197 return cwltool.workflow.default_make_tool(toolpath_object, loadingContext)
199 def output_callback(self, out, processStatus):
200 with self.workflow_eval_lock:
201 if processStatus == "success":
202 logger.info("Overall process status is %s", processStatus)
205 logger.error("Overall process status is %s", processStatus)
208 self.api.pipeline_instances().update(uuid=self.pipeline["uuid"],
209 body={"state": state}).execute(num_retries=self.num_retries)
210 self.final_status = processStatus
211 self.final_output = out
212 self.workflow_eval_lock.notifyAll()
215 def start_run(self, runnable, runtimeContext):
216 self.task_queue.add(partial(runnable.run, runtimeContext),
217 self.workflow_eval_lock, self.stop_polling)
219 def process_submitted(self, container):
220 with self.workflow_eval_lock:
221 self.processes[container.uuid] = container
223 def process_done(self, uuid, record):
224 with self.workflow_eval_lock:
225 j = self.processes[uuid]
226 logger.info("%s %s is %s", self.label(j), uuid, record["state"])
227 self.task_queue.add(partial(j.done, record),
228 self.workflow_eval_lock, self.stop_polling)
229 del self.processes[uuid]
231 def runtime_status_update(self, kind, message, detail=None):
233 Updates the runtime_status field on the runner container.
234 Called when there's a need to report errors, warnings or just
235 activity statuses, for example in the RuntimeStatusLoggingHandler.
237 with self.workflow_eval_lock:
238 current = arvados_cwl.util.get_current_container(self.api, self.num_retries, logger)
241 runtime_status = current.get('runtime_status', {})
242 # In case of status being an error, only report the first one.
244 if not runtime_status.get('error'):
245 runtime_status.update({
248 if detail is not None:
249 runtime_status.update({
250 'errorDetail': detail
252 # Further errors are only mentioned as a count.
254 # Get anything before an optional 'and N more' string.
256 error_msg = re.match(
257 r'^(.*?)(?=\s*\(and \d+ more\)|$)', runtime_status.get('error')).groups()[0]
258 more_failures = re.match(
259 r'.*\(and (\d+) more\)', runtime_status.get('error'))
261 # Ignore tests stubbing errors
264 failure_qty = int(more_failures.groups()[0])
265 runtime_status.update({
266 'error': "%s (and %d more)" % (error_msg, failure_qty+1)
269 runtime_status.update({
270 'error': "%s (and 1 more)" % error_msg
272 elif kind in ['warning', 'activity']:
273 # Record the last warning/activity status without regard of
274 # previous occurences.
275 runtime_status.update({
278 if detail is not None:
279 runtime_status.update({
280 kind+"Detail": detail
283 # Ignore any other status kind
286 self.api.containers().update(uuid=current['uuid'],
288 'runtime_status': runtime_status,
289 }).execute(num_retries=self.num_retries)
290 except Exception as e:
291 logger.info("Couldn't update runtime_status: %s", e)
293 def wrapped_callback(self, cb, obj, st):
294 with self.workflow_eval_lock:
296 self.workflow_eval_lock.notifyAll()
298 def get_wrapped_callback(self, cb):
299 return partial(self.wrapped_callback, cb)
301 def on_message(self, event):
302 if event.get("object_uuid") in self.processes and event["event_type"] == "update":
303 uuid = event["object_uuid"]
304 if event["properties"]["new_attributes"]["state"] == "Running":
305 with self.workflow_eval_lock:
306 j = self.processes[uuid]
307 if j.running is False:
309 j.update_pipeline_component(event["properties"]["new_attributes"])
310 logger.info("%s %s is Running", self.label(j), uuid)
311 elif event["properties"]["new_attributes"]["state"] in ("Complete", "Failed", "Cancelled", "Final"):
312 self.process_done(uuid, event["properties"]["new_attributes"])
314 def label(self, obj):
315 return "[%s %s]" % (self.work_api[0:-1], obj.name)
317 def poll_states(self):
318 """Poll status of jobs or containers listed in the processes dict.
320 Runs in a separate thread.
324 remain_wait = self.poll_interval
327 self.stop_polling.wait(remain_wait)
328 if self.stop_polling.is_set():
330 with self.workflow_eval_lock:
331 keys = list(self.processes.keys())
333 remain_wait = self.poll_interval
336 begin_poll = time.time()
337 if self.work_api == "containers":
338 table = self.poll_api.container_requests()
339 elif self.work_api == "jobs":
340 table = self.poll_api.jobs()
342 pageSize = self.poll_api._rootDesc.get('maxItemsPerResponse', 1000)
345 page = keys[:pageSize]
346 keys = keys[pageSize:]
348 proc_states = table.list(filters=[["uuid", "in", page]]).execute(num_retries=self.num_retries)
349 except Exception as e:
350 logger.warn("Error checking states on API server: %s", e)
351 remain_wait = self.poll_interval
354 for p in proc_states["items"]:
356 "object_uuid": p["uuid"],
357 "event_type": "update",
362 finish_poll = time.time()
363 remain_wait = self.poll_interval - (finish_poll - begin_poll)
365 logger.exception("Fatal error in state polling thread.")
366 with self.workflow_eval_lock:
367 self.processes.clear()
368 self.workflow_eval_lock.notifyAll()
370 self.stop_polling.set()
372 def add_intermediate_output(self, uuid):
374 self.intermediate_output_collections.append(uuid)
376 def trash_intermediate_output(self):
377 logger.info("Cleaning up intermediate output collections")
378 for i in self.intermediate_output_collections:
380 self.api.collections().delete(uuid=i).execute(num_retries=self.num_retries)
382 logger.warn("Failed to delete intermediate output: %s", sys.exc_info()[1], exc_info=(sys.exc_info()[1] if self.debug else False))
383 if sys.exc_info()[0] is KeyboardInterrupt or sys.exc_info()[0] is SystemExit:
386 def check_features(self, obj):
387 if isinstance(obj, dict):
388 if obj.get("writable") and self.work_api != "containers":
389 raise SourceLine(obj, "writable", UnsupportedRequirement).makeError("InitialWorkDir feature 'writable: true' not supported with --api=jobs")
390 if obj.get("class") == "DockerRequirement":
391 if obj.get("dockerOutputDirectory"):
392 if self.work_api != "containers":
393 raise SourceLine(obj, "dockerOutputDirectory", UnsupportedRequirement).makeError(
394 "Option 'dockerOutputDirectory' of DockerRequirement not supported with --api=jobs.")
395 if not obj.get("dockerOutputDirectory").startswith('/'):
396 raise SourceLine(obj, "dockerOutputDirectory", validate.ValidationException).makeError(
397 "Option 'dockerOutputDirectory' must be an absolute path.")
398 if obj.get("class") == "http://commonwl.org/cwltool#Secrets" and self.work_api != "containers":
399 raise SourceLine(obj, "class", UnsupportedRequirement).makeError("Secrets not supported with --api=jobs")
400 for v in obj.itervalues():
401 self.check_features(v)
402 elif isinstance(obj, list):
403 for i,v in enumerate(obj):
404 with SourceLine(obj, i, UnsupportedRequirement, logger.isEnabledFor(logging.DEBUG)):
405 self.check_features(v)
407 def make_output_collection(self, name, storage_classes, tagsString, outputObj):
408 outputObj = copy.deepcopy(outputObj)
411 def capture(fileobj):
412 files.append(fileobj)
414 adjustDirObjs(outputObj, capture)
415 adjustFileObjs(outputObj, capture)
417 generatemapper = NoFollowPathMapper(files, "", "", separateDirs=False)
419 final = arvados.collection.Collection(api_client=self.api,
420 keep_client=self.keep_client,
421 num_retries=self.num_retries)
423 for k,v in generatemapper.items():
424 if k.startswith("_:"):
425 if v.type == "Directory":
427 if v.type == "CreateFile":
428 with final.open(v.target, "wb") as f:
429 f.write(v.resolved.encode("utf-8"))
432 if not k.startswith("keep:"):
433 raise Exception("Output source is not in keep or a literal")
435 srccollection = sp[0][5:]
437 reader = self.collection_cache.get(srccollection)
438 srcpath = "/".join(sp[1:]) if len(sp) > 1 else "."
439 final.copy(srcpath, v.target, source_collection=reader, overwrite=False)
440 except arvados.errors.ArgumentError as e:
441 logger.error("Creating CollectionReader for '%s' '%s': %s", k, v, e)
444 logger.warn("While preparing output collection: %s", e)
446 def rewrite(fileobj):
447 fileobj["location"] = generatemapper.mapper(fileobj["location"]).target
448 for k in ("listing", "contents", "nameext", "nameroot", "dirname"):
452 adjustDirObjs(outputObj, rewrite)
453 adjustFileObjs(outputObj, rewrite)
455 with final.open("cwl.output.json", "w") as f:
456 json.dump(outputObj, f, sort_keys=True, indent=4, separators=(',',': '))
458 final.save_new(name=name, owner_uuid=self.project_uuid, storage_classes=storage_classes, ensure_unique_name=True)
460 logger.info("Final output collection %s \"%s\" (%s)", final.portable_data_hash(),
461 final.api_response()["name"],
462 final.manifest_locator())
464 final_uuid = final.manifest_locator()
465 tags = tagsString.split(',')
467 self.api.links().create(body={
468 "head_uuid": final_uuid, "link_class": "tag", "name": tag
469 }).execute(num_retries=self.num_retries)
471 def finalcollection(fileobj):
472 fileobj["location"] = "keep:%s/%s" % (final.portable_data_hash(), fileobj["location"])
474 adjustDirObjs(outputObj, finalcollection)
475 adjustFileObjs(outputObj, finalcollection)
477 return (outputObj, final)
479 def set_crunch_output(self):
480 if self.work_api == "containers":
481 current = arvados_cwl.util.get_current_container(self.api, self.num_retries, logger)
485 self.api.containers().update(uuid=current['uuid'],
487 'output': self.final_output_collection.portable_data_hash(),
488 }).execute(num_retries=self.num_retries)
489 self.api.collections().update(uuid=self.final_output_collection.manifest_locator(),
492 }).execute(num_retries=self.num_retries)
493 except Exception as e:
494 logger.info("Setting container output: %s", e)
495 elif self.work_api == "jobs" and "TASK_UUID" in os.environ:
496 self.api.job_tasks().update(uuid=os.environ["TASK_UUID"],
498 'output': self.final_output_collection.portable_data_hash(),
499 'success': self.final_status == "success",
501 }).execute(num_retries=self.num_retries)
503 def arv_executor(self, tool, job_order, runtimeContext, logger=None):
504 self.debug = runtimeContext.debug
506 tool.visit(self.check_features)
508 self.project_uuid = runtimeContext.project_uuid
510 self.fs_access = runtimeContext.make_fs_access(runtimeContext.basedir)
511 self.secret_store = runtimeContext.secret_store
513 self.trash_intermediate = runtimeContext.trash_intermediate
514 if self.trash_intermediate and self.work_api != "containers":
515 raise Exception("--trash-intermediate is only supported with --api=containers.")
517 self.intermediate_output_ttl = runtimeContext.intermediate_output_ttl
518 if self.intermediate_output_ttl and self.work_api != "containers":
519 raise Exception("--intermediate-output-ttl is only supported with --api=containers.")
520 if self.intermediate_output_ttl < 0:
521 raise Exception("Invalid value %d for --intermediate-output-ttl, cannot be less than zero" % self.intermediate_output_ttl)
523 if runtimeContext.submit_request_uuid and self.work_api != "containers":
524 raise Exception("--submit-request-uuid requires containers API, but using '{}' api".format(self.work_api))
526 if not runtimeContext.name:
527 runtimeContext.name = self.name = tool.tool.get("label") or tool.metadata.get("label") or os.path.basename(tool.tool["id"])
529 # Upload direct dependencies of workflow steps, get back mapping of files to keep references.
530 # Also uploads docker images.
531 merged_map = upload_workflow_deps(self, tool)
533 # Reload tool object which may have been updated by
534 # upload_workflow_deps
535 # Don't validate this time because it will just print redundant errors.
536 loadingContext = self.loadingContext.copy()
537 loadingContext.loader = tool.doc_loader
538 loadingContext.avsc_names = tool.doc_schema
539 loadingContext.metadata = tool.metadata
540 loadingContext.do_validate = False
542 tool = self.arv_make_tool(tool.doc_loader.idx[tool.tool["id"]],
545 # Upload local file references in the job order.
546 job_order = upload_job_order(self, "%s input" % runtimeContext.name,
549 existing_uuid = runtimeContext.update_workflow
550 if existing_uuid or runtimeContext.create_workflow:
551 # Create a pipeline template or workflow record and exit.
552 if self.work_api == "jobs":
553 tmpl = RunnerTemplate(self, tool, job_order,
554 runtimeContext.enable_reuse,
556 submit_runner_ram=runtimeContext.submit_runner_ram,
557 name=runtimeContext.name,
558 merged_map=merged_map)
560 # cwltool.main will write our return value to stdout.
561 return (tmpl.uuid, "success")
562 elif self.work_api == "containers":
563 return (upload_workflow(self, tool, job_order,
566 submit_runner_ram=runtimeContext.submit_runner_ram,
567 name=runtimeContext.name,
568 merged_map=merged_map),
571 self.ignore_docker_for_reuse = runtimeContext.ignore_docker_for_reuse
572 self.eval_timeout = runtimeContext.eval_timeout
574 runtimeContext = runtimeContext.copy()
575 runtimeContext.use_container = True
576 runtimeContext.tmpdir_prefix = "tmp"
577 runtimeContext.work_api = self.work_api
579 if self.work_api == "containers":
580 if self.ignore_docker_for_reuse:
581 raise Exception("--ignore-docker-for-reuse not supported with containers API.")
582 runtimeContext.outdir = "/var/spool/cwl"
583 runtimeContext.docker_outdir = "/var/spool/cwl"
584 runtimeContext.tmpdir = "/tmp"
585 runtimeContext.docker_tmpdir = "/tmp"
586 elif self.work_api == "jobs":
587 if runtimeContext.priority != DEFAULT_PRIORITY:
588 raise Exception("--priority not implemented for jobs API.")
589 runtimeContext.outdir = "$(task.outdir)"
590 runtimeContext.docker_outdir = "$(task.outdir)"
591 runtimeContext.tmpdir = "$(task.tmpdir)"
593 if runtimeContext.priority < 1 or runtimeContext.priority > 1000:
594 raise Exception("--priority must be in the range 1..1000.")
598 def estimate_collection_cache(obj):
599 if obj.get("location", "").startswith("keep:"):
600 m = pdh_size.match(obj["location"][5:])
601 if m and m.group(1) not in visited:
602 visited.add(m.group(1))
603 estimated_size[0] += int(m.group(2))
604 visit_class(job_order, ("File", "Directory"), estimate_collection_cache)
605 logger.info("Estimated size %s", estimated_size)
608 if runtimeContext.submit:
609 # Submit a runner job to run the workflow for us.
610 if self.work_api == "containers":
611 if tool.tool["class"] == "CommandLineTool" and runtimeContext.wait and (not runtimeContext.always_submit_runner):
612 runtimeContext.runnerjob = tool.tool["id"]
613 runnerjob = tool.job(job_order,
614 self.output_callback,
615 runtimeContext).next()
617 runnerjob = RunnerContainer(self, tool, job_order, runtimeContext.enable_reuse,
620 submit_runner_ram=runtimeContext.submit_runner_ram,
621 name=runtimeContext.name,
622 on_error=runtimeContext.on_error,
623 submit_runner_image=runtimeContext.submit_runner_image,
624 intermediate_output_ttl=runtimeContext.intermediate_output_ttl,
625 merged_map=merged_map,
626 priority=runtimeContext.priority,
627 secret_store=self.secret_store,
628 collection_cache_size=runtimeContext.collection_cache_size)
629 elif self.work_api == "jobs":
630 runnerjob = RunnerJob(self, tool, job_order, runtimeContext.enable_reuse,
633 submit_runner_ram=runtimeContext.submit_runner_ram,
634 name=runtimeContext.name,
635 on_error=runtimeContext.on_error,
636 submit_runner_image=runtimeContext.submit_runner_image,
637 merged_map=merged_map)
638 elif runtimeContext.cwl_runner_job is None and self.work_api == "jobs":
639 # Create pipeline for local run
640 self.pipeline = self.api.pipeline_instances().create(
642 "owner_uuid": self.project_uuid,
643 "name": runtimeContext.name if runtimeContext.name else shortname(tool.tool["id"]),
645 "state": "RunningOnClient"}).execute(num_retries=self.num_retries)
646 logger.info("Pipeline instance %s", self.pipeline["uuid"])
648 if runnerjob and not runtimeContext.wait:
649 submitargs = runtimeContext.copy()
650 submitargs.submit = False
651 runnerjob.run(submitargs)
652 return (runnerjob.uuid, "success")
654 current_container = arvados_cwl.util.get_current_container(self.api, self.num_retries, logger)
655 if current_container:
656 logger.info("Running inside container %s", current_container.get("uuid"))
658 self.poll_api = arvados.api('v1', timeout=runtimeContext.http_timeout)
659 self.polling_thread = threading.Thread(target=self.poll_states)
660 self.polling_thread.start()
662 self.task_queue = TaskQueue(self.workflow_eval_lock, self.thread_count)
665 self.workflow_eval_lock.acquire()
667 jobiter = iter((runnerjob,))
669 if runtimeContext.cwl_runner_job is not None:
670 self.uuid = runtimeContext.cwl_runner_job.get('uuid')
671 jobiter = tool.job(job_order,
672 self.output_callback,
675 # Holds the lock while this code runs and releases it when
676 # it is safe to do so in self.workflow_eval_lock.wait(),
677 # at which point on_message can update job state and
678 # process output callbacks.
680 loopperf = Perf(metrics, "jobiter")
682 for runnable in jobiter:
685 if self.stop_polling.is_set():
688 if self.task_queue.error is not None:
689 raise self.task_queue.error
692 with Perf(metrics, "run"):
693 self.start_run(runnable, runtimeContext)
695 if (self.task_queue.in_flight + len(self.processes)) > 0:
696 self.workflow_eval_lock.wait(3)
698 logger.error("Workflow is deadlocked, no runnable processes and not waiting on any pending processes.")
701 if self.stop_polling.is_set():
707 while (self.task_queue.in_flight + len(self.processes)) > 0:
708 if self.task_queue.error is not None:
709 raise self.task_queue.error
710 self.workflow_eval_lock.wait(3)
712 except UnsupportedRequirement:
715 if sys.exc_info()[0] is KeyboardInterrupt or sys.exc_info()[0] is SystemExit:
716 logger.error("Interrupted, workflow will be cancelled")
718 logger.error("Execution failed:\n%s", sys.exc_info()[1], exc_info=(sys.exc_info()[1] if self.debug else False))
720 self.api.pipeline_instances().update(uuid=self.pipeline["uuid"],
721 body={"state": "Failed"}).execute(num_retries=self.num_retries)
722 if runnerjob and runnerjob.uuid and self.work_api == "containers":
723 self.api.container_requests().update(uuid=runnerjob.uuid,
724 body={"priority": "0"}).execute(num_retries=self.num_retries)
726 self.workflow_eval_lock.release()
727 self.task_queue.drain()
728 self.stop_polling.set()
729 self.polling_thread.join()
730 self.task_queue.join()
732 if self.final_status == "UnsupportedRequirement":
733 raise UnsupportedRequirement("Check log for details.")
735 if self.final_output is None:
736 raise WorkflowException("Workflow did not return a result.")
738 if runtimeContext.submit and isinstance(runnerjob, Runner):
739 logger.info("Final output collection %s", runnerjob.final_output)
741 if self.output_name is None:
742 self.output_name = "Output of %s" % (shortname(tool.tool["id"]))
743 if self.output_tags is None:
744 self.output_tags = ""
746 storage_classes = runtimeContext.storage_classes.strip().split(",")
747 self.final_output, self.final_output_collection = self.make_output_collection(self.output_name, storage_classes, self.output_tags, self.final_output)
748 self.set_crunch_output()
750 if runtimeContext.compute_checksum:
751 adjustDirObjs(self.final_output, partial(get_listing, self.fs_access))
752 adjustFileObjs(self.final_output, partial(compute_checksums, self.fs_access))
754 if self.trash_intermediate and self.final_status == "success":
755 self.trash_intermediate_output()
757 return (self.final_output, self.final_status)