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

[fix] Add ability to decode/encode Objects when source code is missing #2953

Merged
Merged
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
14 changes: 12 additions & 2 deletions src/python/aim/_core/storage/object.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ def decorator(cls):

@staticmethod
def by_name(name: str):
return CustomObject.registry[name]
try:
return CustomObject.registry[name]
except KeyError:
return CustomObjectProxy

@classmethod
def get_typename(cls) -> str:
Expand Down Expand Up @@ -52,4 +55,11 @@ def _aim_encode(self):
@classmethod
def _aim_decode(cls, aim_name, storage):
custom_cls = cls.by_name(aim_name)
return cls.__new__(custom_cls, _storage=storage)
obj = cls.__new__(custom_cls, _storage=storage)
setattr(obj, '_cls_name', aim_name)
return obj


class CustomObjectProxy(CustomObject):
def _aim_encode(self):
return self._cls_name, self.storage[...]
Loading