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 7 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
30 changes: 20 additions & 10 deletions client/ayon_core/tools/publisher/control.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import shutil
import inspect
from abc import ABCMeta, abstractmethod
import re

import six
import arrow
Expand Down Expand Up @@ -1837,14 +1838,15 @@ 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()
allowed_creator_labels = self._get_allowed_creator_labels()
for identifier, creator in self._create_context.creators.items():
try:
if (
allowed_creator_identifiers is not None
and identifier not in allowed_creator_identifiers
allowed_creator_labels is not None
kalisp marked this conversation as resolved.
Show resolved Hide resolved
and not self._label_matches_allowed(
creator.label, allowed_creator_labels)
):
self.log.debug(f"{identifier} not allowed for context")
self.log.debug(f"{creator.label} not allowed for context")
continue
output[identifier] = CreatorItem.from_creator(creator)
except Exception:
Expand All @@ -1856,16 +1858,16 @@ def _collect_creator_items(self):

return output

def _get_allowed_creator_identifiers(self):
"""Provide configured creator identifier in this context
def _get_allowed_creator_labels(self):
"""Provide configured creator label in this context

If no profile provided for current context, it shows all creators
If no profile matches current context, it shows all creators
"""

task_type = self._create_context.get_current_task_type()
project_settings = self._get_current_project_settings()

allowed_creator_identifiers = None
allowed_creator_labels = None
kalisp marked this conversation as resolved.
Show resolved Hide resolved
filter_creator_profiles = (
project_settings
["core"]
Expand All @@ -1885,8 +1887,16 @@ def _get_allowed_creator_identifiers(self):
)

kalisp marked this conversation as resolved.
Show resolved Hide resolved
if profile:
allowed_creator_identifiers = profile["creator_identifiers"]
return allowed_creator_identifiers
allowed_creator_labels = profile["creator_labels"]
self.log.debug(f"Only allowed `{allowed_creator_labels}` creators")
return allowed_creator_labels

def _label_matches_allowed(self, label, allowed_labels):
"""Implement regex support for allowed labels."""
for allowed in allowed_labels:
if re.match(allowed, label):
return True
kalisp marked this conversation as resolved.
Show resolved Hide resolved
return False

def _reset_instances(self):
"""Reset create instances."""
Expand Down
10 changes: 7 additions & 3 deletions server/settings/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,11 @@ class FilterCreatorProfile(BaseSettingsModel):
task_names: list[str] = SettingsField(
default_factory=list,
title="Task names")
creator_identifiers: list[str] = SettingsField(
creator_labels: list[str] = SettingsField(
default_factory=list,
title="Allowed Creator Identifiers")
title="Allowed Creator Labels",
description="Copy creator label from Publisher, regex supported."
)
kalisp marked this conversation as resolved.
Show resolved Hide resolved


class CreatorToolModel(BaseSettingsModel):
Expand All @@ -70,7 +72,9 @@ class CreatorToolModel(BaseSettingsModel):

filter_creator_profiles: list[FilterCreatorProfile] = SettingsField(
default_factory=list,
title="Filter creator profiles"
title="Filter creator profiles",
description="White list of creator labels that will be only shown if "
kalisp marked this conversation as resolved.
Show resolved Hide resolved
"profile matches context."
)

@validator("product_types_smart_select")
Expand Down