X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/c66cf8a682bd326a38c069045bfc116c61603bc8..2512a633dac10249c351b474b80807725246144a:/sdk/cwl/arvados_cwl/arvcontainer.py diff --git a/sdk/cwl/arvados_cwl/arvcontainer.py b/sdk/cwl/arvados_cwl/arvcontainer.py index b7ef13070a..d4b1e0050d 100644 --- a/sdk/cwl/arvados_cwl/arvcontainer.py +++ b/sdk/cwl/arvados_cwl/arvcontainer.py @@ -28,6 +28,7 @@ from cwltool.job import JobBase import arvados.collection import crunchstat_summary.summarizer +import crunchstat_summary.reader from .arvdocker import arv_docker_get_image from . import done @@ -533,12 +534,26 @@ class ArvadosContainer(JobBase): body={"container_request": {"properties": properties}} ).execute(num_retries=self.arvrunner.num_retries) - if logc is not None: - summerizer = crunchstat_summary.summarizer.NewSummarizer(self.uuid) - summerizer.run() - with logc.open("usage_report.html", "wt") as mr: - mr.write(summerizer.html_report()) - logc.save() + if logc is not None and self.job_runtime.enable_usage_report is not False: + try: + summarizer = crunchstat_summary.summarizer.ContainerRequestSummarizer( + record, + collection_object=logc, + label=self.name, + arv=self.arvrunner.api) + summarizer.run() + with logc.open("usage_report.html", "wt") as mr: + mr.write(summarizer.html_report()) + logc.save() + + # Post warnings about nodes that are under-utilized. + for rc in summarizer._recommend_gen(lambda x: x): + logger.warning(x) + + except Exception as e: + logger.warning("%s unable to generate resource usage report", + self.arvrunner.label(self), + exc_info=(e if self.arvrunner.debug else False)) except WorkflowException as e: # Only include a stack trace if in debug mode. @@ -717,6 +732,12 @@ class RunnerContainer(Runner): if runtimeContext.prefer_cached_downloads: command.append("--prefer-cached-downloads") + if runtimeContext.enable_usage_report is True: + command.append("--enable-usage-report") + + if runtimeContext.enable_usage_report is False: + command.append("--disable-usage-report") + if self.fast_parser: command.append("--fast-parser")