Skip to content

Commit

Permalink
Fixed the infinite recursion when deserializing an attribute. (#22)
Browse files Browse the repository at this point in the history
* Fixed the infinite recursion when deserializing an attribute.

* Bumping version to 0.1.11.
  • Loading branch information
fernandocamargoai committed Sep 9, 2020
1 parent fa8fb4e commit d09bda4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion setup.py
Expand Up @@ -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',
Expand Down
17 changes: 9 additions & 8 deletions stripping/executor.py
Expand Up @@ -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.")
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit d09bda4

Please sign in to comment.