Skip to content
Snippets Groups Projects
Commit 82db951c authored by plasky's avatar plasky
Browse files

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

parents 96129f0d ac14b8db
No related branches found
No related tags found
No related merge requests found
Pipeline #
......@@ -17,13 +17,26 @@ def result_file_name(outdir, label):
return '{}/{}_result.h5'.format(outdir, label)
def read_in_result(outdir, label):
""" Read in a saved .h5 data file """
filename = result_file_name(outdir, label)
def read_in_result(outdir=None, label=None, filename=None):
""" Read in a saved .h5 data file
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):
return Result(deepdish.io.load(filename))
else:
return None
raise ValueError("No information given to load file")
class Result(dict):
......
......@@ -200,7 +200,12 @@ class Sampler(object):
logging.debug("Command line argument clean given, forcing rerun")
self.cached_result = None
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:
logging.debug("Command line argument cached given, no cache check performed")
return
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment