From 4a239790d2d4e35a3ba18f8dd8ce307de717d0d6 Mon Sep 17 00:00:00 2001 From: Sergei Trofimov Date: Wed, 13 Dec 2017 11:43:40 +0000 Subject: [PATCH] framework/output: add target_info to RunOutput Make TargetInfo an attribute of run output, replacing the read/write methods for the targetfile. Instead, always load it on creation, if targetfile exists (useful for external scripts), and have a method to set it after creation (uselful during WA run, where the output is created before connecting to the target). --- wa/framework/execution.py | 2 +- wa/framework/output.py | 11 +++++------ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/wa/framework/execution.py b/wa/framework/execution.py index e278c80c..ba566b64 100644 --- a/wa/framework/execution.py +++ b/wa/framework/execution.py @@ -290,7 +290,7 @@ class Executor(object): self.target_manager = TargetManager(config.run_config.device, config.run_config.device_config, output.basepath) - output.write_target_info(self.target_manager.get_target_info()) + output.set_target_info(self.target_manager.get_target_info()) self.logger.info('Initializing execution context') context = ExecutionContext(config_manager, self.target_manager, output) diff --git a/wa/framework/output.py b/wa/framework/output.py index 7cf91221..020a8e7d 100644 --- a/wa/framework/output.py +++ b/wa/framework/output.py @@ -147,6 +147,7 @@ class RunOutput(Output): self.info = None self.state = None self.result = None + self.target_info = None self.jobs = [] if (not os.path.isfile(self.statefile) or not os.path.isfile(self.infofile)): @@ -159,6 +160,8 @@ class RunOutput(Output): self.info = RunInfo.from_pod(read_pod(self.infofile)) self.state = RunState.from_pod(read_pod(self.statefile)) # TODO: propulate the jobs from info in the state + if os.path.isfile(self.targetfile): + self.target_info = TargetInfo.from_pod(read_pod(self.targetfile)) def write_info(self): write_pod(self.info.to_pod(), self.infofile) @@ -174,14 +177,10 @@ class RunOutput(Output): return None return ConfigManager.from_pod(read_pod(self.configfile)) - def write_target_info(self, ti): + def set_target_info(self, ti): + self.target_info = ti write_pod(ti.to_pod(), self.targetfile) - def read_target_config(self): - if not os.path.isfile(self.targetfile): - return None - return TargetInfo.from_pod(read_pod(self.targetfile)) - def write_job_specs(self, job_specs): job_specs[0].to_pod() js_pod = {'jobs': [js.to_pod() for js in job_specs]}