Skip to content
Snippets Groups Projects
Commit 27b2081e authored by Nikolai's avatar Nikolai
Browse files

option to initialise from project directory (without specifying options again)

parent 43f12959
No related branches found
No related tags found
No related merge requests found
......@@ -50,9 +50,20 @@ class KerasROOTClassification(object):
dataset_names_tree = ["x_train", "x_test", "y_train", "y_test", "w_train", "w_test"]
def __init__(self, name, *args, **kwargs):
self._init_from_args(name, *args, **kwargs)
with open(os.path.join(self.project_dir, "options.json"), "w") as of:
json.dump(dict(args=args, kwargs=kwargs), of)
if len(args) < 1 and len(kwargs) < 1:
# if no further arguments given, interpret as directory name
self._init_from_dir(name)
else:
# otherwise initialise new project
self._init_from_args(name, *args, **kwargs)
with open(os.path.join(self.project_dir, "options.json"), "w") as of:
json.dump(dict(args=args, kwargs=kwargs), of)
def _init_from_dir(self, dirname):
with open(os.path.join(dirname, "options.json")) as f:
options = json.load(f)
self._init_from_args(os.path.basename(dirname), *options["args"], **options["kwargs"])
def _init_from_args(self, name,
......
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