Skip to content

Commit

Permalink
[fix] Add ability to decode/encode Objects when source code is missing (
Browse files Browse the repository at this point in the history
#2953)

[fix] Add ability to decode/encode Objects when source code is not available
  • Loading branch information
alberttorosyan authored Aug 24, 2023
1 parent 0352ce3 commit 590a03b
Showing 1 changed file with 12 additions and 2 deletions.
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[...]

0 comments on commit 590a03b

Please sign in to comment.