From 6a498f6e3542546212104c4d3a6f22e4e7f6dc70 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Tue, 9 Dec 2025 17:14:54 +0100 Subject: [PATCH 1/4] change how EntityData work --- ayon_api/entity_hub.py | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/ayon_api/entity_hub.py b/ayon_api/entity_hub.py index c77b9bf68..86c002e43 100644 --- a/ayon_api/entity_hub.py +++ b/ayon_api/entity_hub.py @@ -1418,7 +1418,10 @@ class EntityData(dict): """ def __init__(self, *args, **kwargs) -> None: super().__init__(*args, **kwargs) - self._orig_data = copy.deepcopy(self) + self._orig_data = { + key: copy.deepcopy(value) + for key, value in self.items() + } def get_changes(self) -> dict[str, Any]: """Changes in entity data. @@ -1437,10 +1440,10 @@ def get_changes(self) -> dict[str, Any]: output[key] = None elif key not in self._orig_data: # New value was set - output[key] = self[key] + output[key] = copy.deepcopy(self[key]) elif self[key] != self._orig_data[key]: # Value was changed - output[key] = self[key] + output[key] = copy.deepcopy(self[key]) return output def get_new_entity_value(self) -> dict[str, AttributeValueType]: @@ -1460,7 +1463,21 @@ def get_new_entity_value(self) -> dict[str, AttributeValueType]: def lock(self) -> None: """Lock changes of entity data.""" - self._orig_data = copy.deepcopy(self) + orig_data = {} + for key, value in self.items(): + try: + key = copy.deepcopy(key) + except RecursionError: + print(f"Failed to create copy of key '{key}'!!!") + raise + + try: + orig_data[key] = copy.deepcopy(value) + except RecursionError: + print(f"Failed to create copy of value '{key}'!!!") + raise + + self._orig_data = orig_data class BaseEntity(ABC): From 365cdd4a06aa574c82209f32a40f2599b345edd2 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Tue, 9 Dec 2025 17:18:46 +0100 Subject: [PATCH 2/4] raise new errors to actually see the message --- ayon_api/entity_hub.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/ayon_api/entity_hub.py b/ayon_api/entity_hub.py index 86c002e43..9ddf7912d 100644 --- a/ayon_api/entity_hub.py +++ b/ayon_api/entity_hub.py @@ -1468,14 +1468,18 @@ def lock(self) -> None: try: key = copy.deepcopy(key) except RecursionError: - print(f"Failed to create copy of key '{key}'!!!") - raise + raise RuntimeError( + f"Failed to create copy of key '{key}'" + " because of recursion!!!" + ) try: orig_data[key] = copy.deepcopy(value) except RecursionError: - print(f"Failed to create copy of value '{key}'!!!") - raise + raise RuntimeError( + f"Failed to create copy of value '{key}'" + " because of recursion!!!" + ) self._orig_data = orig_data From 17ef3f8692b902378a1ac59bd5ad10cd5af894b5 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Tue, 9 Dec 2025 17:18:51 +0100 Subject: [PATCH 3/4] use lock on init --- ayon_api/entity_hub.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/ayon_api/entity_hub.py b/ayon_api/entity_hub.py index 9ddf7912d..7a8041db7 100644 --- a/ayon_api/entity_hub.py +++ b/ayon_api/entity_hub.py @@ -1418,10 +1418,9 @@ class EntityData(dict): """ def __init__(self, *args, **kwargs) -> None: super().__init__(*args, **kwargs) - self._orig_data = { - key: copy.deepcopy(value) - for key, value in self.items() - } + self._orig_data = {} + # Fill orig data + self.lock() def get_changes(self) -> dict[str, Any]: """Changes in entity data. From a4134a0224ab0bf43be79d59987dec26ac8c1f33 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Tue, 9 Dec 2025 17:25:21 +0100 Subject: [PATCH 4/4] softer message Co-authored-by: Roy Nieterau --- ayon_api/entity_hub.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ayon_api/entity_hub.py b/ayon_api/entity_hub.py index 7a8041db7..2707bd7f7 100644 --- a/ayon_api/entity_hub.py +++ b/ayon_api/entity_hub.py @@ -1469,7 +1469,7 @@ def lock(self) -> None: except RecursionError: raise RuntimeError( f"Failed to create copy of key '{key}'" - " because of recursion!!!" + " because of recursion." ) try: @@ -1477,7 +1477,7 @@ def lock(self) -> None: except RecursionError: raise RuntimeError( f"Failed to create copy of value '{key}'" - " because of recursion!!!" + " because of recursion." ) self._orig_data = orig_data