Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed the infinite recursion when deserializing an attribute. #22

Merged
merged 2 commits into from
Sep 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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