Skip to content
Snippets Groups Projects
Commit cb1a37dc authored by Klaus Rabbertz's avatar Klaus Rabbertz
Browse files

Improve Singe- and MultiGridClosure to skip in case first seeds; always give...

Improve Singe- and MultiGridClosure to skip in case first seeds; always give return 0 for force = True
parent 8357bca0
Branches
No related tags found
No related merge requests found
...@@ -28,7 +28,7 @@ class CopyFastWarm(Task, TarballExtractionMixin, law.LocalWorkflow): ...@@ -28,7 +28,7 @@ class CopyFastWarm(Task, TarballExtractionMixin, law.LocalWorkflow):
def workflow_requires(self): def workflow_requires(self):
if self.force: if self.force:
return {"fastwarm": FastWarm.req(self, acceptance=0)} return 0
else: else:
return {"fastwarm": FastWarm.req(self)} return {"fastwarm": FastWarm.req(self)}
......
...@@ -43,7 +43,7 @@ class CopyRewarmup(Task, TarballExtractionMixin, law.LocalWorkflow): ...@@ -43,7 +43,7 @@ class CopyRewarmup(Task, TarballExtractionMixin, law.LocalWorkflow):
def workflow_requires(self): def workflow_requires(self):
if self.force: if self.force:
return {"rewarmup": Rewarmup.req(self, acceptance=0)} return 0
else: else:
return {"rewarmup": Rewarmup.req(self)} return {"rewarmup": Rewarmup.req(self)}
......
...@@ -43,7 +43,7 @@ class CopyWarmup(Task, TarballExtractionMixin, law.LocalWorkflow): ...@@ -43,7 +43,7 @@ class CopyWarmup(Task, TarballExtractionMixin, law.LocalWorkflow):
def workflow_requires(self): def workflow_requires(self):
if self.force: if self.force:
return {"warmup": Warmup.req(self, acceptance=0)} return 0
else: else:
return {"warmup": Warmup.req(self)} return {"warmup": Warmup.req(self)}
......
...@@ -48,7 +48,7 @@ class MultiGridClosure(Task, law.LocalWorkflow): ...@@ -48,7 +48,7 @@ class MultiGridClosure(Task, law.LocalWorkflow):
def workflow_requires(self): def workflow_requires(self):
if self.force: if self.force:
return {"fnlocppread": FnloCppread.req(self, acceptance=0)} return 0
else: else:
return {"fnlocppread": FnloCppread.req(self)} return {"fnlocppread": FnloCppread.req(self)}
...@@ -73,17 +73,33 @@ class MultiGridClosure(Task, law.LocalWorkflow): ...@@ -73,17 +73,33 @@ class MultiGridClosure(Task, law.LocalWorkflow):
with self.output().temporary_path() as self.temp_output_path: with self.output().temporary_path() as self.temp_output_path:
os.mkdir(self.temp_output_path) os.mkdir(self.temp_output_path)
tabglob = ( tablepath = os.path.join(self.merge_dir, self.name, self.branch_data['channel'])
"{self.merge_dir}/{self.name}/{self.branch_data[channel]}/" logger.debug('Table path is: %s', tablepath)
"*.{self.branch_data[observable]}.s{self.branch_data[seed]}.tab.gz" # FastProd starting seed for channel
).format(self=self) iseed = self.branch_data['seed']
logger.debug("Table glob: %s", tabglob) # FastProd job number for channel
tables = glob.glob(tabglob) njobs = FastProd().fastprod_jobs[self.branch_data['index']]
fseed = iseed + njobs
if not tables: # Find smallest seed for which table exists (and corresponding dat file, see check in FnloCppread)
raise RuntimeError('No matching file for table glob {}.'.format(tabglob)) ind = iseed
iseed = -1
# Loop over all matching tables is done in python script; only take the first one from all matches while ind < fseed:
tableglob = os.path.join(tablepath,'*.{}.s{}.tab.gz'.format(self.branch_data['observable'],ind))
logger.debug("Table glob: %s", tableglob)
tables = glob.glob(tableglob)
# There should be exactly one matching table
if tables:
iseed = ind
break
else:
logger.warning('No table found for table glob {} and job seed {}. Trying to find first table in next job!'.format(tableglob,ind))
ind = ind+1
if iseed < 0:
message = "No job found for channel {} with a table for observable {}. Multigrid closure plots not possible! Fail!".format(self.branch_data['channel'],self.branch_data['observable'])
raise RuntimeError(message)
# Loop over all matching tables is done in python script; only take the first one
tabfile = tables[0] tabfile = tables[0]
logger.debug("First table file: %s", tabfile) logger.debug("First table file: %s", tabfile)
......
...@@ -43,7 +43,7 @@ class PlotRuntime(Task, law.LocalWorkflow): ...@@ -43,7 +43,7 @@ class PlotRuntime(Task, law.LocalWorkflow):
def workflow_requires(self): def workflow_requires(self):
if self.force: if self.force:
return {"copytables": CopyTables.req(self, acceptance=0)} return 0
else: else:
return {"copytables": CopyTables.req(self)} return {"copytables": CopyTables.req(self)}
......
...@@ -55,7 +55,7 @@ class PlotVegasGrids(Task, law.LocalWorkflow): ...@@ -55,7 +55,7 @@ class PlotVegasGrids(Task, law.LocalWorkflow):
def workflow_requires(self): def workflow_requires(self):
if self.force: if self.force:
return {"copywarmup": CopyWarmup.req(self, acceptance=0)} return 0
else: else:
return {"copywarmup": CopyWarmup.req(self)} return {"copywarmup": CopyWarmup.req(self)}
......
...@@ -40,14 +40,12 @@ class SingleGridClosure(Task, law.LocalWorkflow): ...@@ -40,14 +40,12 @@ class SingleGridClosure(Task, law.LocalWorkflow):
"""Branch data dicts. Each branch should correspond to exactly one output directory.""" """Branch data dicts. Each branch should correspond to exactly one output directory."""
return { return {
i : {'channel': ch, 'index': ch_index, 'observable': obs, 'seed': FastProd().starting_seeds[ch_index]} i : {'channel': ch, 'index': ch_index, 'observable': obs, 'seed': FastProd().starting_seeds[ch_index]}
for i, ((ch_index, ch), obs) in enumerate(product( for i, ((ch_index, ch), obs) in enumerate(product(enumerate(self.channels), self.observables, ))
enumerate(self.channels), self.observables,
))
} }
def workflow_requires(self): def workflow_requires(self):
if self.force: if self.force:
return {"fnlocppread": FnloCppread.req(self, acceptance=0)} return 0
else: else:
return {"fnlocppread": FnloCppread.req(self)} return {"fnlocppread": FnloCppread.req(self)}
...@@ -68,17 +66,44 @@ class SingleGridClosure(Task, law.LocalWorkflow): ...@@ -68,17 +66,44 @@ class SingleGridClosure(Task, law.LocalWorkflow):
) )
def run(self): def run(self):
tabglob = ( tablepath = os.path.join(self.merge_dir, self.name, self.branch_data['channel'])
"{self.merge_dir}/{self.name}/{self.branch_data[channel]}/" logger.debug('Table path is: %s', tablepath)
"*.{self.branch_data[observable]}.s{self.branch_data[seed]}.tab.gz" # FastProd starting seed for channel
).format(self=self) iseed = self.branch_data['seed']
logger.debug("Table glob: %s", tabglob) # FastProd job number for channel
tables = glob.glob(tabglob) njobs = FastProd().fastprod_jobs[self.branch_data['index']]
fseed = iseed + njobs
# Find smallest seed for which all tables exist (and corresponding dat files, see check in FnloCppread)
nobs = len(self.observables)
tableglob = os.path.join(tablepath,'*.s{}.tab.gz'.format(self.branch_data['seed']))
tables = glob.glob(tableglob)
ntabs = len(tables)
logger.debug('Test table glob is: %s', tableglob)
logger.debug('Starting seed: {}, no. of jobs: {}, no. of observables: {}, no. table files: {}'.format(iseed,njobs,nobs,ntabs))
if nobs != ntabs:
logger.warning('Only {} tables available instead of {} for first job seed {}. Trying to find job with table for each observable!'.format(ntabs,nobs,iseed))
ind = iseed+1
iseed = -1
while ind < fseed:
tableglob = os.path.join(tablepath,'*.s{}.tab.gz'.format(ind))
tables = glob.glob(tableglob)
ntabs = len(tables)
logger.debug('Found {} tables out of {} for seed {}.'.format(ntabs,nobs,ind))
if ntabs == nobs:
iseed = ind
break
else:
ind = ind+1
if iseed < 0:
message = "No job found for channel {} with table for each observable. Single job closure plots not possible! Fail!".format(self.branch_data['channel'])
raise RuntimeError(message)
if not tables: tableglob = os.path.join(tablepath,'*.{}.s{}.tab.gz'.format(self.branch_data['observable'],iseed))
raise RuntimeError('No matching file for table glob {}.'.format(tabglob)) logger.debug('Table glob is: %s', tableglob)
tables = glob.glob(tableglob)
# Only take the first one from all matches # There should be exactly one matching table
tabfile = tables[0] tabfile = tables[0]
logger.debug("Table file: %s", tabfile) logger.debug("Table file: %s", tabfile)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment