Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Publisher: filter creators based on task #560

Merged
merged 41 commits into from
Jun 10, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
ddd998f
AY-5539 - new Settings for filtering of creators
kalisp May 28, 2024
cd11db2
AY-5539 - use configured profiles to filter creators
kalisp May 28, 2024
2cf7f36
AY-5539 - do not use profiles for traypublisher
kalisp May 28, 2024
ce13e2e
AY-5539 - provide better method signature
kalisp May 28, 2024
170b1ab
Fix default factory
kalisp May 29, 2024
ea626e1
Fix formatting
kalisp May 29, 2024
34041b3
Fix formatting
kalisp May 29, 2024
5e95565
Fix formatting
kalisp May 29, 2024
1ac4223
Merge branch 'develop' of https://github.com/ynput/ayon-core into enh…
kalisp May 29, 2024
e074268
Merge remote-tracking branch 'origin/enhancement/AY-5539_define-creat…
kalisp May 29, 2024
719e5aa
AY-5539 - remove explicit check for traypublisher
kalisp May 29, 2024
3c287e1
AY-5539 - added project settings to CreatorContext
kalisp May 29, 2024
cafb4c9
Use host_names in Settings
kalisp May 29, 2024
e899dd0
AY-5539 - changed value from Settings
kalisp May 29, 2024
2cdb980
Merge remote-tracking branch 'origin/enhancement/AY-5539_define-creat…
kalisp May 29, 2024
62f43bf
Merge branch 'develop' of https://github.com/ynput/ayon-core into enh…
kalisp May 30, 2024
63a2e8f
AY-5539 - removed get_current_task_entity
kalisp May 30, 2024
4d812df
AY-5539 - reset project_setting when necessary
kalisp May 30, 2024
7b6f8d2
AY-5539 - use internal method for settings
kalisp May 30, 2024
739d459
CreateContext has methods to get folder & task entity and task type
iLLiCiTiT May 30, 2024
ec0327f
use new method in publish controller
iLLiCiTiT May 30, 2024
6e2cdf3
'_get_allowed_creator_identifiers' does not expect any arguments
iLLiCiTiT May 30, 2024
8eb1c89
Merge branch 'develop' of https://github.com/ynput/ayon-core into enh…
kalisp May 30, 2024
b83f8b8
Merge remote-tracking branch 'origin/enhancement/AY-5539_define-creat…
kalisp May 30, 2024
31c2d7e
removed unused import
iLLiCiTiT May 30, 2024
3ffc19c
Merge branch 'develop' of https://github.com/ynput/ayon-core into enh…
kalisp May 31, 2024
96c11e6
AY-5539 - used labels instead of identifiers
kalisp May 31, 2024
5a31435
AY-5539 - support regex in creator label
kalisp May 31, 2024
2794190
AY-5539 - added logging on profile match
kalisp May 31, 2024
0e4918d
Merge remote-tracking branch 'origin/enhancement/AY-5539_define-creat…
kalisp May 31, 2024
d2d05f6
Updated description
kalisp May 31, 2024
0fe6526
AY-5539 - possible speedup of resolution
kalisp May 31, 2024
0fa9041
AY-5539 - update resolution logic
kalisp Jun 3, 2024
c7f0e97
AY-5539 - refactor variable position
kalisp Jun 3, 2024
4e07b75
AY-5539 - fix wrong logic
kalisp Jun 3, 2024
577da3f
AY-5539 - protect from empty field in Settings
kalisp Jun 3, 2024
dd02631
AY-5539 - do only single re compile
kalisp Jun 3, 2024
cbc0516
AY-5539 - refactor argument name
kalisp Jun 6, 2024
909d6e7
AY-5539 - refactor name of method
kalisp Jun 6, 2024
4640f26
Merge branch 'develop' into enhancement/AY-5539_define-creators-per-task
kalisp Jun 7, 2024
e6fed33
Merge branch 'develop' into enhancement/AY-5539_define-creators-per-task
kalisp Jun 10, 2024
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
53 changes: 53 additions & 0 deletions client/ayon_core/tools/publisher/control.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@
)
from ayon_core.pipeline.publish import get_publish_instance_label
from ayon_core.tools.common_models import HierarchyModel
from ayon_core.settings import get_project_settings
from ayon_core.lib.profiles_filtering import filter_profiles
from ayon_core.pipeline.context_tools import get_current_task_entity

# Define constant for plugin orders offset
PLUGIN_ORDER_OFFSET = 0.5
Expand Down Expand Up @@ -1827,8 +1830,19 @@ def _reset_plugins(self):
def _collect_creator_items(self):
# TODO add crashed initialization of create plugins to report
output = {}
allowed_creator_identifiers = self._get_allowed_creator_identifiers(
self.project_name,
self._create_context.host_name,
self.current_task_name,
get_current_task_entity()["taskType"],
kalisp marked this conversation as resolved.
Show resolved Hide resolved
self.log
)
for identifier, creator in self._create_context.creators.items():
try:
if (allowed_creator_identifiers and
identifier not in allowed_creator_identifiers):
kalisp marked this conversation as resolved.
Show resolved Hide resolved
self.log.debug(f"{identifier} not allowed for context")
continue
output[identifier] = CreatorItem.from_creator(creator)
except Exception:
self.log.error(
Expand All @@ -1839,6 +1853,45 @@ def _collect_creator_items(self):

return output

def _get_allowed_creator_identifiers(
self,
project_name,
host_name,
task_name,
task_type,
log=None
kalisp marked this conversation as resolved.
Show resolved Hide resolved
):
kalisp marked this conversation as resolved.
Show resolved Hide resolved
"""Provide configured creator identifier in this context

If no profile provided for current context, it shows all creators
"""
allowed_creator_identifiers = []
if host_name == "traypublisher":
# no real context known
return allowed_creator_identifiers
kalisp marked this conversation as resolved.
Show resolved Hide resolved
proj_settings = get_project_settings(project_name)
kalisp marked this conversation as resolved.
Show resolved Hide resolved
filter_creator_profiles = (
proj_settings
["core"]
["tools"]
["creator"]
["filter_creator_profiles"]
iLLiCiTiT marked this conversation as resolved.
Show resolved Hide resolved
)
filtering_criteria = {
"task_names": task_name,
"task_types": task_type,
"hosts": host_name
}
profile = filter_profiles(
filter_creator_profiles,
filtering_criteria,
logger=log
)

kalisp marked this conversation as resolved.
Show resolved Hide resolved
if profile:
allowed_creator_identifiers = profile["creator_identifiers"]
return allowed_creator_identifiers

def _reset_instances(self):
"""Reset create instances."""
if self._resetting_instances:
Expand Down
24 changes: 23 additions & 1 deletion server/settings/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,22 @@ class ProductNameProfile(BaseSettingsModel):
template: str = SettingsField("", title="Template")


class FilterCreatorProfile(BaseSettingsModel):
kalisp marked this conversation as resolved.
Show resolved Hide resolved
"""Provide list of allowed Creator identifiers for context"""

_layout = "expanded"
hosts: list[str] = SettingsField(default_factory=list, title="Hosts")
kalisp marked this conversation as resolved.
Show resolved Hide resolved
task_types: list[str] = SettingsField(
default_factory=list,
title="Task types",
enum_resolver=task_types_enum
)
task_names: list[str] = SettingsField(default_factory=list,
title="Task names")
kalisp marked this conversation as resolved.
Show resolved Hide resolved
creator_identifiers: list[str] = SettingsField(
"", title="Allowed Creator Identifiers")
kalisp marked this conversation as resolved.
Show resolved Hide resolved


class CreatorToolModel(BaseSettingsModel):
# TODO this was dynamic dictionary '{name: task_names}'
product_types_smart_select: list[ProductTypeSmartSelectModel] = (
Expand All @@ -48,6 +64,11 @@ class CreatorToolModel(BaseSettingsModel):
title="Product name profiles"
)

filter_creator_profiles: list[FilterCreatorProfile] = SettingsField(
default_factory=list,
title="Filter creator profiles"
)

@validator("product_types_smart_select")
def validate_unique_name(cls, value):
ensure_unique_names(value)
Expand Down Expand Up @@ -404,7 +425,8 @@ class GlobalToolsModel(BaseSettingsModel):
"tasks": [],
"template": "SK_{folder[name]}{variant}"
}
]
],
"filter_creator_profiles": []
},
"Workfiles": {
"workfile_template_profiles": [
Expand Down
Loading