diff --git a/setup.py b/setup.py index 84f1d4c..3bb521f 100644 --- a/setup.py +++ b/setup.py @@ -27,7 +27,7 @@ setup( name='stripping', - version='0.1.10', + version='0.1.11', description='An easy to use pipeline solution for AI/ML experiments', author='Adriano Marques, Nathan Martins, Thales Ribeiro', author_email='adriano@xnv.io, nathan@xnv.io, thales@xnv.io', diff --git a/stripping/executor.py b/stripping/executor.py index abebd39..776f3c3 100755 --- a/stripping/executor.py +++ b/stripping/executor.py @@ -69,12 +69,12 @@ def __getattr__(self, attr_name): with self.catalysis_client.open(attr_file_name) as f: if f.exists(): - self._deserialize(attr_file_name) + setattr(self, attr_name, self._deserialize(attr_file_name)) return getattr(self, attr_name) else: if os.path.exists(attr_file_name): - self._deserialize(attr_file_name) + setattr(self, attr_name, self._deserialize(attr_file_name)) return getattr(self, attr_name) logging.warning(f"Attribute '{attr_name}' was not found.") @@ -132,26 +132,27 @@ def _deserialize(self, attr_file_name): with self.catalysis_client.open(attr_file_name, 'rb') as attr_file: try: logging.debug(f"Attempting to deserialize '{attr_file_name}' with pickle...") - setattr(self, attr_file_name, pickle.load(attr_file)) + value = pickle.load(attr_file) logging.debug( f"Successfully deserialized '{attr_file_name}' as a python object of " - f"type '{type(getattr(self, attr_file_name))}'") + f"type '{type(value)}'") except Exception: logging.debug(f"Attempting to deserialize '{attr_file_name}' with numpy...") - setattr(self, attr_file_name, np.load(attr_file)) + value = np.load(attr_file) logging.debug(f"Successfully deserialized '{attr_file_name}' as a numpy array.") else: with open(attr_file_name, 'rb') as attr_file: try: logging.debug(f"Attempting to deserialize '{attr_file_name}' with pickle...") - setattr(self, attr_file_name, pickle.load(attr_file)) + value = pickle.load(attr_file) logging.debug( f"Successfully deserialized '{attr_file_name}' as a python object of " - f"type '{type(getattr(self, attr_file_name))}'") + f"type '{type(value)}'") except Exception: logging.debug(f"Attempting to deserialize '{attr_file_name}' with numpy...") - setattr(self, attr_file_name, np.load(attr_file)) + value = np.load(attr_file) logging.debug(f"Successfully deserialized '{attr_file_name}' as a numpy array.") + return value @SingletonDecorator