mirror of
				https://github.com/ARM-software/workload-automation.git
				synced 2025-11-04 00:52:08 +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:
		@@ -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:
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user