From 547ae1c10eeb3be3d1bf0afb7d1e83168dc98c72 Mon Sep 17 00:00:00 2001 From: Sergei Trofimov Date: Thu, 9 Mar 2017 16:26:50 +0000 Subject: [PATCH] Job output dir handling. --- wa/framework/configuration/core.py | 6 +++++- wa/framework/configuration/execution.py | 4 ++++ wa/framework/execution.py | 6 ++++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/wa/framework/configuration/core.py b/wa/framework/configuration/core.py index 82237ce6..d274b6c0 100644 --- a/wa/framework/configuration/core.py +++ b/wa/framework/configuration/core.py @@ -927,7 +927,11 @@ class JobSpec(Configuration): self.runtime_parameters = target_manager.merge_runtime_parameters(runtime_parameters) def finalize(self): - self.id = "-".join([source.config['id'] for source in self._sources[1:]]) # ignore first id, "global" + self.id = "-".join([source.config['id'] + for source in self._sources[1:]]) # ignore first id, "global" + if self.label is None: + self.label = self.workload_name + # This is used to construct the list of Jobs WA will run diff --git a/wa/framework/configuration/execution.py b/wa/framework/configuration/execution.py index 032d9e52..dd8df4e0 100644 --- a/wa/framework/configuration/execution.py +++ b/wa/framework/configuration/execution.py @@ -38,6 +38,10 @@ class Job(object): def id(self): return self.spec.id + @property + def output_name(self): + return '{}-{}-{}'.format(self.id, self.spec.label, self.iteration) + def __init__(self, spec, iteration, context): self.logger = logging.getLogger('job') self.spec = spec diff --git a/wa/framework/execution.py b/wa/framework/execution.py index 3b562fad..cedc5714 100644 --- a/wa/framework/execution.py +++ b/wa/framework/execution.py @@ -104,6 +104,11 @@ class ExecutionContext(object): return True return self.current_job.spec.id != self.next_job.spec.id + @property + def output_directory(self): + if self.current_job: + return os.path.join(self.output.basepath, self.current_job.output_name) + return self.output.basepath def __init__(self, cm, tm, output): self.logger = logging.getLogger('context') @@ -133,6 +138,7 @@ class ExecutionContext(object): if not self.job_queue: raise RuntimeError('No jobs to run') self.current_job = self.job_queue.pop(0) + os.makedirs(self.output_directory) return self.current_job def end_job(self):