Repository: Duke-GCB/lando

Issue:
k8s save calrissian record usage report
Calrissian has a usage report option that will record statistics about how memory/cpu usage when running a job. Add the `--usage-report <report.json>` flag to the calrissian command line.

Relevant code:
https://github.com/Duke-GCB/lando/blob/da2c40ef588578993a45c46f20676a691ef68067/lando/k8s/jobmanager.py#L171-L175

This report should be saved into the output directory that is uploaded to DukeDS.

Discussion:

Patch:
diff --git a/lando/k8s/jobmanager.py b/lando/k8s/jobmanager.py
index 456a8f2..6774189 100644
--- a/lando/k8s/jobmanager.py
+++ b/lando/k8s/jobmanager.py
@@ -171,7 +171,8 @@ class JobManager(object):
         command_parts.extend(["--tmp-outdir-prefix", Paths.TMPOUT_DATA + "/",
                               "--outdir", Paths.OUTPUT_RESULTS_DIR + "/",
                               "--max-ram", self.job.job_flavor_memory,
-                              "--max-cores", str(self.job.job_flavor_cpus)
+                              "--max-cores", str(self.job.job_flavor_cpus),
+                              "--usage-report", str(self.names.usage_report_path),
                               ])
         command_parts.extend([
             self.names.workflow_path,
@@ -400,6 +401,7 @@ class Names(object):
         self.run_workflow_stdout_path = '{}/bespin-workflow-output.json'.format(Paths.OUTPUT_DATA)
         self.run_workflow_stderr_path = '{}/bespin-workflow-output.log'.format(Paths.OUTPUT_DATA)
         self.annotate_project_details_path = '{}/annotate_project_details.sh'.format(Paths.OUTPUT_DATA)
+        self.usage_report_path = '{}/job-{}-resource-usage.json'.format(Paths.OUTPUT_DATA, suffix)
 
 
 class Paths(object):


Test patch:
diff --git a/lando/k8s/tests/test_jobmanager.py b/lando/k8s/tests/test_jobmanager.py
index e98c2a4..73c5ed6 100644
--- a/lando/k8s/tests/test_jobmanager.py
+++ b/lando/k8s/tests/test_jobmanager.py
@@ -193,6 +193,7 @@ class TestJobManager(TestCase):
         expected_bash_command = 'cwltool --tmp-outdir-prefix /bespin/tmpout/ ' \
                                 '--outdir /bespin/output-data/results/ ' \
                                 '--max-ram 1G --max-cores 2 ' \
+                                '--usage-report /bespin/output-data/job-51-jpb-resource-usage.json ' \
                                 '/bespin/job-data/workflow/someurl ' \
                                 '/bespin/job-data/job-order.json ' \
                                 '>/bespin/output-data/bespin-workflow-output.json ' \