From be20a9f69626240bbb941e7661d5866a97b736cc Mon Sep 17 00:00:00 2001 From: Roy Nieterau Date: Fri, 29 Nov 2024 10:14:47 +0100 Subject: [PATCH 01/52] Add ShapeFX Loki support --- client/ayon_core/hooks/pre_add_last_workfile_arg.py | 3 ++- client/ayon_core/hooks/pre_ocio_hook.py | 3 ++- client/ayon_core/plugins/publish/validate_file_saved.py | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/client/ayon_core/hooks/pre_add_last_workfile_arg.py b/client/ayon_core/hooks/pre_add_last_workfile_arg.py index d5914c2352..0652e7c5aa 100644 --- a/client/ayon_core/hooks/pre_add_last_workfile_arg.py +++ b/client/ayon_core/hooks/pre_add_last_workfile_arg.py @@ -29,7 +29,8 @@ class AddLastWorkfileToLaunchArgs(PreLaunchHook): "aftereffects", "wrap", "openrv", - "cinema4d" + "cinema4d", + "loki" } launch_types = {LaunchTypes.local} diff --git a/client/ayon_core/hooks/pre_ocio_hook.py b/client/ayon_core/hooks/pre_ocio_hook.py index 7406aa42cf..6462d1a3ae 100644 --- a/client/ayon_core/hooks/pre_ocio_hook.py +++ b/client/ayon_core/hooks/pre_ocio_hook.py @@ -20,7 +20,8 @@ class OCIOEnvHook(PreLaunchHook): "hiero", "resolve", "openrv", - "cinema4d" + "cinema4d", + "loki" } launch_types = set() diff --git a/client/ayon_core/plugins/publish/validate_file_saved.py b/client/ayon_core/plugins/publish/validate_file_saved.py index f52998cef3..78c243d5aa 100644 --- a/client/ayon_core/plugins/publish/validate_file_saved.py +++ b/client/ayon_core/plugins/publish/validate_file_saved.py @@ -37,7 +37,7 @@ class ValidateCurrentSaveFile(pyblish.api.ContextPlugin): label = "Validate File Saved" order = pyblish.api.ValidatorOrder - 0.1 hosts = ["fusion", "houdini", "max", "maya", "nuke", "substancepainter", - "cinema4d"] + "cinema4d", "loki"] actions = [SaveByVersionUpAction, ShowWorkfilesAction] def process(self, context): From 293e5fe2e9d759e970d17781cde9c24c1b585c6f Mon Sep 17 00:00:00 2001 From: Roy Nieterau Date: Wed, 23 Jul 2025 01:14:11 +0200 Subject: [PATCH 02/52] Use `save_next_version` from Workfiles API https://github.com/ynput/ayon-core/pull/1275 in `version_up_current_workfile` --- client/ayon_core/pipeline/context_tools.py | 53 ++-------------------- 1 file changed, 3 insertions(+), 50 deletions(-) diff --git a/client/ayon_core/pipeline/context_tools.py b/client/ayon_core/pipeline/context_tools.py index cccdafe6f1..308dd1bf44 100644 --- a/client/ayon_core/pipeline/context_tools.py +++ b/client/ayon_core/pipeline/context_tools.py @@ -580,53 +580,6 @@ def get_process_id(): def version_up_current_workfile(): - """Function to increment and save workfile - """ - host = registered_host() - - project_name = get_current_project_name() - folder_path = get_current_folder_path() - task_name = get_current_task_name() - host_name = get_current_host_name() - - template_key = get_workfile_template_key_from_context( - project_name, - folder_path, - task_name, - host_name, - ) - anatomy = Anatomy(project_name) - - data = get_template_data_with_names( - project_name, folder_path, task_name, host_name - ) - data["root"] = anatomy.roots - - work_template = anatomy.get_template_item("work", template_key) - - # Define saving file extension - extensions = host.get_workfile_extensions() - current_file = host.get_current_workfile() - if current_file: - extensions = [os.path.splitext(current_file)[-1]] - - work_root = work_template["directory"].format_strict(data) - file_template = work_template["file"].template - last_workfile_path = get_last_workfile( - work_root, file_template, data, extensions, True - ) - # `get_last_workfile` will return the first expected file version - # if no files exist yet. In that case, if they do not exist we will - # want to save v001 - new_workfile_path = last_workfile_path - if os.path.exists(new_workfile_path): - new_workfile_path = version_up(new_workfile_path) - - # Raise an error if the parent folder doesn't exist as `host.save_workfile` - # is not supposed/able to create missing folders. - parent_folder = os.path.dirname(new_workfile_path) - if not os.path.exists(parent_folder): - raise MissingWorkdirError( - f"Work area directory '{parent_folder}' does not exist.") - - host.save_workfile(new_workfile_path) + """Function to increment and save workfile""" + from ayon_core.pipeline.workfile.utils import save_next_version + save_next_version() From 94b96345552beaccf6a16530d7a8b89f9035235d Mon Sep 17 00:00:00 2001 From: Roy Nieterau Date: Wed, 23 Jul 2025 11:25:55 +0200 Subject: [PATCH 03/52] Fix logged warnings --- .../plugins/publish/collect_scene_loaded_versions.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/client/ayon_core/plugins/publish/collect_scene_loaded_versions.py b/client/ayon_core/plugins/publish/collect_scene_loaded_versions.py index 1abb8e29d2..c8d9747091 100644 --- a/client/ayon_core/plugins/publish/collect_scene_loaded_versions.py +++ b/client/ayon_core/plugins/publish/collect_scene_loaded_versions.py @@ -27,12 +27,13 @@ class CollectSceneLoadedVersions(pyblish.api.ContextPlugin): def process(self, context): host = registered_host() if host is None: - self.log.warn("No registered host.") + self.log.warning("No registered host.") return if not hasattr(host, "ls"): host_name = host.__name__ - self.log.warn("Host %r doesn't have ls() implemented." % host_name) + self.log.warning( + f"Host {host_name} doesn't have ls() implemented.") return loaded_versions = [] From f0ea841ebf339a14940792d268e46918c2c60a3c Mon Sep 17 00:00:00 2001 From: Roy Nieterau Date: Wed, 23 Jul 2025 11:29:23 +0200 Subject: [PATCH 04/52] Use `ILoadHost.get_containers()` when available --- .../publish/collect_scene_loaded_versions.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/client/ayon_core/plugins/publish/collect_scene_loaded_versions.py b/client/ayon_core/plugins/publish/collect_scene_loaded_versions.py index c8d9747091..34d3e5b136 100644 --- a/client/ayon_core/plugins/publish/collect_scene_loaded_versions.py +++ b/client/ayon_core/plugins/publish/collect_scene_loaded_versions.py @@ -1,7 +1,9 @@ import ayon_api import ayon_api.utils +from ayon_core.host import ILoadHost from ayon_core.pipeline import registered_host + import pyblish.api @@ -30,14 +32,19 @@ class CollectSceneLoadedVersions(pyblish.api.ContextPlugin): self.log.warning("No registered host.") return - if not hasattr(host, "ls"): + if isinstance(host, ILoadHost): + containers = list(host.get_containers()) + elif hasattr(host, "ls"): + # Backwards compatibility for legacy host implementations + containers = list(host.ls()) + else: host_name = host.__name__ self.log.warning( - f"Host {host_name} doesn't have ls() implemented.") + f"Host {host_name} does not implement ILoadHost " + f"nor does it have ls() implemented. Skipping querying of " + f"loaded versions in scene.") return - loaded_versions = [] - containers = list(host.ls()) repre_ids = { container["representation"] for container in containers @@ -62,6 +69,7 @@ class CollectSceneLoadedVersions(pyblish.api.ContextPlugin): # QUESTION should we add same representation id when loaded multiple # times? + loaded_versions = [] for con in containers: repre_id = con["representation"] repre_entity = repre_entities_by_id.get(repre_id) From 5a44efd2ad60cbd380c706217f896106958afb1c Mon Sep 17 00:00:00 2001 From: Roy Nieterau Date: Wed, 23 Jul 2025 11:31:29 +0200 Subject: [PATCH 05/52] Opt-out early if there are no containers in the scene file --- .../plugins/publish/collect_scene_loaded_versions.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/client/ayon_core/plugins/publish/collect_scene_loaded_versions.py b/client/ayon_core/plugins/publish/collect_scene_loaded_versions.py index 34d3e5b136..e3e938b65b 100644 --- a/client/ayon_core/plugins/publish/collect_scene_loaded_versions.py +++ b/client/ayon_core/plugins/publish/collect_scene_loaded_versions.py @@ -45,6 +45,11 @@ class CollectSceneLoadedVersions(pyblish.api.ContextPlugin): f"loaded versions in scene.") return + if not containers: + # Opt out early if there are no containers + self.log.debug("No loaded containers found in scene.") + return + repre_ids = { container["representation"] for container in containers From 8b8cff8ea5036e7a49e3b61e036f7beec35642fb Mon Sep 17 00:00:00 2001 From: Roy Nieterau Date: Wed, 23 Jul 2025 11:32:48 +0200 Subject: [PATCH 06/52] Add debug log --- .../ayon_core/plugins/publish/collect_scene_loaded_versions.py | 1 + 1 file changed, 1 insertion(+) diff --git a/client/ayon_core/plugins/publish/collect_scene_loaded_versions.py b/client/ayon_core/plugins/publish/collect_scene_loaded_versions.py index e3e938b65b..ea949eb087 100644 --- a/client/ayon_core/plugins/publish/collect_scene_loaded_versions.py +++ b/client/ayon_core/plugins/publish/collect_scene_loaded_versions.py @@ -94,4 +94,5 @@ class CollectSceneLoadedVersions(pyblish.api.ContextPlugin): } loaded_versions.append(version) + self.log.debug(f"Collected {len(loaded_versions)} loaded versions.") context.data["loadedVersions"] = loaded_versions From ecd3538dfd481d7fe3c4a4388d3affe7f7d4b615 Mon Sep 17 00:00:00 2001 From: Roy Nieterau Date: Wed, 23 Jul 2025 11:46:52 +0200 Subject: [PATCH 07/52] Update client/ayon_core/plugins/publish/collect_scene_loaded_versions.py Co-authored-by: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> --- .../ayon_core/plugins/publish/collect_scene_loaded_versions.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/client/ayon_core/plugins/publish/collect_scene_loaded_versions.py b/client/ayon_core/plugins/publish/collect_scene_loaded_versions.py index ea949eb087..9574c8c211 100644 --- a/client/ayon_core/plugins/publish/collect_scene_loaded_versions.py +++ b/client/ayon_core/plugins/publish/collect_scene_loaded_versions.py @@ -34,9 +34,6 @@ class CollectSceneLoadedVersions(pyblish.api.ContextPlugin): if isinstance(host, ILoadHost): containers = list(host.get_containers()) - elif hasattr(host, "ls"): - # Backwards compatibility for legacy host implementations - containers = list(host.ls()) else: host_name = host.__name__ self.log.warning( From 654833054901c0e53b9e2683328fad46610446cb Mon Sep 17 00:00:00 2001 From: Roy Nieterau Date: Wed, 23 Jul 2025 11:47:38 +0200 Subject: [PATCH 08/52] Reformat code --- .../plugins/publish/collect_scene_loaded_versions.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/client/ayon_core/plugins/publish/collect_scene_loaded_versions.py b/client/ayon_core/plugins/publish/collect_scene_loaded_versions.py index 9574c8c211..ee448e7911 100644 --- a/client/ayon_core/plugins/publish/collect_scene_loaded_versions.py +++ b/client/ayon_core/plugins/publish/collect_scene_loaded_versions.py @@ -32,16 +32,15 @@ class CollectSceneLoadedVersions(pyblish.api.ContextPlugin): self.log.warning("No registered host.") return - if isinstance(host, ILoadHost): - containers = list(host.get_containers()) - else: + if not isinstance(host, ILoadHost): host_name = host.__name__ self.log.warning( - f"Host {host_name} does not implement ILoadHost " - f"nor does it have ls() implemented. Skipping querying of " - f"loaded versions in scene.") + f"Host {host_name} does not implement ILoadHost. " + "Skipping querying of loaded versions in scene." + ) return + containers = list(host.get_containers()) if not containers: # Opt out early if there are no containers self.log.debug("No loaded containers found in scene.") From 3941040d23e14aebfaa7b8c1d561ea011d8b34eb Mon Sep 17 00:00:00 2001 From: Roy Nieterau Date: Wed, 23 Jul 2025 12:22:28 +0200 Subject: [PATCH 09/52] Update client/ayon_core/plugins/publish/collect_scene_loaded_versions.py Co-authored-by: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> --- .../ayon_core/plugins/publish/collect_scene_loaded_versions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/ayon_core/plugins/publish/collect_scene_loaded_versions.py b/client/ayon_core/plugins/publish/collect_scene_loaded_versions.py index ee448e7911..524381f656 100644 --- a/client/ayon_core/plugins/publish/collect_scene_loaded_versions.py +++ b/client/ayon_core/plugins/publish/collect_scene_loaded_versions.py @@ -33,7 +33,7 @@ class CollectSceneLoadedVersions(pyblish.api.ContextPlugin): return if not isinstance(host, ILoadHost): - host_name = host.__name__ + host_name = host.name self.log.warning( f"Host {host_name} does not implement ILoadHost. " "Skipping querying of loaded versions in scene." From 50e6c541f982a52ede822f70eb72074888f038c6 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Thu, 24 Jul 2025 10:59:34 +0200 Subject: [PATCH 10/52] reuse comment from last workfile --- client/ayon_core/pipeline/workfile/utils.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/client/ayon_core/pipeline/workfile/utils.py b/client/ayon_core/pipeline/workfile/utils.py index d5c717bd6d..36e72bb55a 100644 --- a/client/ayon_core/pipeline/workfile/utils.py +++ b/client/ayon_core/pipeline/workfile/utils.py @@ -417,7 +417,9 @@ def save_next_version( Args: version (Optional[int]): Workfile version that will be used. Last version + 1 is used if is not passed in. - comment (optional[str]): Workfile comment. + comment (optional[str]): Workfile comment. Pass '""' to clear comment. + The last workfile comment is used if it is not passed in and + passed 'version' is 'None'. description (Optional[str]): Workfile description. prepared_data (Optional[SaveWorkfileOptionalData]): Prepared data for speed enhancements. @@ -513,6 +515,9 @@ def save_next_version( product_type="workfile" ) + if comment is None and last_workfile is not None: + comment = last_workfile.comment + template_data["version"] = version template_data["comment"] = comment From eea1f4cb6a9057a1cf5c4a00e5ba26ecd07985d8 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Thu, 24 Jul 2025 11:05:41 +0200 Subject: [PATCH 11/52] re-use comment from current file --- client/ayon_core/pipeline/workfile/utils.py | 24 +++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/client/ayon_core/pipeline/workfile/utils.py b/client/ayon_core/pipeline/workfile/utils.py index 36e72bb55a..a6e4dad2b4 100644 --- a/client/ayon_core/pipeline/workfile/utils.py +++ b/client/ayon_core/pipeline/workfile/utils.py @@ -429,6 +429,11 @@ def save_next_version( from ayon_core.pipeline.context_tools import registered_host host = registered_host() + current_path = host.get_current_workfile() + if not current_path: + current_path = None + else: + current_path = os.path.normpath(current_path) context = host.get_current_context() project_name = context["project_name"] @@ -483,6 +488,7 @@ def save_next_version( ) rootless_dir = workdir.rootless last_workfile = None + current_workfile = None if version is None: workfiles = host.list_workfiles( project_name, folder_entity, task_entity, @@ -496,6 +502,10 @@ def save_next_version( for workfile in workfiles: if workfile.version is None: continue + + if current_workfile is None and workfile.filepath == current_path: + current_workfile = workfile + if ( last_workfile is None or last_workfile.version < workfile.version @@ -515,11 +525,18 @@ def save_next_version( product_type="workfile" ) - if comment is None and last_workfile is not None: - comment = last_workfile.comment + # Re-use comment if is not set + if comment is None: + if current_workfile is not None: + # Use 'comment' from the current workfile if is set + comment = current_workfile.comment + elif last_workfile is not None: + # Use 'comment' from the last workfile + comment = last_workfile.comment template_data["version"] = version - template_data["comment"] = comment + if comment: + template_data["comment"] = comment # Resolve extension # - Don't fill any if the host does not have defined any -> e.g. if host @@ -530,7 +547,6 @@ def save_next_version( ext = None workfile_extensions = host.get_workfile_extensions() if workfile_extensions: - current_path = host.get_current_workfile() if current_path: ext = os.path.splitext(current_path)[1].lstrip(".") elif last_workfile is not None: From 4b5431f26718169a93cda20706b37f343f441e8b Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Thu, 24 Jul 2025 11:07:09 +0200 Subject: [PATCH 12/52] added helper functions to workfile __init__.py --- client/ayon_core/pipeline/workfile/__init__.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/client/ayon_core/pipeline/workfile/__init__.py b/client/ayon_core/pipeline/workfile/__init__.py index c6a0e0d80b..7acaf69a7c 100644 --- a/client/ayon_core/pipeline/workfile/__init__.py +++ b/client/ayon_core/pipeline/workfile/__init__.py @@ -22,9 +22,11 @@ from .utils import ( should_open_workfiles_tool_on_launch, MissingWorkdirError, + save_workfile_info, save_current_workfile_to, save_workfile_with_current_context, - save_workfile_info, + save_next_version, + copy_workfile_to_context, find_workfile_rootless_path, ) @@ -63,9 +65,11 @@ __all__ = ( "should_open_workfiles_tool_on_launch", "MissingWorkdirError", + "save_workfile_info", "save_current_workfile_to", "save_workfile_with_current_context", - "save_workfile_info", + "save_next_version", + "copy_workfile_to_context", "BuildWorkfile", From 15854f07060838d9e3c5008feeb4551d5da898c5 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Thu, 24 Jul 2025 11:49:00 +0200 Subject: [PATCH 13/52] revert some of the logic --- client/ayon_core/pipeline/workfile/utils.py | 43 +++++++++------------ 1 file changed, 18 insertions(+), 25 deletions(-) diff --git a/client/ayon_core/pipeline/workfile/utils.py b/client/ayon_core/pipeline/workfile/utils.py index a6e4dad2b4..3812fb6471 100644 --- a/client/ayon_core/pipeline/workfile/utils.py +++ b/client/ayon_core/pipeline/workfile/utils.py @@ -418,8 +418,7 @@ def save_next_version( version (Optional[int]): Workfile version that will be used. Last version + 1 is used if is not passed in. comment (optional[str]): Workfile comment. Pass '""' to clear comment. - The last workfile comment is used if it is not passed in and - passed 'version' is 'None'. + The current workfile comment is used if it is not passed. description (Optional[str]): Workfile description. prepared_data (Optional[SaveWorkfileOptionalData]): Prepared data for speed enhancements. @@ -489,7 +488,7 @@ def save_next_version( rootless_dir = workdir.rootless last_workfile = None current_workfile = None - if version is None: + if version is None or comment is None: workfiles = host.list_workfiles( project_name, folder_entity, task_entity, prepared_data=ListWorkfilesOptionalData( @@ -500,39 +499,33 @@ def save_next_version( ) ) for workfile in workfiles: - if workfile.version is None: - continue - if current_workfile is None and workfile.filepath == current_path: current_workfile = workfile + if workfile.version is None: + continue + if ( last_workfile is None or last_workfile.version < workfile.version ): last_workfile = workfile - version = None - if last_workfile is not None: - version = last_workfile.version + 1 + if version is None and last_workfile is not None: + version = last_workfile.version + 1 - if version is None: - version = get_versioning_start( - project_name, - host.name, - task_name=task_entity["name"], - task_type=task_entity["taskType"], - product_type="workfile" - ) + if version is None: + version = get_versioning_start( + project_name, + host.name, + task_name=task_entity["name"], + task_type=task_entity["taskType"], + product_type="workfile" + ) - # Re-use comment if is not set - if comment is None: - if current_workfile is not None: - # Use 'comment' from the current workfile if is set - comment = current_workfile.comment - elif last_workfile is not None: - # Use 'comment' from the last workfile - comment = last_workfile.comment + # Re-use comment from the current workfile if is not passed in + if comment is None and current_workfile is not None: + comment = current_workfile.comment template_data["version"] = version if comment: From 583dae949dabe0abd75fb1bb311dbe6547a1730d Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Thu, 24 Jul 2025 11:57:25 +0200 Subject: [PATCH 14/52] strip dot of extension --- client/ayon_core/pipeline/workfile/utils.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/client/ayon_core/pipeline/workfile/utils.py b/client/ayon_core/pipeline/workfile/utils.py index 3812fb6471..354449bd3e 100644 --- a/client/ayon_core/pipeline/workfile/utils.py +++ b/client/ayon_core/pipeline/workfile/utils.py @@ -541,11 +541,12 @@ def save_next_version( workfile_extensions = host.get_workfile_extensions() if workfile_extensions: if current_path: - ext = os.path.splitext(current_path)[1].lstrip(".") + ext = os.path.splitext(current_path)[1] elif last_workfile is not None: - ext = os.path.splitext(last_workfile.filepath)[1].lstrip(".") + ext = os.path.splitext(last_workfile.filepath)[1] else: ext = next(iter(workfile_extensions), None) + ext = ext.lstrip(".") if ext: template_data["ext"] = ext From 4204de3ab2482903f1c84b597e29487dfbadf6a4 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Thu, 24 Jul 2025 12:34:53 +0200 Subject: [PATCH 15/52] pass variant to actions list --- client/ayon_core/tools/launcher/models/actions.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/client/ayon_core/tools/launcher/models/actions.py b/client/ayon_core/tools/launcher/models/actions.py index adb8d371ed..1a8e423751 100644 --- a/client/ayon_core/tools/launcher/models/actions.py +++ b/client/ayon_core/tools/launcher/models/actions.py @@ -399,7 +399,11 @@ class ActionsModel: return cache.get_data() try: - response = ayon_api.post("actions/list", **request_data) + # 'variant' query is supported since AYON backend 1.10.4 + query = urlencode({"variant": self._variant}) + response = ayon_api.post( + f"actions/list?{query}", **request_data + ) response.raise_for_status() except Exception: self.log.warning("Failed to collect webactions.", exc_info=True) From a4ec6c4a774008dd66af401957f05d1e55569e8c Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Thu, 24 Jul 2025 12:40:59 +0200 Subject: [PATCH 16/52] Remove redundant default value Co-authored-by: Roy Nieterau --- client/ayon_core/pipeline/workfile/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/ayon_core/pipeline/workfile/utils.py b/client/ayon_core/pipeline/workfile/utils.py index 354449bd3e..6666853998 100644 --- a/client/ayon_core/pipeline/workfile/utils.py +++ b/client/ayon_core/pipeline/workfile/utils.py @@ -545,7 +545,7 @@ def save_next_version( elif last_workfile is not None: ext = os.path.splitext(last_workfile.filepath)[1] else: - ext = next(iter(workfile_extensions), None) + ext = next(iter(workfile_extensions)) ext = ext.lstrip(".") if ext: From 351167a8d62fc59ddd693b9ab45ecad65eecc177 Mon Sep 17 00:00:00 2001 From: Roy Nieterau Date: Thu, 24 Jul 2025 13:33:35 +0200 Subject: [PATCH 17/52] Remove unused imports --- client/ayon_core/pipeline/context_tools.py | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/client/ayon_core/pipeline/context_tools.py b/client/ayon_core/pipeline/context_tools.py index 308dd1bf44..b06d34b26f 100644 --- a/client/ayon_core/pipeline/context_tools.py +++ b/client/ayon_core/pipeline/context_tools.py @@ -16,7 +16,6 @@ from ayon_core.host import HostBase from ayon_core.lib import ( is_in_tests, initialize_ayon_connection, - version_up ) from ayon_core.addon import load_addons, AddonsManager from ayon_core.settings import get_project_settings @@ -24,12 +23,7 @@ from ayon_core.settings import get_project_settings from .publish.lib import filter_pyblish_plugins from .anatomy import Anatomy from .template_data import get_template_data_with_names -from .workfile import ( - get_custom_workfile_template_by_string_context, - get_workfile_template_key_from_context, - get_last_workfile, - MissingWorkdirError, -) +from .workfile import get_custom_workfile_template_by_string_context from . import ( register_loader_plugin_path, register_inventory_action_path, From 2d3259aac6170d82106a8f469376cd076b22baea Mon Sep 17 00:00:00 2001 From: Roy Nieterau Date: Thu, 24 Jul 2025 13:36:14 +0200 Subject: [PATCH 18/52] Import from a level up --- client/ayon_core/pipeline/context_tools.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/ayon_core/pipeline/context_tools.py b/client/ayon_core/pipeline/context_tools.py index b06d34b26f..9b29fa0b3a 100644 --- a/client/ayon_core/pipeline/context_tools.py +++ b/client/ayon_core/pipeline/context_tools.py @@ -575,5 +575,5 @@ def get_process_id(): def version_up_current_workfile(): """Function to increment and save workfile""" - from ayon_core.pipeline.workfile.utils import save_next_version + from ayon_core.pipeline.workfile import save_next_version save_next_version() From 39c72809b9c13d773fc1abb217658c3d495bff9f Mon Sep 17 00:00:00 2001 From: Ynbot Date: Thu, 24 Jul 2025 12:05:37 +0000 Subject: [PATCH 19/52] [Automated] Add generated package files from main --- client/ayon_core/version.py | 2 +- package.py | 2 +- pyproject.toml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/client/ayon_core/version.py b/client/ayon_core/version.py index 509c4a8d14..5e5ea1ca3a 100644 --- a/client/ayon_core/version.py +++ b/client/ayon_core/version.py @@ -1,3 +1,3 @@ # -*- coding: utf-8 -*- """Package declaring AYON addon 'core' version.""" -__version__ = "1.4.1+dev" +__version__ = "1.5.0" diff --git a/package.py b/package.py index 039bf0379c..f10bbe29cb 100644 --- a/package.py +++ b/package.py @@ -1,6 +1,6 @@ name = "core" title = "Core" -version = "1.4.1+dev" +version = "1.5.0" client_dir = "ayon_core" diff --git a/pyproject.toml b/pyproject.toml index 68e1ed39a3..9e1046dc43 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -5,7 +5,7 @@ [tool.poetry] name = "ayon-core" -version = "1.4.1+dev" +version = "1.5.0" description = "" authors = ["Ynput Team "] readme = "README.md" From 34d2c6e6e1f21c452e0c50524b33eefcb6087fd3 Mon Sep 17 00:00:00 2001 From: Ynbot Date: Thu, 24 Jul 2025 12:06:16 +0000 Subject: [PATCH 20/52] [Automated] Update version in package.py for develop --- client/ayon_core/version.py | 2 +- package.py | 2 +- pyproject.toml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/client/ayon_core/version.py b/client/ayon_core/version.py index 5e5ea1ca3a..7f55a17a01 100644 --- a/client/ayon_core/version.py +++ b/client/ayon_core/version.py @@ -1,3 +1,3 @@ # -*- coding: utf-8 -*- """Package declaring AYON addon 'core' version.""" -__version__ = "1.5.0" +__version__ = "1.5.0+dev" diff --git a/package.py b/package.py index f10bbe29cb..807e4e4b35 100644 --- a/package.py +++ b/package.py @@ -1,6 +1,6 @@ name = "core" title = "Core" -version = "1.5.0" +version = "1.5.0+dev" client_dir = "ayon_core" diff --git a/pyproject.toml b/pyproject.toml index 9e1046dc43..e7977a5579 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -5,7 +5,7 @@ [tool.poetry] name = "ayon-core" -version = "1.5.0" +version = "1.5.0+dev" description = "" authors = ["Ynput Team "] readme = "README.md" From 7382eb338c82618a7ab2161630a8be176c66fa3a Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Thu, 24 Jul 2025 12:07:11 +0000 Subject: [PATCH 21/52] chore(): update bug report / version --- .github/ISSUE_TEMPLATE/bug_report.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index 9fb6ee645d..9202190f8b 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -35,6 +35,7 @@ body: label: Version description: What version are you running? Look to AYON Tray options: + - 1.5.0 - 1.4.1 - 1.4.0 - 1.3.2 From 3cba26a85f4ca068a1229a146a36d981a388a31b Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Thu, 24 Jul 2025 15:21:19 +0200 Subject: [PATCH 22/52] moved 'get_current_project_settings' to pipeline context tools --- client/ayon_core/pipeline/context_tools.py | 18 +++++++++++++ client/ayon_core/settings/lib.py | 30 +++++++++++++--------- 2 files changed, 36 insertions(+), 12 deletions(-) diff --git a/client/ayon_core/pipeline/context_tools.py b/client/ayon_core/pipeline/context_tools.py index 9b29fa0b3a..0877f2f049 100644 --- a/client/ayon_core/pipeline/context_tools.py +++ b/client/ayon_core/pipeline/context_tools.py @@ -360,6 +360,24 @@ def get_current_task_name(): return get_global_context()["task_name"] +def get_current_project_settings() -> dict[str, Any]: + """Project settings for the current context project. + + Returns: + dict[str, Any]: Project settings for the current context project. + + Raises: + ValueError: If current project is not set. + + """ + project_name = get_current_project_name() + if not project_name: + raise ValueError( + "Current project is not set. Can't get project settings." + ) + return get_project_settings(project_name) + + def get_current_project_entity(fields=None): """Helper function to get project document based on global Session. diff --git a/client/ayon_core/settings/lib.py b/client/ayon_core/settings/lib.py index 72af07799f..fbbd860397 100644 --- a/client/ayon_core/settings/lib.py +++ b/client/ayon_core/settings/lib.py @@ -4,6 +4,7 @@ import logging import collections import copy import time +import warnings import ayon_api @@ -175,17 +176,22 @@ def get_project_environments(project_name, project_settings=None): def get_current_project_settings(): - """Project settings for current context project. + """DEPRECATE Project settings for current context project. + + Function requires access to pipeline context which is in + 'ayon_core.pipeline'. + + Returns: + dict[str, Any]: Project settings for current context project. - Project name should be stored in environment variable `AYON_PROJECT_NAME`. - This function should be used only in host context where environment - variable must be set and should not happen that any part of process will - change the value of the environment variable. """ - project_name = os.environ.get("AYON_PROJECT_NAME") - if not project_name: - raise ValueError( - "Missing context project in environment" - " variable `AYON_PROJECT_NAME`." - ) - return get_project_settings(project_name) + warnings.warn( + "Used deprecated function 'get_current_project_settings' in" + " 'ayon_core.settings'. The function was moved to" + " 'ayon_core.pipeline.context_tools'.", + DeprecationWarning, + stacklevel=2 + ) + from ayon_core.pipeline.context_tools import get_current_project_settings + + return get_current_project_settings() From 7f4f7be8b36b5a24ad63a58ba9a05036ef40e443 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Thu, 24 Jul 2025 15:22:51 +0200 Subject: [PATCH 23/52] use anatomy if roots are not filled --- client/ayon_core/pipeline/load/utils.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/client/ayon_core/pipeline/load/utils.py b/client/ayon_core/pipeline/load/utils.py index 3c50d76fb5..836fc5e096 100644 --- a/client/ayon_core/pipeline/load/utils.py +++ b/client/ayon_core/pipeline/load/utils.py @@ -720,11 +720,13 @@ def get_representation_path(representation, root=None): str: fullpath of the representation """ - if root is None: - from ayon_core.pipeline import registered_root + from ayon_core.pipeline import get_current_project_name, Anatomy - root = registered_root() + anatomy = Anatomy(get_current_project_name()) + return get_representation_path_with_anatomy( + representation, anatomy + ) def path_from_representation(): try: @@ -772,7 +774,7 @@ def get_representation_path(representation, root=None): dir_path, file_name = os.path.split(path) if not os.path.exists(dir_path): - return + return None base_name, ext = os.path.splitext(file_name) file_name_items = None @@ -782,7 +784,7 @@ def get_representation_path(representation, root=None): file_name_items = base_name.split("%") if not file_name_items: - return + return None filename_start = file_name_items[0] From 97cd8a2ec960bbca158dad49c2522a2828011fc3 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Thu, 24 Jul 2025 15:23:07 +0200 Subject: [PATCH 24/52] mark registered root as deprecated --- client/ayon_core/pipeline/context_tools.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/client/ayon_core/pipeline/context_tools.py b/client/ayon_core/pipeline/context_tools.py index 0877f2f049..89963a6205 100644 --- a/client/ayon_core/pipeline/context_tools.py +++ b/client/ayon_core/pipeline/context_tools.py @@ -69,7 +69,7 @@ def _get_addons_manager(): def register_root(path): - """Register currently active root""" + """DEPRECATED Register currently active root.""" log.info("Registering root: %s" % path) _registered_root["_"] = path @@ -88,8 +88,14 @@ def registered_root(): Returns: dict[str, str]: Root paths. - """ + """ + warnings.warn( + "Used deprecated function 'registered_root'. Please use 'Anatomy'" + " to get roots.", + DeprecationWarning, + stacklevel=2, + ) return _registered_root["_"] From 2d341f6e552c76604a31df60ac875a7dbd7ce1b1 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Thu, 24 Jul 2025 15:23:26 +0200 Subject: [PATCH 25/52] use 'get_current_host_name' to get host name --- client/ayon_core/pipeline/context_tools.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/ayon_core/pipeline/context_tools.py b/client/ayon_core/pipeline/context_tools.py index 89963a6205..2b4f9d45b8 100644 --- a/client/ayon_core/pipeline/context_tools.py +++ b/client/ayon_core/pipeline/context_tools.py @@ -183,7 +183,7 @@ def install_ayon_plugins(project_name=None, host_name=None): register_inventory_action_path(INVENTORY_PATH) if host_name is None: - host_name = os.environ.get("AYON_HOST_NAME") + host_name = get_current_host_name() addons_manager = _get_addons_manager() publish_plugin_dirs = addons_manager.collect_publish_plugin_paths( From 28eac4b18bc69ca4117d0cd6bdf6a9e2363d7e38 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Thu, 24 Jul 2025 15:24:16 +0200 Subject: [PATCH 26/52] added HostBase validation --- client/ayon_core/pipeline/context_tools.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/client/ayon_core/pipeline/context_tools.py b/client/ayon_core/pipeline/context_tools.py index 2b4f9d45b8..e8a770ec54 100644 --- a/client/ayon_core/pipeline/context_tools.py +++ b/client/ayon_core/pipeline/context_tools.py @@ -99,13 +99,18 @@ def registered_root(): return _registered_root["_"] -def install_host(host): +def install_host(host: HostBase) -> None: """Install `host` into the running Python session. Args: host (HostBase): A host interface object. """ + if not isinstance(host, HostBase): + log.error( + f"Host must be a subclass of 'HostBase', got '{type(host)}'." + ) + global _is_installed _is_installed = True From ab60d611105a58901bdf8467a9d59ff34598ed13 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Thu, 24 Jul 2025 15:24:31 +0200 Subject: [PATCH 27/52] mark 'version_up_current_workfile' as deprecated --- client/ayon_core/pipeline/context_tools.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/client/ayon_core/pipeline/context_tools.py b/client/ayon_core/pipeline/context_tools.py index e8a770ec54..423e8f7216 100644 --- a/client/ayon_core/pipeline/context_tools.py +++ b/client/ayon_core/pipeline/context_tools.py @@ -1,5 +1,6 @@ """Core pipeline functionality""" from __future__ import annotations + import os import logging import platform @@ -575,6 +576,7 @@ def change_current_context( " It is not necessary to pass it in anymore." ), DeprecationWarning, + stacklevel=2, ) host = registered_host() @@ -603,6 +605,16 @@ def get_process_id(): def version_up_current_workfile(): - """Function to increment and save workfile""" + """DEPRECATED Function to increment and save workfile. + + Please use 'save_next_version' from 'ayon_core.pipeline.workfile' instead. + + """ + warnings.warn( + "Used deprecated 'version_up_current_workfile' please use" + " 'save_next_version' from 'ayon_core.pipeline.workfile' instead.", + DeprecationWarning, + stacklevel=2, + ) from ayon_core.pipeline.workfile import save_next_version save_next_version() From 32ea97af45bef30951c65e235f541cc2f2827e46 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Fri, 25 Jul 2025 16:04:03 +0200 Subject: [PATCH 28/52] define settings category on core plugins --- client/ayon_core/plugins/publish/cleanup.py | 2 ++ client/ayon_core/plugins/publish/cleanup_farm.py | 2 ++ client/ayon_core/plugins/publish/collect_audio.py | 1 + client/ayon_core/plugins/publish/collect_frames_fix.py | 1 + client/ayon_core/plugins/publish/collect_scene_version.py | 3 ++- client/ayon_core/plugins/publish/extract_burnin.py | 1 + client/ayon_core/plugins/publish/extract_color_transcode.py | 2 ++ client/ayon_core/plugins/publish/extract_review.py | 1 + client/ayon_core/plugins/publish/extract_thumbnail.py | 1 + .../plugins/publish/extract_usd_layer_contributions.py | 6 +++++- client/ayon_core/plugins/publish/integrate_hero_version.py | 2 ++ client/ayon_core/plugins/publish/integrate_product_group.py | 2 ++ .../publish/preintegrate_thumbnail_representation.py | 2 ++ client/ayon_core/plugins/publish/validate_containers.py | 1 + client/ayon_core/plugins/publish/validate_intent.py | 2 ++ client/ayon_core/plugins/publish/validate_version.py | 1 + 16 files changed, 28 insertions(+), 2 deletions(-) diff --git a/client/ayon_core/plugins/publish/cleanup.py b/client/ayon_core/plugins/publish/cleanup.py index 681fe700a3..03eaaf9c6e 100644 --- a/client/ayon_core/plugins/publish/cleanup.py +++ b/client/ayon_core/plugins/publish/cleanup.py @@ -38,6 +38,8 @@ class CleanUp(pyblish.api.InstancePlugin): "webpublisher", "shell" ] + settings_category = "core" + exclude_families = ["clip"] optional = True active = True diff --git a/client/ayon_core/plugins/publish/cleanup_farm.py b/client/ayon_core/plugins/publish/cleanup_farm.py index e655437ced..8d1c8de425 100644 --- a/client/ayon_core/plugins/publish/cleanup_farm.py +++ b/client/ayon_core/plugins/publish/cleanup_farm.py @@ -13,6 +13,8 @@ class CleanUpFarm(pyblish.api.ContextPlugin): order = pyblish.api.IntegratorOrder + 11 label = "Clean Up Farm" + + settings_category = "core" enabled = True # Keep "filesequence" for backwards compatibility of older jobs diff --git a/client/ayon_core/plugins/publish/collect_audio.py b/client/ayon_core/plugins/publish/collect_audio.py index 57c69ef2b2..c0b263fa6f 100644 --- a/client/ayon_core/plugins/publish/collect_audio.py +++ b/client/ayon_core/plugins/publish/collect_audio.py @@ -41,6 +41,7 @@ class CollectAudio(pyblish.api.ContextPlugin): "max", "circuit", ] + settings_category = "core" audio_product_name = "audioMain" diff --git a/client/ayon_core/plugins/publish/collect_frames_fix.py b/client/ayon_core/plugins/publish/collect_frames_fix.py index 0f7d5b692a..4270af5541 100644 --- a/client/ayon_core/plugins/publish/collect_frames_fix.py +++ b/client/ayon_core/plugins/publish/collect_frames_fix.py @@ -23,6 +23,7 @@ class CollectFramesFixDef( targets = ["local"] hosts = ["nuke"] families = ["render", "prerender"] + settings_category = "core" rewrite_version_enable = False diff --git a/client/ayon_core/plugins/publish/collect_scene_version.py b/client/ayon_core/plugins/publish/collect_scene_version.py index 7979b66abe..e6e81ea074 100644 --- a/client/ayon_core/plugins/publish/collect_scene_version.py +++ b/client/ayon_core/plugins/publish/collect_scene_version.py @@ -12,9 +12,10 @@ class CollectSceneVersion(pyblish.api.ContextPlugin): """ order = pyblish.api.CollectorOrder - label = 'Collect Scene Version' + label = "Collect Scene Version" # configurable in Settings hosts = ["*"] + settings_category = "core" # in some cases of headless publishing (for example webpublisher using PS) # you want to ignore version from name and let integrate use next version diff --git a/client/ayon_core/plugins/publish/extract_burnin.py b/client/ayon_core/plugins/publish/extract_burnin.py index fa7fd4e504..f962032680 100644 --- a/client/ayon_core/plugins/publish/extract_burnin.py +++ b/client/ayon_core/plugins/publish/extract_burnin.py @@ -57,6 +57,7 @@ class ExtractBurnin(publish.Extractor): "unreal", "circuit", ] + settings_category = "core" optional = True diff --git a/client/ayon_core/plugins/publish/extract_color_transcode.py b/client/ayon_core/plugins/publish/extract_color_transcode.py index 8a276cf608..bbb6f9585b 100644 --- a/client/ayon_core/plugins/publish/extract_color_transcode.py +++ b/client/ayon_core/plugins/publish/extract_color_transcode.py @@ -55,6 +55,8 @@ class ExtractOIIOTranscode(publish.Extractor): label = "Transcode color spaces" order = pyblish.api.ExtractorOrder + 0.019 + settings_category = "core" + optional = True # Supported extensions diff --git a/client/ayon_core/plugins/publish/extract_review.py b/client/ayon_core/plugins/publish/extract_review.py index 1e4997cfb4..377010d9e0 100644 --- a/client/ayon_core/plugins/publish/extract_review.py +++ b/client/ayon_core/plugins/publish/extract_review.py @@ -165,6 +165,7 @@ class ExtractReview(pyblish.api.InstancePlugin): "photoshop" ] + settings_category = "core" # Supported extensions image_exts = {"exr", "jpg", "jpeg", "png", "dpx", "tga", "tiff", "tif"} video_exts = {"mov", "mp4"} diff --git a/client/ayon_core/plugins/publish/extract_thumbnail.py b/client/ayon_core/plugins/publish/extract_thumbnail.py index 66acb15312..5d9f83fb42 100644 --- a/client/ayon_core/plugins/publish/extract_thumbnail.py +++ b/client/ayon_core/plugins/publish/extract_thumbnail.py @@ -43,6 +43,7 @@ class ExtractThumbnail(pyblish.api.InstancePlugin): "houdini", "circuit", ] + settings_category = "core" enabled = False integrate_thumbnail = False diff --git a/client/ayon_core/plugins/publish/extract_usd_layer_contributions.py b/client/ayon_core/plugins/publish/extract_usd_layer_contributions.py index ec1fddc6b1..c2fa61e1fe 100644 --- a/client/ayon_core/plugins/publish/extract_usd_layer_contributions.py +++ b/client/ayon_core/plugins/publish/extract_usd_layer_contributions.py @@ -255,7 +255,7 @@ class CollectUSDLayerContributions(pyblish.api.InstancePlugin, order = pyblish.api.CollectorOrder + 0.35 label = "Collect USD Layer Contributions (Asset/Shot)" families = ["usd"] - enabled = True + settings_category = "core" # A contribution defines a contribution into a (department) layer which # will get layered into the target product, usually the asset or shot. @@ -633,6 +633,8 @@ class ExtractUSDLayerContribution(publish.Extractor): label = "Extract USD Layer Contributions (Asset/Shot)" order = pyblish.api.ExtractorOrder + 0.45 + settings_category = "core" + use_ayon_entity_uri = False def process(self, instance): @@ -795,6 +797,8 @@ class ExtractUSDAssetContribution(publish.Extractor): label = "Extract USD Asset/Shot Contributions" order = ExtractUSDLayerContribution.order + 0.01 + settings_category = "core" + use_ayon_entity_uri = False def process(self, instance): diff --git a/client/ayon_core/plugins/publish/integrate_hero_version.py b/client/ayon_core/plugins/publish/integrate_hero_version.py index 43f93da293..90e6f15568 100644 --- a/client/ayon_core/plugins/publish/integrate_hero_version.py +++ b/client/ayon_core/plugins/publish/integrate_hero_version.py @@ -61,6 +61,8 @@ class IntegrateHeroVersion( # Must happen after IntegrateNew order = pyblish.api.IntegratorOrder + 0.1 + settings_category = "core" + optional = True active = True diff --git a/client/ayon_core/plugins/publish/integrate_product_group.py b/client/ayon_core/plugins/publish/integrate_product_group.py index 90887a359d..8904d21d69 100644 --- a/client/ayon_core/plugins/publish/integrate_product_group.py +++ b/client/ayon_core/plugins/publish/integrate_product_group.py @@ -24,6 +24,8 @@ class IntegrateProductGroup(pyblish.api.InstancePlugin): order = pyblish.api.IntegratorOrder - 0.1 label = "Product Group" + settings_category = "core" + # Attributes set by settings product_grouping_profiles = None diff --git a/client/ayon_core/plugins/publish/preintegrate_thumbnail_representation.py b/client/ayon_core/plugins/publish/preintegrate_thumbnail_representation.py index 8bd67c0183..900febc236 100644 --- a/client/ayon_core/plugins/publish/preintegrate_thumbnail_representation.py +++ b/client/ayon_core/plugins/publish/preintegrate_thumbnail_representation.py @@ -22,6 +22,8 @@ class PreIntegrateThumbnails(pyblish.api.InstancePlugin): label = "Override Integrate Thumbnail Representations" order = pyblish.api.IntegratorOrder - 0.1 + settings_category = "core" + integrate_profiles = [] def process(self, instance): diff --git a/client/ayon_core/plugins/publish/validate_containers.py b/client/ayon_core/plugins/publish/validate_containers.py index 520e7a7ce9..fda3d93627 100644 --- a/client/ayon_core/plugins/publish/validate_containers.py +++ b/client/ayon_core/plugins/publish/validate_containers.py @@ -31,6 +31,7 @@ class ValidateOutdatedContainers( label = "Validate Outdated Containers" order = pyblish.api.ValidatorOrder + settings_category = "core" optional = True actions = [ShowInventory] diff --git a/client/ayon_core/plugins/publish/validate_intent.py b/client/ayon_core/plugins/publish/validate_intent.py index 71df652e92..fa5e5af093 100644 --- a/client/ayon_core/plugins/publish/validate_intent.py +++ b/client/ayon_core/plugins/publish/validate_intent.py @@ -14,6 +14,8 @@ class ValidateIntent(pyblish.api.ContextPlugin): order = pyblish.api.ValidatorOrder label = "Validate Intent" + settings_category = "core" + enabled = False # Can be modified by settings diff --git a/client/ayon_core/plugins/publish/validate_version.py b/client/ayon_core/plugins/publish/validate_version.py index 0359f8fb53..d63c4e1f03 100644 --- a/client/ayon_core/plugins/publish/validate_version.py +++ b/client/ayon_core/plugins/publish/validate_version.py @@ -17,6 +17,7 @@ class ValidateVersion(pyblish.api.InstancePlugin, OptionalPyblishPluginMixin): order = pyblish.api.ValidatorOrder label = "Validate Version" + settings_category = "core" optional = False active = True From 2e345fb297604b9bff86c8c124e50eb723b1b04e Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Fri, 25 Jul 2025 16:35:59 +0200 Subject: [PATCH 29/52] warn if 'settings_category' is not filled but settings are received --- client/ayon_core/pipeline/publish/lib.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/client/ayon_core/pipeline/publish/lib.py b/client/ayon_core/pipeline/publish/lib.py index fb84417730..cd6a7bca75 100644 --- a/client/ayon_core/pipeline/publish/lib.py +++ b/client/ayon_core/pipeline/publish/lib.py @@ -354,12 +354,17 @@ def get_plugin_settings(plugin, project_settings, log, category=None): # Use project settings based on a category name if category: try: - return ( + output = ( project_settings [category] ["publish"] [plugin.__name__] ) + warnings.warn( + f"Please fill 'settings_category' for plugin '{plugin.__name__}'.", + DeprecationWarning + ) + return output except KeyError: pass @@ -384,12 +389,17 @@ def get_plugin_settings(plugin, project_settings, log, category=None): category_from_file = "core" try: - return ( + output = ( project_settings [category_from_file] [plugin_kind] [plugin.__name__] ) + warnings.warn( + f"Please fill 'settings_category' for plugin '{plugin.__name__}'.", + DeprecationWarning + ) + return output except KeyError: pass return {} From 1bdd64ae3de81473796ed52ac3f59dde47fca55b Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Fri, 25 Jul 2025 17:03:17 +0200 Subject: [PATCH 30/52] allow path to python file --- client/ayon_core/pipeline/publish/lib.py | 37 +++++++++++++----------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/client/ayon_core/pipeline/publish/lib.py b/client/ayon_core/pipeline/publish/lib.py index fb84417730..ddb1c46def 100644 --- a/client/ayon_core/pipeline/publish/lib.py +++ b/client/ayon_core/pipeline/publish/lib.py @@ -243,32 +243,35 @@ def publish_plugins_discover( for path in paths: path = os.path.normpath(path) - if not os.path.isdir(path): - continue + filenames = [] + if os.path.isdir(path): + filenames.extend( + name + for name in os.listdir(path) + if ( + os.path.isfile(os.path.join(path, name)) + and not name.startswith("_") + ) + ) + else: + filenames.append(os.path.basename(path)) + path = os.path.dirname(path) - for fname in os.listdir(path): - if fname.startswith("_"): - continue - - abspath = os.path.join(path, fname) - - if not os.path.isfile(abspath): - continue - - mod_name, mod_ext = os.path.splitext(fname) - - if mod_ext != ".py": + for filename in filenames: + mod_name, mod_ext = os.path.splitext(filename) + if mod_ext.lower() != ".py": continue + filepath = os.path.join(path, filename) try: module = import_filepath( - abspath, mod_name, sys_module_name=mod_name) + filepath, mod_name, sys_module_name=mod_name except Exception as err: # noqa: BLE001 # we need broad exception to catch all possible errors. - result.crashed_file_paths[abspath] = sys.exc_info() + result.crashed_file_paths[filepath] = sys.exc_info() - log.debug('Skipped: "%s" (%s)', mod_name, err) + log.debug('Skipped: "%s" (%s)', filepath, err) continue for plugin in pyblish.plugin.plugins_from_module(module): From c398e1fca35c5c379acb53b1c47bce8a493affb9 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Fri, 25 Jul 2025 17:03:37 +0200 Subject: [PATCH 31/52] hash dirpath for sys modules --- client/ayon_core/pipeline/publish/lib.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/client/ayon_core/pipeline/publish/lib.py b/client/ayon_core/pipeline/publish/lib.py index ddb1c46def..c0b138c7f2 100644 --- a/client/ayon_core/pipeline/publish/lib.py +++ b/client/ayon_core/pipeline/publish/lib.py @@ -5,6 +5,7 @@ import sys import inspect import copy import warnings +import hashlib import xml.etree.ElementTree from typing import TYPE_CHECKING, Optional, Union, List @@ -257,15 +258,18 @@ def publish_plugins_discover( filenames.append(os.path.basename(path)) path = os.path.dirname(path) + dirpath_hash = hashlib.md5(path.encode("utf-8")).hexdigest() for filename in filenames: mod_name, mod_ext = os.path.splitext(filename) if mod_ext.lower() != ".py": continue filepath = os.path.join(path, filename) + sys_module_name = f"{dirpath_hash}.{mod_name}" try: module = import_filepath( - filepath, mod_name, sys_module_name=mod_name + filepath, mod_name, sys_module_name=sys_module_name + ) except Exception as err: # noqa: BLE001 # we need broad exception to catch all possible errors. From cdb719494ef86728f22440e137320e2aa91c6216 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Fri, 25 Jul 2025 17:19:26 +0200 Subject: [PATCH 32/52] use same name for both sys module and module --- client/ayon_core/pipeline/publish/lib.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/client/ayon_core/pipeline/publish/lib.py b/client/ayon_core/pipeline/publish/lib.py index c0b138c7f2..d360526024 100644 --- a/client/ayon_core/pipeline/publish/lib.py +++ b/client/ayon_core/pipeline/publish/lib.py @@ -260,15 +260,15 @@ def publish_plugins_discover( dirpath_hash = hashlib.md5(path.encode("utf-8")).hexdigest() for filename in filenames: - mod_name, mod_ext = os.path.splitext(filename) - if mod_ext.lower() != ".py": + basename, ext = os.path.splitext(filename) + if ext.lower() != ".py": continue filepath = os.path.join(path, filename) - sys_module_name = f"{dirpath_hash}.{mod_name}" + module_name = f"{dirpath_hash}.{basename}" try: module = import_filepath( - filepath, mod_name, sys_module_name=sys_module_name + filepath, module_name, sys_module_name=module_name ) except Exception as err: # noqa: BLE001 From feece4a7c30f32603c58d11d201aa73d494ed040 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Fri, 25 Jul 2025 17:29:12 +0200 Subject: [PATCH 33/52] fix line length --- client/ayon_core/pipeline/publish/lib.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/client/ayon_core/pipeline/publish/lib.py b/client/ayon_core/pipeline/publish/lib.py index cd6a7bca75..dfaba0e7a9 100644 --- a/client/ayon_core/pipeline/publish/lib.py +++ b/client/ayon_core/pipeline/publish/lib.py @@ -361,7 +361,8 @@ def get_plugin_settings(plugin, project_settings, log, category=None): [plugin.__name__] ) warnings.warn( - f"Please fill 'settings_category' for plugin '{plugin.__name__}'.", + "Please fill 'settings_category'" + f" for plugin '{plugin.__name__}'.", DeprecationWarning ) return output @@ -396,7 +397,8 @@ def get_plugin_settings(plugin, project_settings, log, category=None): [plugin.__name__] ) warnings.warn( - f"Please fill 'settings_category' for plugin '{plugin.__name__}'.", + "Please fill 'settings_category'" + f" for plugin '{plugin.__name__}'.", DeprecationWarning ) return output From 4e39e86037d878eed6e5359f1891587b5d909ec5 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Mon, 28 Jul 2025 10:28:29 +0200 Subject: [PATCH 34/52] Add 'enabled' attribute back --- .../ayon_core/plugins/publish/extract_usd_layer_contributions.py | 1 + 1 file changed, 1 insertion(+) diff --git a/client/ayon_core/plugins/publish/extract_usd_layer_contributions.py b/client/ayon_core/plugins/publish/extract_usd_layer_contributions.py index c2fa61e1fe..0dc9a5e34d 100644 --- a/client/ayon_core/plugins/publish/extract_usd_layer_contributions.py +++ b/client/ayon_core/plugins/publish/extract_usd_layer_contributions.py @@ -255,6 +255,7 @@ class CollectUSDLayerContributions(pyblish.api.InstancePlugin, order = pyblish.api.CollectorOrder + 0.35 label = "Collect USD Layer Contributions (Asset/Shot)" families = ["usd"] + enabled = True settings_category = "core" # A contribution defines a contribution into a (department) layer which From bfc82a07fd58914933f7d1757dc48f3a6e1601c8 Mon Sep 17 00:00:00 2001 From: "robin@ynput.io" Date: Mon, 28 Jul 2025 11:30:57 -0400 Subject: [PATCH 35/52] Detect rounding issues in media available_range when extracting (OTIO). --- client/ayon_core/pipeline/editorial.py | 4 ++ .../publish/extract_otio_audio_tracks.py | 9 +++++ .../plugins/publish/extract_otio_review.py | 39 +++++++++++++++---- 3 files changed, 45 insertions(+), 7 deletions(-) diff --git a/client/ayon_core/pipeline/editorial.py b/client/ayon_core/pipeline/editorial.py index 8b6cfc52f1..b553fae3fb 100644 --- a/client/ayon_core/pipeline/editorial.py +++ b/client/ayon_core/pipeline/editorial.py @@ -7,6 +7,10 @@ import opentimelineio as otio from opentimelineio import opentime as _ot +# https://github.com/AcademySoftwareFoundation/OpenTimelineIO/issues/1822 +OTIO_EPSILON = 1e-9 + + def otio_range_to_frame_range(otio_range): start = _ot.to_frames( otio_range.start_time, otio_range.start_time.rate) diff --git a/client/ayon_core/plugins/publish/extract_otio_audio_tracks.py b/client/ayon_core/plugins/publish/extract_otio_audio_tracks.py index 472694d334..2aec4a5415 100644 --- a/client/ayon_core/plugins/publish/extract_otio_audio_tracks.py +++ b/client/ayon_core/plugins/publish/extract_otio_audio_tracks.py @@ -7,6 +7,7 @@ from ayon_core.lib import ( get_ffmpeg_tool_args, run_subprocess ) +from ayon_core.pipeline import editorial class ExtractOtioAudioTracks(pyblish.api.ContextPlugin): @@ -172,6 +173,14 @@ class ExtractOtioAudioTracks(pyblish.api.ContextPlugin): clip_start = otio_clip.source_range.start_time fps = clip_start.rate conformed_av_start = media_av_start.rescaled_to(fps) + + # Avoid rounding issue on media available range. + if clip_start.almost_equal( + conformed_av_start, + editorial.OTIO_EPSILON + ): + conformed_av_start = clip_start + # ffmpeg ignores embedded tc start = clip_start - conformed_av_start duration = otio_clip.source_range.duration diff --git a/client/ayon_core/plugins/publish/extract_otio_review.py b/client/ayon_core/plugins/publish/extract_otio_review.py index f217be551c..74cf45e474 100644 --- a/client/ayon_core/plugins/publish/extract_otio_review.py +++ b/client/ayon_core/plugins/publish/extract_otio_review.py @@ -23,7 +23,11 @@ from ayon_core.lib import ( get_ffmpeg_tool_args, run_subprocess, ) -from ayon_core.pipeline import publish +from ayon_core.pipeline import ( + KnownPublishError, + editorial, + publish, +) class ExtractOTIOReview( @@ -97,8 +101,11 @@ class ExtractOTIOReview( # skip instance if no reviewable data available if ( - not isinstance(otio_review_clips[0], otio.schema.Clip) - and len(otio_review_clips) == 1 + len(otio_review_clips) == 1 + and ( + not isinstance(otio_review_clips[0], otio.schema.Clip) + or otio_review_clips[0].media_reference.is_missing_reference + ) ): self.log.warning( "Instance `{}` has nothing to process".format(instance)) @@ -248,7 +255,7 @@ class ExtractOTIOReview( # Single video way. # Extraction via FFmpeg. - else: + elif hasattr(media_ref, "target_url"): path = media_ref.target_url # Set extract range from 0 (FFmpeg ignores # embedded timecode). @@ -370,6 +377,13 @@ class ExtractOTIOReview( avl_start = avl_range.start_time + # Avoid rounding issue on media available range. + if start.almost_equal( + avl_start, + editorial.OTIO_EPSILON + ): + avl_start = start + # An additional gap is required before the available # range to conform source start point and head handles. if start < avl_start: @@ -388,6 +402,14 @@ class ExtractOTIOReview( # (media duration is shorter then clip requirement). end_point = start + duration avl_end_point = avl_range.end_time_exclusive() + + # Avoid rounding issue on media available range. + if end_point.almost_equal( + avl_end_point, + editorial.OTIO_EPSILON + ): + avl_end_point = end_point + if end_point > avl_end_point: gap_duration = end_point - avl_end_point duration -= gap_duration @@ -444,7 +466,7 @@ class ExtractOTIOReview( command = get_ffmpeg_tool_args("ffmpeg") input_extension = None - if sequence: + if sequence is not None: input_dir, collection, sequence_fps = sequence in_frame_start = min(collection.indexes) @@ -478,7 +500,7 @@ class ExtractOTIOReview( "-i", input_path ]) - elif video: + elif video is not None: video_path, otio_range = video frame_start = otio_range.start_time.value input_fps = otio_range.start_time.rate @@ -496,7 +518,7 @@ class ExtractOTIOReview( "-i", video_path ]) - elif gap: + elif gap is not None: sec_duration = frames_to_seconds(gap, self.actual_fps) # form command for rendering gap files @@ -510,6 +532,9 @@ class ExtractOTIOReview( "-tune", "stillimage" ]) + else: + raise KnownPublishError("Sequence, video or gap is required.") + if video or sequence: command.extend([ "-vf", f"scale={self.to_width}:{self.to_height}:flags=lanczos", From 74ad2e2c7ed451807934f9e640e1f2be2aab350c Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Tue, 29 Jul 2025 17:39:54 +0200 Subject: [PATCH 36/52] add settings category to CollectAnatomyInstanceData --- .../ayon_core/plugins/publish/collect_anatomy_instance_data.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/client/ayon_core/plugins/publish/collect_anatomy_instance_data.py b/client/ayon_core/plugins/publish/collect_anatomy_instance_data.py index 2fcf562dd0..2cb2297bf7 100644 --- a/client/ayon_core/plugins/publish/collect_anatomy_instance_data.py +++ b/client/ayon_core/plugins/publish/collect_anatomy_instance_data.py @@ -46,6 +46,8 @@ class CollectAnatomyInstanceData(pyblish.api.ContextPlugin): order = pyblish.api.CollectorOrder + 0.49 label = "Collect Anatomy Instance data" + settings_category = "core" + follow_workfile_version = False def process(self, context): From 97a3ab142c291ced73aef586bad8e6c3b62d5ab4 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Thu, 31 Jul 2025 10:46:37 +0200 Subject: [PATCH 37/52] raise dedicated exception if item is not available --- client/ayon_core/lib/local_settings.py | 41 +++++++++++++++----------- 1 file changed, 24 insertions(+), 17 deletions(-) diff --git a/client/ayon_core/lib/local_settings.py b/client/ayon_core/lib/local_settings.py index 91b881cf57..7c6459fad6 100644 --- a/client/ayon_core/lib/local_settings.py +++ b/client/ayon_core/lib/local_settings.py @@ -15,6 +15,11 @@ import ayon_api _PLACEHOLDER = object() +# TODO should use 'KeyError' or 'Exception' as base +class RegistryItemNotFound(ValueError): + """Raised when the item is not found in keyring.""" + + class _Cache: username = None @@ -187,7 +192,7 @@ class AYONSecureRegistry: value (str): Value of the item. Raises: - ValueError: If item doesn't exist and default is not defined. + RegistryItemNotFound: If item doesn't exist and default is not defined. .. _Keyring module: https://github.com/jaraco/keyring @@ -202,9 +207,8 @@ class AYONSecureRegistry: if default is not _PLACEHOLDER: return default - # NOTE Should raise `KeyError` - raise ValueError( - "Item {}:{} does not exist in keyring.".format(self._name, name) + raise RegistryItemNotFound( + f"Item {self._name}:{name} not found in keyring." ) def delete_item(self, name): @@ -277,7 +281,7 @@ class ASettingRegistry(ABC): value (str): Value of the item. Raises: - ValueError: If item doesn't exist. + RegistryItemNotFound: If the item doesn't exist. """ return self._get_item(name) @@ -388,7 +392,7 @@ class IniSettingRegistry(ASettingRegistry): str: Value of item. Raises: - ValueError: If value doesn't exist. + RegistryItemNotFound: If value doesn't exist. """ return super(IniSettingRegistry, self).get_item(name) @@ -399,8 +403,8 @@ class IniSettingRegistry(ASettingRegistry): """Get item from section of ini file. This will read ini file and try to get item value from specified - section. If that section or item doesn't exist, :exc:`ValueError` - is risen. + section. If that section or item doesn't exist, + :exc:`RegistryItemNotFound` is risen. Args: section (str): Name of ini section. @@ -410,7 +414,7 @@ class IniSettingRegistry(ASettingRegistry): str: Item value. Raises: - ValueError: If value doesn't exist. + RegistryItemNotFound: If value doesn't exist. """ config = configparser.ConfigParser() @@ -418,8 +422,9 @@ class IniSettingRegistry(ASettingRegistry): try: value = config[section][name] except KeyError: - raise ValueError( - "Registry doesn't contain value {}:{}".format(section, name)) + raise RegistryItemNotFound( + f"Registry doesn't contain value {section}:{name}" + ) return value def _get_item(self, name): @@ -435,7 +440,7 @@ class IniSettingRegistry(ASettingRegistry): name (str): Name of the item. Raises: - ValueError: If item doesn't exist. + RegistryItemNotFound: If the item doesn't exist. """ self.get_item_from_section.cache_clear() @@ -444,8 +449,9 @@ class IniSettingRegistry(ASettingRegistry): try: _ = config[section][name] except KeyError: - raise ValueError( - "Registry doesn't contain value {}:{}".format(section, name)) + raise RegistryItemNotFound( + f"Registry doesn't contain value {section}:{name}" + ) config.remove_option(section, name) # if section is empty, delete it @@ -494,8 +500,9 @@ class JSONSettingRegistry(ASettingRegistry): try: value = data["registry"][name] except KeyError: - raise ValueError( - "Registry doesn't contain value {}".format(name)) + raise RegistryItemNotFound( + f"Registry doesn't contain value {name}" + ) return value def get_item(self, name): @@ -509,7 +516,7 @@ class JSONSettingRegistry(ASettingRegistry): value of the item Raises: - ValueError: If item is not found in registry file. + RegistryItemNotFound: If the item is not found in registry file. """ return self._get_item(name) From 88b01a2797c39e9b19d5808f475c3ecb49ce885f Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Thu, 31 Jul 2025 10:54:26 +0200 Subject: [PATCH 38/52] added type-hints --- client/ayon_core/lib/local_settings.py | 101 ++++++++++--------------- 1 file changed, 38 insertions(+), 63 deletions(-) diff --git a/client/ayon_core/lib/local_settings.py b/client/ayon_core/lib/local_settings.py index 7c6459fad6..19ffffd63f 100644 --- a/client/ayon_core/lib/local_settings.py +++ b/client/ayon_core/lib/local_settings.py @@ -8,6 +8,7 @@ import warnings from datetime import datetime from abc import ABC, abstractmethod from functools import lru_cache +from typing import Optional, Any import platformdirs import ayon_api @@ -24,14 +25,14 @@ class _Cache: username = None -def _get_ayon_appdirs(*args): +def _get_ayon_appdirs(*args: str) -> str: return os.path.join( platformdirs.user_data_dir("AYON", "Ynput"), *args ) -def get_ayon_appdirs(*args): +def get_ayon_appdirs(*args: str) -> str: """Local app data directory of AYON client. Deprecated: @@ -141,7 +142,7 @@ class AYONSecureRegistry: Args: name(str): Name of registry used as identifier for data. """ - def __init__(self, name): + def __init__(self, name: str) -> None: try: import keyring @@ -159,8 +160,7 @@ class AYONSecureRegistry: # Force "AYON" prefix self._name = "/".join(("AYON", name)) - def set_item(self, name, value): - # type: (str, str) -> None + def set_item(self, name: str, value: str) -> None: """Set sensitive item into system's keyring. This uses `Keyring module`_ to save sensitive stuff into system's @@ -179,7 +179,9 @@ class AYONSecureRegistry: keyring.set_password(self._name, name, value) @lru_cache(maxsize=32) - def get_item(self, name, default=_PLACEHOLDER): + def get_item( + self, name: str, default: Any = _PLACEHOLDER + ) -> Optional[str]: """Get value of sensitive item from system's keyring. See also `Keyring module`_ @@ -211,8 +213,7 @@ class AYONSecureRegistry: f"Item {self._name}:{name} not found in keyring." ) - def delete_item(self, name): - # type: (str) -> None + def delete_item(self, name: str) -> None: """Delete value stored in system's keyring. See also `Keyring module`_ @@ -241,16 +242,13 @@ class ASettingRegistry(ABC): _name (str): Registry names. """ - - def __init__(self, name): - # type: (str) -> ASettingRegistry + def __init__(self, name: str) -> None: super(ASettingRegistry, self).__init__() self._name = name self._items = {} - def set_item(self, name, value): - # type: (str, str) -> None + def set_item(self, name: str, value: str) -> None: """Set item to settings registry. Args: @@ -261,17 +259,14 @@ class ASettingRegistry(ABC): self._set_item(name, value) @abstractmethod - def _set_item(self, name, value): - # type: (str, str) -> None - # Implement it - pass + def _set_item(self, name: str, value: str) -> None: + """Set item value to registry.""" - def __setitem__(self, name, value): + def __setitem__(self, name: str, value: str) -> None: self._items[name] = value self._set_item(name, value) - def get_item(self, name): - # type: (str) -> str + def get_item(self, name: str) -> str: """Get item from settings registry. Args: @@ -287,16 +282,13 @@ class ASettingRegistry(ABC): return self._get_item(name) @abstractmethod - def _get_item(self, name): - # type: (str) -> str - # Implement it - pass + def _get_item(self, name: str) -> str: + """Get item value from registry.""" - def __getitem__(self, name): + def __getitem__(self, name: str) -> Any: return self._get_item(name) - def delete_item(self, name): - # type: (str) -> None + def delete_item(self, name: str) -> None: """Delete item from settings registry. Args: @@ -306,12 +298,10 @@ class ASettingRegistry(ABC): self._delete_item(name) @abstractmethod - def _delete_item(self, name): - # type: (str) -> None - """Delete item from settings.""" - pass + def _delete_item(self, name: str) -> None: + """Delete item from registry.""" - def __delitem__(self, name): + def __delitem__(self, name: str) -> None: del self._items[name] self._delete_item(name) @@ -322,9 +312,7 @@ class IniSettingRegistry(ASettingRegistry): This class is using :mod:`configparser` (ini) files to store items. """ - - def __init__(self, name, path): - # type: (str, str) -> IniSettingRegistry + def __init__(self, name: str, path: str) -> None: super(IniSettingRegistry, self).__init__(name) # get registry file self._registry_file = os.path.join(path, "{}.ini".format(name)) @@ -334,8 +322,7 @@ class IniSettingRegistry(ASettingRegistry): now = datetime.now().strftime("%d/%m/%Y %H:%M:%S") print("# {}".format(now), cfg) - def set_item_section(self, section, name, value): - # type: (str, str, str) -> None + def set_item_section(self, section: str, name: str, value: str) -> None: """Set item to specific section of ini registry. If section doesn't exists, it is created. @@ -358,12 +345,10 @@ class IniSettingRegistry(ASettingRegistry): with open(self._registry_file, mode="w") as cfg: config.write(cfg) - def _set_item(self, name, value): - # type: (str, str) -> None + def _set_item(self, name: str, value: str) -> None: self.set_item_section("MAIN", name, value) - def set_item(self, name, value): - # type: (str, str) -> None + def set_item(self, name: str, value: str) -> None: """Set item to settings ini file. This saves item to ``DEFAULT`` section of ini as each item there @@ -378,8 +363,7 @@ class IniSettingRegistry(ASettingRegistry): # we cast value to str as ini options values must be strings. super(IniSettingRegistry, self).set_item(name, str(value)) - def get_item(self, name): - # type: (str) -> str + def get_item(self, name: str) -> str: """Gets item from settings ini file. This gets settings from ``DEFAULT`` section of ini file as each item @@ -398,8 +382,7 @@ class IniSettingRegistry(ASettingRegistry): return super(IniSettingRegistry, self).get_item(name) @lru_cache(maxsize=32) - def get_item_from_section(self, section, name): - # type: (str, str) -> str + def get_item_from_section(self, section: str, name: str) -> str: """Get item from section of ini file. This will read ini file and try to get item value from specified @@ -427,12 +410,10 @@ class IniSettingRegistry(ASettingRegistry): ) return value - def _get_item(self, name): - # type: (str) -> str + def _get_item(self, name: str) -> str: return self.get_item_from_section("MAIN", name) - def delete_item_from_section(self, section, name): - # type: (str, str) -> None + def delete_item_from_section(self, section: str, name: str) -> None: """Delete item from section in ini file. Args: @@ -469,8 +450,7 @@ class IniSettingRegistry(ASettingRegistry): class JSONSettingRegistry(ASettingRegistry): """Class using json file as storage.""" - def __init__(self, name, path): - # type: (str, str) -> JSONSettingRegistry + def __init__(self, name: str, path: str) -> None: super(JSONSettingRegistry, self).__init__(name) #: str: name of registry file self._registry_file = os.path.join(path, "{}.json".format(name)) @@ -487,8 +467,7 @@ class JSONSettingRegistry(ASettingRegistry): json.dump(header, cfg, indent=4) @lru_cache(maxsize=32) - def _get_item(self, name): - # type: (str) -> object + def _get_item(self, name: str) -> Any: """Get item value from registry json. Note: @@ -505,8 +484,7 @@ class JSONSettingRegistry(ASettingRegistry): ) return value - def get_item(self, name): - # type: (str) -> object + def get_item(self, name: str) -> Any: """Get item value from registry json. Args: @@ -521,8 +499,7 @@ class JSONSettingRegistry(ASettingRegistry): """ return self._get_item(name) - def _set_item(self, name, value): - # type: (str, object) -> None + def _set_item(self, name: str, value: Any) -> None: """Set item value to registry json. Note: @@ -536,8 +513,7 @@ class JSONSettingRegistry(ASettingRegistry): cfg.seek(0) json.dump(data, cfg, indent=4) - def set_item(self, name, value): - # type: (str, object) -> None + def set_item(self, name: str, value: Any) -> None: """Set item and its value into json registry file. Args: @@ -547,8 +523,7 @@ class JSONSettingRegistry(ASettingRegistry): """ self._set_item(name, value) - def _delete_item(self, name): - # type: (str) -> None + def _delete_item(self, name: str) -> None: self._get_item.cache_clear() with open(self._registry_file, "r+") as cfg: data = json.load(cfg) @@ -563,9 +538,9 @@ class AYONSettingsRegistry(JSONSettingRegistry): Args: name (Optional[str]): Name of the registry. - """ - def __init__(self, name=None): + """ + def __init__(self, name: Optional[str] = None) -> None: if not name: name = "AYON_settings" path = get_launcher_storage_dir() From d431956963c55bb60405142649efd636011b89ca Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Thu, 31 Jul 2025 10:55:34 +0200 Subject: [PATCH 39/52] simplified super calls --- client/ayon_core/lib/local_settings.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/client/ayon_core/lib/local_settings.py b/client/ayon_core/lib/local_settings.py index 19ffffd63f..26db587835 100644 --- a/client/ayon_core/lib/local_settings.py +++ b/client/ayon_core/lib/local_settings.py @@ -243,7 +243,7 @@ class ASettingRegistry(ABC): """ def __init__(self, name: str) -> None: - super(ASettingRegistry, self).__init__() + super().__init__() self._name = name self._items = {} @@ -313,7 +313,7 @@ class IniSettingRegistry(ASettingRegistry): """ def __init__(self, name: str, path: str) -> None: - super(IniSettingRegistry, self).__init__(name) + super().__init__(name) # get registry file self._registry_file = os.path.join(path, "{}.ini".format(name)) if not os.path.exists(self._registry_file): @@ -361,7 +361,7 @@ class IniSettingRegistry(ASettingRegistry): """ # this does the some, overridden just for different docstring. # we cast value to str as ini options values must be strings. - super(IniSettingRegistry, self).set_item(name, str(value)) + super().set_item(name, str(value)) def get_item(self, name: str) -> str: """Gets item from settings ini file. @@ -379,7 +379,7 @@ class IniSettingRegistry(ASettingRegistry): RegistryItemNotFound: If value doesn't exist. """ - return super(IniSettingRegistry, self).get_item(name) + return super().get_item(name) @lru_cache(maxsize=32) def get_item_from_section(self, section: str, name: str) -> str: @@ -451,7 +451,7 @@ class JSONSettingRegistry(ASettingRegistry): """Class using json file as storage.""" def __init__(self, name: str, path: str) -> None: - super(JSONSettingRegistry, self).__init__(name) + super().__init__(name) #: str: name of registry file self._registry_file = os.path.join(path, "{}.json".format(name)) now = datetime.now().strftime("%d/%m/%Y %H:%M:%S") @@ -544,7 +544,7 @@ class AYONSettingsRegistry(JSONSettingRegistry): if not name: name = "AYON_settings" path = get_launcher_storage_dir() - super(AYONSettingsRegistry, self).__init__(name, path) + super().__init__(name, path) def get_local_site_id(): From 08c242edefe4b11046a589fca10a7e8e7f969177 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Thu, 31 Jul 2025 10:55:59 +0200 Subject: [PATCH 40/52] use f-strings --- client/ayon_core/lib/local_settings.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/client/ayon_core/lib/local_settings.py b/client/ayon_core/lib/local_settings.py index 26db587835..36abeb4283 100644 --- a/client/ayon_core/lib/local_settings.py +++ b/client/ayon_core/lib/local_settings.py @@ -158,7 +158,7 @@ class AYONSecureRegistry: keyring.set_keyring(Windows.WinVaultKeyring()) # Force "AYON" prefix - self._name = "/".join(("AYON", name)) + self._name = f"AYON/{name}" def set_item(self, name: str, value: str) -> None: """Set sensitive item into system's keyring. @@ -315,12 +315,12 @@ class IniSettingRegistry(ASettingRegistry): def __init__(self, name: str, path: str) -> None: super().__init__(name) # get registry file - self._registry_file = os.path.join(path, "{}.ini".format(name)) + self._registry_file = os.path.join(path, f"{name}.ini") if not os.path.exists(self._registry_file): with open(self._registry_file, mode="w") as cfg: print("# Settings registry", cfg) now = datetime.now().strftime("%d/%m/%Y %H:%M:%S") - print("# {}".format(now), cfg) + print(f"# {now}", cfg) def set_item_section(self, section: str, name: str, value: str) -> None: """Set item to specific section of ini registry. @@ -452,8 +452,7 @@ class JSONSettingRegistry(ASettingRegistry): def __init__(self, name: str, path: str) -> None: super().__init__(name) - #: str: name of registry file - self._registry_file = os.path.join(path, "{}.json".format(name)) + self._registry_file = os.path.join(path, f"{name}.json") now = datetime.now().strftime("%d/%m/%Y %H:%M:%S") header = { "__metadata__": {"generated": now}, From d1fce584fa577d209feff5c91867eda12399acec Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Thu, 31 Jul 2025 10:56:25 +0200 Subject: [PATCH 41/52] remove unncessary variable --- client/ayon_core/lib/local_settings.py | 6 ------ 1 file changed, 6 deletions(-) diff --git a/client/ayon_core/lib/local_settings.py b/client/ayon_core/lib/local_settings.py index 36abeb4283..a52539a4dd 100644 --- a/client/ayon_core/lib/local_settings.py +++ b/client/ayon_core/lib/local_settings.py @@ -238,15 +238,11 @@ class ASettingRegistry(ABC): mechanism for storing common items must be implemented in abstract methods. - Attributes: - _name (str): Registry names. - """ def __init__(self, name: str) -> None: super().__init__() self._name = name - self._items = {} def set_item(self, name: str, value: str) -> None: """Set item to settings registry. @@ -263,7 +259,6 @@ class ASettingRegistry(ABC): """Set item value to registry.""" def __setitem__(self, name: str, value: str) -> None: - self._items[name] = value self._set_item(name, value) def get_item(self, name: str) -> str: @@ -302,7 +297,6 @@ class ASettingRegistry(ABC): """Delete item from registry.""" def __delitem__(self, name: str) -> None: - del self._items[name] self._delete_item(name) From d88a8678729fc2e51c9e49e7f798499e5e74cdcd Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Thu, 31 Jul 2025 10:56:39 +0200 Subject: [PATCH 42/52] reset cache on set item --- client/ayon_core/lib/local_settings.py | 1 + 1 file changed, 1 insertion(+) diff --git a/client/ayon_core/lib/local_settings.py b/client/ayon_core/lib/local_settings.py index a52539a4dd..162e17fd94 100644 --- a/client/ayon_core/lib/local_settings.py +++ b/client/ayon_core/lib/local_settings.py @@ -177,6 +177,7 @@ class AYONSecureRegistry: import keyring keyring.set_password(self._name, name, value) + self.get_item.cache_clear() @lru_cache(maxsize=32) def get_item( From 41228915eca2c0b29fdc7d7c5eb208ecda0fd568 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Thu, 31 Jul 2025 10:58:08 +0200 Subject: [PATCH 43/52] more explicit dir creation --- client/ayon_core/lib/local_settings.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/client/ayon_core/lib/local_settings.py b/client/ayon_core/lib/local_settings.py index 162e17fd94..98eec3af4f 100644 --- a/client/ayon_core/lib/local_settings.py +++ b/client/ayon_core/lib/local_settings.py @@ -454,8 +454,10 @@ class JSONSettingRegistry(ASettingRegistry): "registry": {} } - if not os.path.exists(os.path.dirname(self._registry_file)): - os.makedirs(os.path.dirname(self._registry_file), exist_ok=True) + # Use 'os.path.dirname' in case someone uses slashes in 'name' + dirpath = os.path.dirname(self._registry_file) + if not os.path.exists(dirpath): + os.makedirs(dirpath, exist_ok=True) if not os.path.exists(self._registry_file): with open(self._registry_file, mode="w") as cfg: json.dump(header, cfg, indent=4) From 2013eea5c4cc52942f79c371032f7c9b6126870a Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Thu, 31 Jul 2025 10:58:21 +0200 Subject: [PATCH 44/52] formatting change --- client/ayon_core/lib/local_settings.py | 1 + 1 file changed, 1 insertion(+) diff --git a/client/ayon_core/lib/local_settings.py b/client/ayon_core/lib/local_settings.py index 98eec3af4f..b06b890992 100644 --- a/client/ayon_core/lib/local_settings.py +++ b/client/ayon_core/lib/local_settings.py @@ -141,6 +141,7 @@ class AYONSecureRegistry: Args: name(str): Name of registry used as identifier for data. + """ def __init__(self, name: str) -> None: try: From 1a46f2c027b60e03ac35a25d231bf034042bcb1c Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Thu, 31 Jul 2025 11:00:51 +0200 Subject: [PATCH 45/52] remove unnecessary super call --- client/ayon_core/lib/local_settings.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/client/ayon_core/lib/local_settings.py b/client/ayon_core/lib/local_settings.py index b06b890992..79e0e24307 100644 --- a/client/ayon_core/lib/local_settings.py +++ b/client/ayon_core/lib/local_settings.py @@ -242,8 +242,6 @@ class ASettingRegistry(ABC): """ def __init__(self, name: str) -> None: - super().__init__() - self._name = name def set_item(self, name: str, value: str) -> None: From b403db76e6626b450dad91d489e20bc997284746 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Thu, 31 Jul 2025 11:01:52 +0200 Subject: [PATCH 46/52] better order of methods --- client/ayon_core/lib/local_settings.py | 46 ++++++++++++++------------ 1 file changed, 25 insertions(+), 21 deletions(-) diff --git a/client/ayon_core/lib/local_settings.py b/client/ayon_core/lib/local_settings.py index 79e0e24307..4b85a76b2d 100644 --- a/client/ayon_core/lib/local_settings.py +++ b/client/ayon_core/lib/local_settings.py @@ -244,23 +244,31 @@ class ASettingRegistry(ABC): def __init__(self, name: str) -> None: self._name = name - def set_item(self, name: str, value: str) -> None: - """Set item to settings registry. - - Args: - name (str): Name of the item. - value (str): Value of the item. - - """ - self._set_item(name, value) + @abstractmethod + def _get_item(self, name: str) -> Any: + """Get item value from registry.""" @abstractmethod def _set_item(self, name: str, value: str) -> None: """Set item value to registry.""" + @abstractmethod + def _delete_item(self, name: str) -> None: + """Delete item from registry.""" + + def __getitem__(self, name: str) -> Any: + return self._get_item(name) + def __setitem__(self, name: str, value: str) -> None: self._set_item(name, value) + def __delitem__(self, name: str) -> None: + self._delete_item(name) + + @property + def name(self) -> str: + return self._name + def get_item(self, name: str) -> str: """Get item from settings registry. @@ -276,12 +284,15 @@ class ASettingRegistry(ABC): """ return self._get_item(name) - @abstractmethod - def _get_item(self, name: str) -> str: - """Get item value from registry.""" + def set_item(self, name: str, value: str) -> None: + """Set item to settings registry. - def __getitem__(self, name: str) -> Any: - return self._get_item(name) + Args: + name (str): Name of the item. + value (str): Value of the item. + + """ + self._set_item(name, value) def delete_item(self, name: str) -> None: """Delete item from settings registry. @@ -292,13 +303,6 @@ class ASettingRegistry(ABC): """ self._delete_item(name) - @abstractmethod - def _delete_item(self, name: str) -> None: - """Delete item from registry.""" - - def __delitem__(self, name: str) -> None: - self._delete_item(name) - class IniSettingRegistry(ASettingRegistry): """Class using :mod:`configparser`. From d4092c8e314eb5e02cf004e07ac8a5f69f39a36c Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Thu, 31 Jul 2025 11:02:12 +0200 Subject: [PATCH 47/52] deprecated not passed name in 'AYONSettingsRegistry' --- client/ayon_core/lib/local_settings.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/client/ayon_core/lib/local_settings.py b/client/ayon_core/lib/local_settings.py index 4b85a76b2d..8511c8d15e 100644 --- a/client/ayon_core/lib/local_settings.py +++ b/client/ayon_core/lib/local_settings.py @@ -536,12 +536,21 @@ class AYONSettingsRegistry(JSONSettingRegistry): """Class handling AYON general settings registry. Args: - name (Optional[str]): Name of the registry. + name (Optional[str]): Name of the registry. Using 'None' or not + passing name is deprecated. """ def __init__(self, name: Optional[str] = None) -> None: if not name: name = "AYON_settings" + warnings.warn( + ( + "Used 'AYONSettingsRegistry' without 'name' argument." + " The argument will be required in future versions." + ), + DeprecationWarning, + stacklevel=2, + ) path = get_launcher_storage_dir() super().__init__(name, path) From 473cf8b0c13f19d4763d2d9bea4f0b376ca85f77 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Thu, 31 Jul 2025 11:19:39 +0200 Subject: [PATCH 48/52] grammar fixes --- client/ayon_core/lib/local_settings.py | 37 +++++++++++++------------- 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/client/ayon_core/lib/local_settings.py b/client/ayon_core/lib/local_settings.py index 8511c8d15e..19381b18e0 100644 --- a/client/ayon_core/lib/local_settings.py +++ b/client/ayon_core/lib/local_settings.py @@ -18,7 +18,7 @@ _PLACEHOLDER = object() # TODO should use 'KeyError' or 'Exception' as base class RegistryItemNotFound(ValueError): - """Raised when the item is not found in keyring.""" + """Raised when the item is not found in the keyring.""" class _Cache: @@ -37,10 +37,10 @@ def get_ayon_appdirs(*args: str) -> str: Deprecated: Use 'get_launcher_local_dir' or 'get_launcher_storage_dir' based on - use-case. Deprecation added 24/08/09 (0.4.4-dev.1). + a use-case. Deprecation added 24/08/09 (0.4.4-dev.1). Args: - *args (Iterable[str]): Subdirectories/files in local app data dir. + *args (Iterable[str]): Subdirectories/files in the local app data dir. Returns: str: Path to directory/file in local app data dir. @@ -58,7 +58,7 @@ def get_ayon_appdirs(*args: str) -> str: def get_launcher_storage_dir(*subdirs: str) -> str: - """Get storage directory for launcher. + """Get a storage directory for launcher. Storage directory is used for storing shims, addons, dependencies, etc. @@ -83,14 +83,14 @@ def get_launcher_storage_dir(*subdirs: str) -> str: def get_launcher_local_dir(*subdirs: str) -> str: - """Get local directory for launcher. + """Get a local directory for launcher. - Local directory is used for storing machine or user specific data. + Local directory is used for storing machine or user-specific data. - The location is user specific. + The location is user-specific. Note: - This function should be called at least once on bootstrap. + This function should be called at least once on the bootstrap. Args: *subdirs (str): Subdirectories relative to local dir. @@ -107,7 +107,7 @@ def get_launcher_local_dir(*subdirs: str) -> str: def get_addons_resources_dir(addon_name: str, *args) -> str: - """Get directory for storing resources for addons. + """Get a directory for storing resources for addons. Some addons might need to store ad-hoc resources that are not part of addon client package (e.g. because of size). Studio might define @@ -117,7 +117,7 @@ def get_addons_resources_dir(addon_name: str, *args) -> str: Args: addon_name (str): Addon name. - *args (str): Subfolders in resources directory. + *args (str): Subfolders in the resources directory. Returns: str: Path to resources directory. @@ -140,7 +140,7 @@ class AYONSecureRegistry: identify which data were created by AYON. Args: - name(str): Name of registry used as identifier for data. + name(str): Name of registry used as the identifier for data. """ def __init__(self, name: str) -> None: @@ -162,9 +162,9 @@ class AYONSecureRegistry: self._name = f"AYON/{name}" def set_item(self, name: str, value: str) -> None: - """Set sensitive item into system's keyring. + """Set sensitive item into the system's keyring. - This uses `Keyring module`_ to save sensitive stuff into system's + This uses `Keyring module`_ to save sensitive stuff into the system's keyring. Args: @@ -184,19 +184,20 @@ class AYONSecureRegistry: def get_item( self, name: str, default: Any = _PLACEHOLDER ) -> Optional[str]: - """Get value of sensitive item from system's keyring. + """Get value of sensitive item from the system's keyring. See also `Keyring module`_ Args: name (str): Name of the item. - default (Any): Default value if item is not available. + default (Any): Default value if the item is not available. Returns: value (str): Value of the item. Raises: - RegistryItemNotFound: If item doesn't exist and default is not defined. + RegistryItemNotFound: If the item doesn't exist and default + is not defined. .. _Keyring module: https://github.com/jaraco/keyring @@ -216,7 +217,7 @@ class AYONSecureRegistry: ) def delete_item(self, name: str) -> None: - """Delete value stored in system's keyring. + """Delete value stored in the system's keyring. See also `Keyring module`_ @@ -446,7 +447,7 @@ class IniSettingRegistry(ASettingRegistry): class JSONSettingRegistry(ASettingRegistry): - """Class using json file as storage.""" + """Class using a json file as storage.""" def __init__(self, name: str, path: str) -> None: super().__init__(name) From 3c867c517c4773b75aae84d049a1edf5e8323512 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Thu, 31 Jul 2025 11:20:08 +0200 Subject: [PATCH 49/52] change value of json registry to 'str' --- client/ayon_core/lib/local_settings.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/client/ayon_core/lib/local_settings.py b/client/ayon_core/lib/local_settings.py index 19381b18e0..09855c6075 100644 --- a/client/ayon_core/lib/local_settings.py +++ b/client/ayon_core/lib/local_settings.py @@ -467,8 +467,8 @@ class JSONSettingRegistry(ASettingRegistry): json.dump(header, cfg, indent=4) @lru_cache(maxsize=32) - def _get_item(self, name: str) -> Any: - """Get item value from registry json. + def _get_item(self, name: str) -> str: + """Get item value from the registry. Note: See :meth:`ayon_core.lib.JSONSettingRegistry.get_item` @@ -499,8 +499,8 @@ class JSONSettingRegistry(ASettingRegistry): """ return self._get_item(name) - def _set_item(self, name: str, value: Any) -> None: - """Set item value to registry json. + def _set_item(self, name: str, value: str) -> None: + """Set item value to the registry. Note: See :meth:`ayon_core.lib.JSONSettingRegistry.set_item` From 6433ada42c78a586899c9329b91838a5ade936e7 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Thu, 31 Jul 2025 11:20:50 +0200 Subject: [PATCH 50/52] remove unnecessary overriden methods --- client/ayon_core/lib/local_settings.py | 26 -------------------------- 1 file changed, 26 deletions(-) diff --git a/client/ayon_core/lib/local_settings.py b/client/ayon_core/lib/local_settings.py index 09855c6075..7982a2797e 100644 --- a/client/ayon_core/lib/local_settings.py +++ b/client/ayon_core/lib/local_settings.py @@ -484,21 +484,6 @@ class JSONSettingRegistry(ASettingRegistry): ) return value - def get_item(self, name: str) -> Any: - """Get item value from registry json. - - Args: - name (str): Name of the item. - - Returns: - value of the item - - Raises: - RegistryItemNotFound: If the item is not found in registry file. - - """ - return self._get_item(name) - def _set_item(self, name: str, value: str) -> None: """Set item value to the registry. @@ -513,18 +498,7 @@ class JSONSettingRegistry(ASettingRegistry): cfg.seek(0) json.dump(data, cfg, indent=4) - def set_item(self, name: str, value: Any) -> None: - """Set item and its value into json registry file. - - Args: - name (str): name of the item. - value (Any): value of the item. - - """ - self._set_item(name, value) - def _delete_item(self, name: str) -> None: - self._get_item.cache_clear() with open(self._registry_file, "r+") as cfg: data = json.load(cfg) del data["registry"][name] From 83b109be28602958e1fa0b666fc3e10188ad7cae Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Thu, 31 Jul 2025 11:21:11 +0200 Subject: [PATCH 51/52] fix cache again --- client/ayon_core/lib/local_settings.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/client/ayon_core/lib/local_settings.py b/client/ayon_core/lib/local_settings.py index 7982a2797e..4cfe059e2a 100644 --- a/client/ayon_core/lib/local_settings.py +++ b/client/ayon_core/lib/local_settings.py @@ -497,6 +497,7 @@ class JSONSettingRegistry(ASettingRegistry): cfg.truncate(0) cfg.seek(0) json.dump(data, cfg, indent=4) + self._get_item.cache_clear() def _delete_item(self, name: str) -> None: with open(self._registry_file, "r+") as cfg: @@ -505,6 +506,7 @@ class JSONSettingRegistry(ASettingRegistry): cfg.truncate(0) cfg.seek(0) json.dump(data, cfg, indent=4) + self._get_item.cache_clear() class AYONSettingsRegistry(JSONSettingRegistry): From 1017becebd118f5cdd3bd021ed7fbe5891bf954e Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Thu, 31 Jul 2025 11:21:26 +0200 Subject: [PATCH 52/52] changed abstract class docstring --- client/ayon_core/lib/local_settings.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/client/ayon_core/lib/local_settings.py b/client/ayon_core/lib/local_settings.py index 4cfe059e2a..85ece54d6f 100644 --- a/client/ayon_core/lib/local_settings.py +++ b/client/ayon_core/lib/local_settings.py @@ -235,11 +235,7 @@ class AYONSecureRegistry: class ASettingRegistry(ABC): - """Abstract class defining structure of **SettingRegistry** class. - - It is implementing methods to store secure items into keyring, otherwise - mechanism for storing common items must be implemented in abstract - methods. + """Abstract class to defining structure of registry class. """ def __init__(self, name: str) -> None: