From dbcb8f63e36f8813029a7da25650bb1dfa361875 Mon Sep 17 00:00:00 2001 From: Petr Kalis Date: Mon, 21 Feb 2022 13:55:24 +0100 Subject: [PATCH 1/4] OP-2642 - added subset filter to limit Slack notifications --- .../standalonepublisher/plugins/publish/collect_texture.py | 3 +++ .../modules/slack/plugins/publish/collect_slack_family.py | 7 ++++++- openpype/settings/defaults/project_settings/slack.json | 1 + .../schemas/projects_schema/schema_project_slack.json | 6 ++++++ 4 files changed, 16 insertions(+), 1 deletion(-) diff --git a/openpype/hosts/standalonepublisher/plugins/publish/collect_texture.py b/openpype/hosts/standalonepublisher/plugins/publish/collect_texture.py index 596a8ccfd2..d318070fbc 100644 --- a/openpype/hosts/standalonepublisher/plugins/publish/collect_texture.py +++ b/openpype/hosts/standalonepublisher/plugins/publish/collect_texture.py @@ -411,9 +411,11 @@ class CollectTextures(pyblish.api.ContextPlugin): Raises: ValueError - if broken 'input_naming_groups' """ + self.log.info("{} {} {}".format(name, input_naming_patterns, input_naming_groups)) for input_pattern in input_naming_patterns: for cs in color_spaces: pattern = input_pattern.replace('{color_space}', cs) + self.log.info("{} {}".format(pattern, name)) regex_result = re.findall(pattern, name) if regex_result: idx = list(input_naming_groups).index(key) @@ -424,6 +426,7 @@ class CollectTextures(pyblish.api.ContextPlugin): try: parsed_value = regex_result[0][idx] + self.log.info("par{}".format(parsed_value)) return parsed_value except IndexError: self.log.warning("Wrong index, probably " diff --git a/openpype/modules/slack/plugins/publish/collect_slack_family.py b/openpype/modules/slack/plugins/publish/collect_slack_family.py index 2110c0703b..6c965b04cd 100644 --- a/openpype/modules/slack/plugins/publish/collect_slack_family.py +++ b/openpype/modules/slack/plugins/publish/collect_slack_family.py @@ -20,18 +20,23 @@ class CollectSlackFamilies(pyblish.api.InstancePlugin): def process(self, instance): task_name = io.Session.get("AVALON_TASK") family = self.main_family_from_instance(instance) - key_values = { "families": family, "tasks": task_name, "hosts": instance.data["anatomyData"]["app"], + "subsets": instance.data["subset"] } profile = filter_profiles(self.profiles, key_values, logger=self.log) + if not profile: + self.log.info("No profile found, notification won't be send") + return + # make slack publishable if profile: + self.log.info("Found profile: {}".format(profile)) if instance.data.get('families'): instance.data['families'].append('slack') else: diff --git a/openpype/settings/defaults/project_settings/slack.json b/openpype/settings/defaults/project_settings/slack.json index 2d10bd173d..d77b8c2208 100644 --- a/openpype/settings/defaults/project_settings/slack.json +++ b/openpype/settings/defaults/project_settings/slack.json @@ -10,6 +10,7 @@ "hosts": [], "task_types": [], "tasks": [], + "subsets": [], "channel_messages": [] } ] diff --git a/openpype/settings/entities/schemas/projects_schema/schema_project_slack.json b/openpype/settings/entities/schemas/projects_schema/schema_project_slack.json index 4e82c991e7..14814d8b01 100644 --- a/openpype/settings/entities/schemas/projects_schema/schema_project_slack.json +++ b/openpype/settings/entities/schemas/projects_schema/schema_project_slack.json @@ -69,6 +69,12 @@ "type": "list", "object_type": "text" }, + { + "key": "subsets", + "label": "Subset names", + "type": "list", + "object_type": "text" + }, { "type": "separator" }, From 5b85dff95a323813604e927b4ed3c5428b074097 Mon Sep 17 00:00:00 2001 From: Petr Kalis Date: Mon, 21 Feb 2022 15:17:58 +0100 Subject: [PATCH 2/4] OP-2642 - added subset filter to limit Slack notifications --- website/docs/module_slack.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/docs/module_slack.md b/website/docs/module_slack.md index 67b200259d..3a2842da63 100644 --- a/website/docs/module_slack.md +++ b/website/docs/module_slack.md @@ -47,7 +47,7 @@ It is possible to create multiple tokens and configure different scopes for them ### Profiles Profiles are used to select when to trigger notification. One or multiple profiles -could be configured, `Families`, `Task names` (regex available), `Host names` combination is needed. +could be configured, `Families`, `Task names` (regex available), `Host names`, `Subset names` (regex available) combination is needed. Eg. If I want to be notified when render is published from Maya, setting is: From 592cf54a976f4eab3a86987adbd23249fa0aa4e7 Mon Sep 17 00:00:00 2001 From: Petr Kalis Date: Mon, 21 Feb 2022 16:13:53 +0100 Subject: [PATCH 3/4] OP-2642 - revert of unwanted logs --- .../standalonepublisher/plugins/publish/collect_texture.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/openpype/hosts/standalonepublisher/plugins/publish/collect_texture.py b/openpype/hosts/standalonepublisher/plugins/publish/collect_texture.py index d318070fbc..3b7343e685 100644 --- a/openpype/hosts/standalonepublisher/plugins/publish/collect_texture.py +++ b/openpype/hosts/standalonepublisher/plugins/publish/collect_texture.py @@ -411,7 +411,6 @@ class CollectTextures(pyblish.api.ContextPlugin): Raises: ValueError - if broken 'input_naming_groups' """ - self.log.info("{} {} {}".format(name, input_naming_patterns, input_naming_groups)) for input_pattern in input_naming_patterns: for cs in color_spaces: pattern = input_pattern.replace('{color_space}', cs) @@ -426,7 +425,6 @@ class CollectTextures(pyblish.api.ContextPlugin): try: parsed_value = regex_result[0][idx] - self.log.info("par{}".format(parsed_value)) return parsed_value except IndexError: self.log.warning("Wrong index, probably " From 9dd492ab236bd09f44947bed51336bd5484a4d16 Mon Sep 17 00:00:00 2001 From: Petr Kalis Date: Mon, 21 Feb 2022 16:14:34 +0100 Subject: [PATCH 4/4] OP-2642 - revert of unwanted logs --- .../hosts/standalonepublisher/plugins/publish/collect_texture.py | 1 - 1 file changed, 1 deletion(-) diff --git a/openpype/hosts/standalonepublisher/plugins/publish/collect_texture.py b/openpype/hosts/standalonepublisher/plugins/publish/collect_texture.py index 3b7343e685..596a8ccfd2 100644 --- a/openpype/hosts/standalonepublisher/plugins/publish/collect_texture.py +++ b/openpype/hosts/standalonepublisher/plugins/publish/collect_texture.py @@ -414,7 +414,6 @@ class CollectTextures(pyblish.api.ContextPlugin): for input_pattern in input_naming_patterns: for cs in color_spaces: pattern = input_pattern.replace('{color_space}', cs) - self.log.info("{} {}".format(pattern, name)) regex_result = re.findall(pattern, name) if regex_result: idx = list(input_naming_groups).index(key)