Skip to content

Commit

Permalink
Merge pull request #129 from ynput/enhancement/AY-6666_Shotgrid-seque…
Browse files Browse the repository at this point in the history
…nce-and-shot-folder-grouping

Sequence and shot folder grouping
  • Loading branch information
kalisp authored Nov 29, 2024
2 parents d77f968 + 127e24c commit f828cb5
Show file tree
Hide file tree
Showing 8 changed files with 587 additions and 157 deletions.
108 changes: 107 additions & 1 deletion server/settings/main.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
from ayon_server.entities.core.attrib import attribute_library
from ayon_server.settings import BaseSettingsModel, SettingsField
from ayon_server.settings.enum import secrets_enum, anatomy_presets_enum
from ayon_server.settings.enum import (
secrets_enum,
anatomy_presets_enum,
folder_types_enum
)


def default_shotgrid_entities():
Expand Down Expand Up @@ -30,6 +34,16 @@ def default_shotgrid_enabled_entities():
]


def default_shotgrid_reparenting_entities():
"""The entity types in ShotGrid that are enabled by default in AYON."""
return [
"Episode",
"Sequence",
"Shot",
"Asset",
]


def get_default_folder_attributes():
"""Get AYON's Folder attributes
Expand Down Expand Up @@ -113,6 +127,92 @@ class AttributesMappingModel(BaseSettingsModel):
)


class FolderReparentingParentsModel(BaseSettingsModel):
folder_type: str = SettingsField(
"asset",
title="Parent Ayon Folder Type",
enum_resolver=folder_types_enum,
description="Type of the parent folder in AYON",
)
folder_name: str = SettingsField(
"assets",
title="Parent Ayon Folder Name",
description=(
"Name of the parent folder in AYON. Anatomy presets can be used."
"`sg_` prefix can be used to refer to ShotGrid entities. Example: "
"`{shotgrid_type}` will be replaced with the ShotGrid Asset Type."
),
)


class FolderReparentingPresetsModel(BaseSettingsModel):

filter_by_sg_entity_type: str = SettingsField(
"Asset",
title="Filter by ShotGrid Entity Type",
enum_resolver=default_shotgrid_reparenting_entities,
description=("Type of the ShotGrid entity to filter preset on."),
)
parents: list[FolderReparentingParentsModel] = SettingsField(
title="Parents",
default_factory=list,
description=(
"List of parent folders. If empty default behavior will be used. "
"The order of the parents from top to bottom is important."
"Within 'Root relocation' type the first parent will be "
"the root folder."
),
)


class FolderReparentingRelocateModel(BaseSettingsModel):
"""Re-parent folders with Root relocation"""
enabled: bool = SettingsField(
False,
title="Enabled",
description="Enable or disable the re-parenting",
)

presets: list[FolderReparentingPresetsModel] = SettingsField(
title="Presets",
default_factory=list,
description=(
"List of presets for re-parenting. "
"If empty default behavior will be used."
),
)


class FolderReparentingTypeGroupingModel(BaseSettingsModel):
"""Re-parent folders with Type grouping"""
enabled: bool = SettingsField(
False,
title="Enabled",
description="Enable or disable the re-parenting",
)

presets: list[FolderReparentingPresetsModel] = SettingsField(
title="Presets",
default_factory=list,
description=(
"List of presets for re-parenting. "
"If empty default behavior will be used."
),
)


class FolderReparentingModel(BaseSettingsModel):

root_relocate: FolderReparentingRelocateModel = SettingsField(
default_factory=FolderReparentingRelocateModel,
title="Root relocation",
)

type_grouping: FolderReparentingTypeGroupingModel = SettingsField(
default_factory=FolderReparentingTypeGroupingModel,
title="Type grouping",
)

class ShotgridCompatibilitySettings(BaseSettingsModel):
""" Settings to define relationships between ShotGrid and AYON.
"""
Expand All @@ -136,6 +236,12 @@ class ShotgridCompatibilitySettings(BaseSettingsModel):
),
)

folder_parenting: FolderReparentingModel = SettingsField(
title="Folder re-parenting",
default_factory=FolderReparentingModel,
description=("Parent folders for AYON folders matching to SG types."),
)


class ClientLoginDetailsModel(BaseSettingsModel):
_layout = "expanded"
Expand Down
6 changes: 4 additions & 2 deletions services/shotgrid_common/ayon_shotgrid_hub/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def __init__(self,
custom_attribs_types=None,
sg_enabled_entities=None,
):
self.settings = ayon_api.get_service_addon_settings()
self.settings = ayon_api.get_service_addon_settings(project_name)

self._sg = sg_connection

Expand Down Expand Up @@ -280,7 +280,8 @@ def synchronize_projects(self, source="ayon"):
self._sg,
self.sg_enabled_entities,
self.sg_project_code_field,
self.custom_attribs_map
self.custom_attribs_map,
self.settings
)

case _:
Expand Down Expand Up @@ -338,6 +339,7 @@ def react_to_shotgrid_event(self, sg_event_meta):
self.sg_enabled_entities,
self.sg_project_code_field,
self.custom_attribs_map,
self.settings
)

case "attribute_change":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ def match_ayon_hierarchy_in_shotgrid(
)
continue
elif sg_entity_id:
# convert sg_entity_id to int if exists
sg_entity_id = int(sg_entity_id)

if sg_entity_type == "AssetCategory":
Expand Down
Loading

0 comments on commit f828cb5

Please sign in to comment.