From e81aaf342165b3f638870d96c0bfcba3277fa994 Mon Sep 17 00:00:00 2001 From: Marc Bonnici Date: Tue, 30 Oct 2018 17:15:43 +0000 Subject: [PATCH] framework/output: Split out common Output functionality In preparation for the creation of a DatabaseRunOut split out functionality that can be shared. --- wa/framework/output.py | 51 +++++++++++++++++++++++------------------- 1 file changed, 28 insertions(+), 23 deletions(-) diff --git a/wa/framework/output.py b/wa/framework/output.py index a499564e..aa2d66c2 100644 --- a/wa/framework/output.py +++ b/wa/framework/output.py @@ -165,8 +165,35 @@ class Output(object): def __str__(self): return os.path.basename(self.basepath) +class RunOutputCommon(object): + ''' Split out common functionality to form a second base of + the RunOutput classes + ''' + @property + def run_config(self): + if self._combined_config: + return self._combined_config.run_config -class RunOutput(Output): + @property + def settings(self): + if self._combined_config: + return self._combined_config.settings + + def get_job_spec(self, spec_id): + for spec in self.job_specs: + if spec.id == spec_id: + return spec + return None + + def list_workloads(self): + workloads = [] + for job in self.jobs: + if job.label not in workloads: + workloads.append(job.label) + return workloads + + +class RunOutput(Output, RunOutputCommon): kind = 'run' @@ -207,16 +234,6 @@ class RunOutput(Output): path = os.path.join(self.basepath, '__failed') return ensure_directory_exists(path) - @property - def run_config(self): - if self._combined_config: - return self._combined_config.run_config - - @property - def settings(self): - if self._combined_config: - return self._combined_config.settings - @property def augmentations(self): run_augs = set([]) @@ -302,18 +319,6 @@ class RunOutput(Output): shutil.move(job_output.basepath, failed_path) job_output.basepath = failed_path - def get_job_spec(self, spec_id): - for spec in self.job_specs: - if spec.id == spec_id: - return spec - return None - - def list_workloads(self): - workloads = [] - for job in self.jobs: - if job.label not in workloads: - workloads.append(job.label) - return workloads class JobOutput(Output):