From 375378e74cc7cddb1d4e83bbc90c1bfd14d52693 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Fri, 24 Jan 2025 14:18:27 +0100 Subject: [PATCH 1/5] auto-fill project entity if is not passed in --- client/ayon_core/pipeline/create/creator_plugins.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/client/ayon_core/pipeline/create/creator_plugins.py b/client/ayon_core/pipeline/create/creator_plugins.py index 445b41cb4b..ce109e3a37 100644 --- a/client/ayon_core/pipeline/create/creator_plugins.py +++ b/client/ayon_core/pipeline/create/creator_plugins.py @@ -562,6 +562,9 @@ class BaseCreator(ABC): instance ) + if not project_entity: + project_entity = self.create_context.get_current_project_entity() + return get_product_name( project_name, task_name, From 8b4f5ec42a210c08f22bba61abc09d1d0f9dd047 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Fri, 24 Jan 2025 14:21:22 +0100 Subject: [PATCH 2/5] added one more check if current project is the project name passed in --- client/ayon_core/pipeline/create/creator_plugins.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/client/ayon_core/pipeline/create/creator_plugins.py b/client/ayon_core/pipeline/create/creator_plugins.py index ce109e3a37..fca671d546 100644 --- a/client/ayon_core/pipeline/create/creator_plugins.py +++ b/client/ayon_core/pipeline/create/creator_plugins.py @@ -562,7 +562,8 @@ class BaseCreator(ABC): instance ) - if not project_entity: + cur_project_name = self.create_context.get_current_project_name() + if not project_entity and project_name == cur_project_name: project_entity = self.create_context.get_current_project_entity() return get_product_name( From b048f0aa3bae1e6c3b963ab89b88b804e0208c2a Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Tue, 4 Feb 2025 10:29:01 +0100 Subject: [PATCH 3/5] added helper method 'get_template_data' to create context --- client/ayon_core/pipeline/create/context.py | 31 +++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/client/ayon_core/pipeline/create/context.py b/client/ayon_core/pipeline/create/context.py index e29971415d..36a05725a6 100644 --- a/client/ayon_core/pipeline/create/context.py +++ b/client/ayon_core/pipeline/create/context.py @@ -29,6 +29,7 @@ from ayon_core.lib.events import QueuedEventSystem from ayon_core.lib.attribute_definitions import get_default_values from ayon_core.host import IPublishHost, IWorkfileHost from ayon_core.pipeline import Anatomy +from ayon_core.pipeline.template_data import get_template_data from ayon_core.pipeline.plugin_discover import DiscoverResult from .exceptions import ( @@ -480,6 +481,36 @@ class CreateContext: self.get_current_project_name()) return self._current_project_settings + def get_template_data( + self, folder_path: Optional[str], task_name: Optional[str] + ) -> dict[str, Any]: + """Prepare template data for given context. + + Method is using cached entities and settings to prepare template data. + + Args: + folder_path (Optional[str]): Folder path. + task_name (Optional[str]): Task name. + + Returns: + dict[str, Any]: Template data. + + """ + project_entity = self.get_current_project_entity() + folder_entity = task_entity = None + if folder_path: + folder_entity = self.get_folder_entity(folder_path) + if task_name and folder_entity: + task_entity = self.get_task_entity(folder_path, task_name) + + return get_template_data( + project_entity, + folder_entity, + task_entity, + host_name=self.host_name, + settings=self.get_current_project_settings(), + ) + @property def context_has_changed(self): """Host context has changed. From cc1ec148656a7afbf0546d35cae93350742c886f Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Tue, 4 Feb 2025 10:46:52 +0100 Subject: [PATCH 4/5] fix index validation --- client/ayon_core/lib/path_templates.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client/ayon_core/lib/path_templates.py b/client/ayon_core/lib/path_templates.py index 057889403c..9e3e455a6c 100644 --- a/client/ayon_core/lib/path_templates.py +++ b/client/ayon_core/lib/path_templates.py @@ -587,8 +587,8 @@ class FormattingPart: if sub_key < 0: sub_key = len(value) + sub_key - invalid = 0 > sub_key < len(data) - if invalid: + valid = 0 <= sub_key < len(value) + if not valid: used_keys.append(sub_key) missing_key = True break From 43b18910bac326c00d0784b764641398738aca6b Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Tue, 4 Feb 2025 10:51:08 +0100 Subject: [PATCH 5/5] fix typehint --- client/ayon_core/pipeline/create/context.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/ayon_core/pipeline/create/context.py b/client/ayon_core/pipeline/create/context.py index 36a05725a6..c169df67df 100644 --- a/client/ayon_core/pipeline/create/context.py +++ b/client/ayon_core/pipeline/create/context.py @@ -483,7 +483,7 @@ class CreateContext: def get_template_data( self, folder_path: Optional[str], task_name: Optional[str] - ) -> dict[str, Any]: + ) -> Dict[str, Any]: """Prepare template data for given context. Method is using cached entities and settings to prepare template data.