def __init__(self, filedir, guid, **kwargs): MetadataManager.__init__(self, **kwargs) self._ignore.update(['guid', 'file_path', 'root_dir']) self.guid = guid self.param_groups = set() self.root_dir = os.path.join(filedir,guid) fname = ''.join([guid, '_master.hdf5']) self.file_path = os.path.join(self.root_dir, fname) self.brick_tree = RTreeProxy() if self.is_persisted_in_db(guid): self._load() elif self.isPersisted(filedir, guid): mm = MasterManager(filedir, guid, **kwargs) for key, value in mm.__dict__.iteritems(): if not key == "_dirty": self.__setattr__(key, value) self.flush(deep=False) # This is odd - You can load an object and override stored values on construction. # This might lead to unexpected behavior for users. for k, v in kwargs.iteritems(): if hasattr(self, k) and v is None: continue setattr(self, k, v) if (hasattr(self, 'parameter_bounds') and self.parameter_bounds is None) or not hasattr(self, 'parameter_bounds'): self.parameter_bounds = {}
def __init__(self, root_dir, file_name, **kwargs): MetadataManager.__init__(self, **kwargs) self.root_dir = root_dir self.file_path = os.path.join(root_dir, file_name) if not os.path.exists(self.root_dir): os.makedirs(self.root_dir) if os.path.exists(self.file_path): self._load() for k, v in kwargs.iteritems(): # Don't overwrite with None if hasattr(self, k) and v is None: continue setattr(self, k, v)
def __init__(self, filedir, guid, **kwargs): MetadataManager.__init__(self, **kwargs) self.guid = guid self._ignore.update(['guid', 'file_path', 'root_dir', 'type']) self.param_groups = set() self.root_dir = os.path.join(filedir,guid) self.file_path = os.path.join(filedir, guid) self.brick_tree = RTreeProxy() self.type = '' self._load() # This is odd - You can load an object and override stored values on construction. # This might lead to unexpected behavior for users. for k, v in kwargs.iteritems(): if hasattr(self, k) and v is None: continue setattr(self, k, v) if (hasattr(self, 'parameter_bounds') and self.parameter_bounds is None) or not hasattr(self, 'parameter_bounds'): self.parameter_bounds = {}