Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion client/ayon_core/tools/publisher/abstract.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ class UIPublishErrorItem:
def from_error_item(
cls, error_info: PublishErrorInfo
) -> "UIPublishErrorItem":
"""Create new object based on resukt from controller.
"""Create new object based on result from controller.

Returns:
PublishErrorItem: New object with filled data.
Expand Down Expand Up @@ -347,6 +347,14 @@ def from_data(cls, data: dict[str, Any]):
)


@dataclass
class SubtaskProduct:
product_name: str
product_base_type: str
product_type: str
created: bool = False


class AbstractPublisherCommon(ABC):
@abstractmethod
def register_event_callback(self, topic: str, callback: Callable) -> None:
Expand Down Expand Up @@ -507,6 +515,12 @@ def get_folder_entity(
) -> dict[str, Any] | None:
pass

@abstractmethod
def get_folder_item(
self, project_name: str, folder_id: str
) -> FolderItem | None:
pass

@abstractmethod
def get_folder_item_by_path(
self, project_name: str, folder_path: str
Expand Down Expand Up @@ -1049,3 +1063,9 @@ def get_thumbnail_temp_dir_path(self) -> str:
def clear_thumbnail_temp_dir_path(self) -> None:
"""Remove content of thumbnail temp directory."""
pass

@abstractmethod
def get_subtask_products(
self, folder_id: str, task_name: str
) -> list[SubtaskProduct]:
"""Get subtask products for a given folder and task."""
15 changes: 15 additions & 0 deletions client/ayon_core/tools/publisher/control.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,11 @@
)

if typing.TYPE_CHECKING:
from ayon_core.tools.common_models import FolderItem
from ayon_core.tools.common_models.settings import TaskSortMode

from .abstract import SubtaskProduct


class PublisherController(
AbstractPublisherBackend,
Expand Down Expand Up @@ -261,6 +264,13 @@ def get_folder_entity(self, project_name, folder_id):
def get_task_entity(self, project_name, task_id):
return self._hierarchy_model.get_task_entity(project_name, task_id)

def get_folder_item(
self, project_name: str, folder_id: str
) -> FolderItem | None:
return self._hierarchy_model.get_folder_item(
project_name, folder_id
)

def get_folder_item_by_path(self, project_name, folder_path):
return self._hierarchy_model.get_folder_item_by_path(
project_name, folder_path
Expand Down Expand Up @@ -676,3 +686,8 @@ def get_comment_def(self) -> CommentDef:
return CommentDef(
minimum_chars_required=comment_minimum_required_chars
)

def get_subtask_products(
self, folder_id: str, task_name: str
) -> list[SubtaskProduct]:
return self._create_model.get_subtask_products(folder_id, task_name)
66 changes: 66 additions & 0 deletions client/ayon_core/tools/publisher/models/create.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
PublishAttrDefsInfo,
AbstractPublisherBackend,
CardMessageTypes,
SubtaskProduct,
)

CREATE_EVENT_SOURCE = "publisher.create.model"
Expand Down Expand Up @@ -1093,6 +1094,71 @@ def set_thumbnail_paths_for_instances(
}
)

def get_subtask_products(
self, folder_id: str, task_name: str
) -> list[SubtaskProduct]:
project_name = self._controller.get_current_project_name()
if project_name is None:
return []

# TODO implement how to get subtask products for the given context.
subtask_products = [
SubtaskProduct(
"ynterestingMain",
"nothing",
"biiiiig",
),
SubtaskProduct(
"workfileMain",
"workfile",
"workfile",
),
SubtaskProduct(
"testMain",
"test",
"test",
),
SubtaskProduct(
"test2Main",
"test2",
"test2",
),
]
if not subtask_products:
return []

# Filter subtask products based on existing instances
# - skip products that are already created in the scene
folder_item = self._controller.get_folder_item(
project_name, folder_id
)
context_instances = [
instance
for instance in self._create_context.instances
if (
instance["folderPath"] == folder_item.path
and instance["task"] == task_name
)
]
if not context_instances:
return subtask_products

for subset_product in subtask_products:
pt = subset_product.product_type
pbt = subset_product.product_base_type
matching_instance = next((
instance
for instance in context_instances
if (
instance.product_type == pt
and instance.product_base_type == pbt
)
), None)
if matching_instance is not None:
subset_product.created = True

return subtask_products

def _emit_event(
self,
topic: str,
Expand Down
Loading
Loading