mirror of
https://github.com/ARM-software/workload-automation.git
synced 2025-01-31 10:11:17 +00:00
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.
This commit is contained in:
parent
82b0b238c2
commit
2ef4074c8b
@ -75,6 +75,11 @@ class ExecutionContext(object):
|
|||||||
return True
|
return True
|
||||||
return self.current_job.spec.id != self.next_job.spec.id
|
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
|
@property
|
||||||
def job_output(self):
|
def job_output(self):
|
||||||
if self.current_job:
|
if self.current_job:
|
||||||
@ -150,6 +155,11 @@ class ExecutionContext(object):
|
|||||||
self.output.write_result()
|
self.output.write_result()
|
||||||
self.current_job = None
|
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):
|
def extract_results(self):
|
||||||
self.tm.extract_results(self)
|
self.tm.extract_results(self)
|
||||||
|
|
||||||
@ -171,6 +181,14 @@ class ExecutionContext(object):
|
|||||||
def write_state(self):
|
def write_state(self):
|
||||||
self.run_output.write_state()
|
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,
|
def add_metric(self, name, value, units=None, lower_is_better=False,
|
||||||
classifiers=None):
|
classifiers=None):
|
||||||
if self.current_job:
|
if self.current_job:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user