Commit 82db951c authored by plasky's avatar plasky

Merge branch 'master' of git.ligo.org:Monash/tupak

parents 96129f0d ac14b8db
Pipeline #19446 passed with stages
in 5 minutes and 46 seconds
...@@ -17,13 +17,26 @@ def result_file_name(outdir, label): ...@@ -17,13 +17,26 @@ def result_file_name(outdir, label):
return '{}/{}_result.h5'.format(outdir, label) return '{}/{}_result.h5'.format(outdir, label)
def read_in_result(outdir, label): def read_in_result(outdir=None, label=None, filename=None):
""" Read in a saved .h5 data file """ """ Read in a saved .h5 data file
filename = result_file_name(outdir, label)
Parameters
----------
outdir, label: str
If given, use the default naming convention for saved results file
filename: str
If given, try to load from this filename
Returns:
result: tupak.result.Result instance
"""
if filename is None:
filename = result_file_name(outdir, label)
if os.path.isfile(filename): if os.path.isfile(filename):
return Result(deepdish.io.load(filename)) return Result(deepdish.io.load(filename))
else: else:
return None raise ValueError("No information given to load file")
class Result(dict): class Result(dict):
......
...@@ -200,7 +200,12 @@ class Sampler(object): ...@@ -200,7 +200,12 @@ class Sampler(object):
logging.debug("Command line argument clean given, forcing rerun") logging.debug("Command line argument clean given, forcing rerun")
self.cached_result = None self.cached_result = None
return return
self.cached_result = read_in_result(self.outdir, self.label)
try:
self.cached_result = read_in_result(self.outdir, self.label)
except ValueError:
self.cached_result = None
if utils.command_line_args.use_cached: if utils.command_line_args.use_cached:
logging.debug("Command line argument cached given, no cache check performed") logging.debug("Command line argument cached given, no cache check performed")
return return
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment