From 2ef4074c8b288e5c51d60c0adc9538dca0e98c31 Mon Sep 17 00:00:00 2001 From: Sergei Trofimov Date: Fri, 15 Sep 2017 13:41:24 +0100 Subject: [PATCH] framework/execution: ExecutionContext enhancements - Add workload property as the shortcut for accessing the workoad for the current job. - Add set_status method that setts the status of the current job. - Add get_metric method that searches for a metric in the output for the current job, or failing that, in the run output. --- wa/framework/execution.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/wa/framework/execution.py b/wa/framework/execution.py index 69343b00..d4afe8c1 100644 --- a/wa/framework/execution.py +++ b/wa/framework/execution.py @@ -75,6 +75,11 @@ class ExecutionContext(object): return True return self.current_job.spec.id != self.next_job.spec.id + @property + def workload(self): + if self.current_job: + return self.current_job.workload + @property def job_output(self): if self.current_job: @@ -150,6 +155,11 @@ class ExecutionContext(object): self.output.write_result() self.current_job = None + def set_status(self, status): + if not self.current_job: + raise RuntimeError('No jobs in progress') + self.current_job.status = Status(status) + def extract_results(self): self.tm.extract_results(self) @@ -171,6 +181,14 @@ class ExecutionContext(object): def write_state(self): self.run_output.write_state() + def get_metric(self, name): + try: + return self.output.get_metric(name) + except HostError: + if not self.current_job: + raise + return self.run_output.get_metric(name) + def add_metric(self, name, value, units=None, lower_is_better=False, classifiers=None): if self.current_job: