From 6b7076ac458bc9dfdbe751f71d8742dd0bcc01f0 Mon Sep 17 00:00:00 2001 From: Marwan Zouinkhi Date: Tue, 2 Apr 2024 12:27:35 -0400 Subject: [PATCH] support old dacapo data --- dacapo/experiments/starts/start.py | 9 +++++++-- dacapo/store/converter.py | 13 +++++++++---- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/dacapo/experiments/starts/start.py b/dacapo/experiments/starts/start.py index 8b667b56b..a673b7e56 100644 --- a/dacapo/experiments/starts/start.py +++ b/dacapo/experiments/starts/start.py @@ -99,8 +99,13 @@ def __init__(self, start_config): An object containing configuration details for the model initialization. """ - self.run = start_config.run - self.criterion = start_config.criterion + # Old version return a dict, new version return an object, this line is to support both + if isinstance(start_config, dict): + self.run = start_config["run"] + self.criterion = start_config["criterion"] + else: + self.run = start_config.run + self.criterion = start_config.criterion self.channels = None diff --git a/dacapo/store/converter.py b/dacapo/store/converter.py index bffa526db..62bb2f4df 100644 --- a/dacapo/store/converter.py +++ b/dacapo/store/converter.py @@ -117,10 +117,15 @@ def __typed_structure(self, obj_data, cls, cls_fn): to determine the class. This is useful for reconstructing a concrete class from unstructured data. """ - - cls = cls_fn(obj_data["__type__"]) - structure_fn = make_dict_structure_fn(cls, self) - return structure_fn(obj_data, cls) + try: + cls = cls_fn(obj_data["__type__"]) + structure_fn = make_dict_structure_fn(cls, self) + return structure_fn(obj_data, cls) + except: + print( + f"Could not structure object of type {obj_data}. will try unstructured data. attr __type__ can be missing because of old version of the data." + ) + return obj_data # The global converter object, to be used by stores to convert objects into