From 15cfcc6998bca422099364a0a68ad0998db3b03c Mon Sep 17 00:00:00 2001 From: Petr Kalis Date: Mon, 25 Nov 2024 12:40:19 +0100 Subject: [PATCH 1/6] Fail better when no DL webservice connection Without this it throws weird Enum error. --- .../plugins/publish/global/collect_jobinfo.py | 37 +++++++++++++------ 1 file changed, 25 insertions(+), 12 deletions(-) diff --git a/client/ayon_deadline/plugins/publish/global/collect_jobinfo.py b/client/ayon_deadline/plugins/publish/global/collect_jobinfo.py index 6ac544a495..dda63b0f0e 100644 --- a/client/ayon_deadline/plugins/publish/global/collect_jobinfo.py +++ b/client/ayon_deadline/plugins/publish/global/collect_jobinfo.py @@ -16,6 +16,7 @@ from ayon_deadline.lib import ( FARM_FAMILIES, AYONDeadlineJobInfo, + DeadlineWebserviceError ) @@ -93,32 +94,44 @@ def apply_settings(cls, project_settings): addons_manager = AddonsManager(project_settings) deadline_addon = addons_manager["deadline"] deadline_server_name = settings["deadline_server"] - pools = deadline_addon.get_pools_by_server_name(deadline_server_name) + pools = groups = limit_groups = machines = [] + try: + pools = deadline_addon.get_pools_by_server_name( + deadline_server_name) + groups = deadline_addon.get_groups_by_server_name( + deadline_server_name) + limit_groups = deadline_addon.get_limit_groups_by_server_name( + deadline_server_name + ) + machines = deadline_addon.get_machines_by_server_name( + deadline_server_name + ) + except Exception: + cls.log.warning(f"Unable to connect to {deadline_server_name}") + if not pools: + pools.append("< none >") + if not groups: + groups.append("< none >") + if not limit_groups: + limit_groups.append("< none >") + if not machines: + machines.append("< none >") + cls.pool_enum_values = [ {"value": pool, "label": pool} for pool in pools ] - groups = deadline_addon.get_groups_by_server_name(deadline_server_name) cls.group_enum_values = [ {"value": group, "label": group} for group in groups ] - limit_groups = deadline_addon.get_limit_groups_by_server_name( - deadline_server_name - ) - limit_group_items = [ + cls.limit_group_enum_values = [ {"value": limit_group, "label": limit_group} for limit_group in limit_groups ] - if not limit_group_items: - limit_group_items.append({"value": None, "label": "< none >"}) - cls.limit_group_enum_values = limit_group_items - machines = deadline_addon.get_machines_by_server_name( - deadline_server_name - ) cls.machines_enum_values = [ {"value": machine, "label": machine} for machine in machines From 903060e8a7a9db7bcb8d202ed33995573fb86745 Mon Sep 17 00:00:00 2001 From: Petr Kalis Date: Mon, 25 Nov 2024 12:43:43 +0100 Subject: [PATCH 2/6] Cannot catch custom exception --- client/ayon_deadline/plugins/publish/global/collect_jobinfo.py | 1 - 1 file changed, 1 deletion(-) diff --git a/client/ayon_deadline/plugins/publish/global/collect_jobinfo.py b/client/ayon_deadline/plugins/publish/global/collect_jobinfo.py index dda63b0f0e..c55875dc84 100644 --- a/client/ayon_deadline/plugins/publish/global/collect_jobinfo.py +++ b/client/ayon_deadline/plugins/publish/global/collect_jobinfo.py @@ -16,7 +16,6 @@ from ayon_deadline.lib import ( FARM_FAMILIES, AYONDeadlineJobInfo, - DeadlineWebserviceError ) From c52d715337722785cac66a7353c55445d25b5d6d Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Mon, 25 Nov 2024 13:16:24 +0100 Subject: [PATCH 3/6] Make sure the value is None and we're working with different objects. --- .../plugins/publish/global/collect_jobinfo.py | 77 ++++++++++--------- 1 file changed, 40 insertions(+), 37 deletions(-) diff --git a/client/ayon_deadline/plugins/publish/global/collect_jobinfo.py b/client/ayon_deadline/plugins/publish/global/collect_jobinfo.py index c55875dc84..6f33ecac54 100644 --- a/client/ayon_deadline/plugins/publish/global/collect_jobinfo.py +++ b/client/ayon_deadline/plugins/publish/global/collect_jobinfo.py @@ -93,48 +93,51 @@ def apply_settings(cls, project_settings): addons_manager = AddonsManager(project_settings) deadline_addon = addons_manager["deadline"] deadline_server_name = settings["deadline_server"] - pools = groups = limit_groups = machines = [] + pools = [] + groups = [] + limit_groups = [] + machines = [] try: - pools = deadline_addon.get_pools_by_server_name( - deadline_server_name) - groups = deadline_addon.get_groups_by_server_name( - deadline_server_name) - limit_groups = deadline_addon.get_limit_groups_by_server_name( - deadline_server_name - ) - machines = deadline_addon.get_machines_by_server_name( - deadline_server_name - ) + pools = [ + {"value": pool, "label": pool} + for pool in deadline_addon.get_pools_by_server_name( + deadline_server_name + ) + ] + groups = [ + {"value": group, "label": group} + for group in deadline_addon.get_groups_by_server_name( + deadline_server_name + ) + ] + limit_groups = [ + {"value": limit_group, "label": limit_group} + for limit_group in ( + deadline_addon.get_limit_groups_by_server_name( + deadline_server_name + ) + ) + ] + machines = [ + {"value": machine, "label": machine} + for machine in deadline_addon.get_machines_by_server_name( + deadline_server_name + ) + ] + except Exception: cls.log.warning(f"Unable to connect to {deadline_server_name}") - if not pools: - pools.append("< none >") - if not groups: - groups.append("< none >") - if not limit_groups: - limit_groups.append("< none >") - if not machines: - machines.append("< none >") - - cls.pool_enum_values = [ - {"value": pool, "label": pool} - for pool in pools - ] - - cls.group_enum_values = [ - {"value": group, "label": group} - for group in groups - ] - cls.limit_group_enum_values = [ - {"value": limit_group, "label": limit_group} - for limit_group in limit_groups - ] + for items in [ + pools, groups, limit_groups, machines + ]: + if not items: + items.append({"value": None, "label": "< none >"}) - cls.machines_enum_values = [ - {"value": machine, "label": machine} - for machine in machines - ] + cls.pool_enum_values = pools + cls.group_enum_values = groups + cls.limit_group_enum_values = limit_groups + cls.machines_enum_values = machines @classmethod def get_attr_defs_for_instance(cls, create_context, instance): From f2754d0030b5817b412df2d19cf510bb90cf90cd Mon Sep 17 00:00:00 2001 From: Petr Kalis Date: Thu, 28 Nov 2024 13:35:54 +0100 Subject: [PATCH 4/6] Formatting change Co-authored-by: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> --- .../ayon_deadline/plugins/publish/global/collect_jobinfo.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/client/ayon_deadline/plugins/publish/global/collect_jobinfo.py b/client/ayon_deadline/plugins/publish/global/collect_jobinfo.py index 6f33ecac54..cf1df20653 100644 --- a/client/ayon_deadline/plugins/publish/global/collect_jobinfo.py +++ b/client/ayon_deadline/plugins/publish/global/collect_jobinfo.py @@ -126,7 +126,10 @@ def apply_settings(cls, project_settings): ] except Exception: - cls.log.warning(f"Unable to connect to {deadline_server_name}") + cls.log.warning( + f"Unable to connect to {deadline_server_name}", + exc_info=True + ) for items in [ pools, groups, limit_groups, machines From 15207463168ae102b2c31dc1251f3de0bd2cc103 Mon Sep 17 00:00:00 2001 From: Petr Kalis Date: Fri, 29 Nov 2024 10:10:43 +0100 Subject: [PATCH 5/6] Fix raising of an exception --- client/ayon_deadline/lib.py | 6 +----- .../ayon_deadline/plugins/publish/global/collect_jobinfo.py | 3 ++- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/client/ayon_deadline/lib.py b/client/ayon_deadline/lib.py index 2a5d99c433..ec5d1dcf37 100644 --- a/client/ayon_deadline/lib.py +++ b/client/ayon_deadline/lib.py @@ -173,11 +173,7 @@ def _get_deadline_info( except requests.exceptions.ConnectionError as exc: msg = 'Cannot connect to DL web service {}'.format(endpoint) log.error(msg) - raise( - DeadlineWebserviceError, - DeadlineWebserviceError('{} - {}'.format(msg, exc)), - sys.exc_info()[2] - ) + raise DeadlineWebserviceError(msg) from exc if not response.ok: log.warning(f"No {item_type} retrieved") return [] diff --git a/client/ayon_deadline/plugins/publish/global/collect_jobinfo.py b/client/ayon_deadline/plugins/publish/global/collect_jobinfo.py index 84b796d5a4..045e75b4d4 100644 --- a/client/ayon_deadline/plugins/publish/global/collect_jobinfo.py +++ b/client/ayon_deadline/plugins/publish/global/collect_jobinfo.py @@ -16,6 +16,7 @@ from ayon_deadline.lib import ( FARM_FAMILIES, AYONDeadlineJobInfo, + DeadlineWebserviceError, ) @@ -148,7 +149,7 @@ def apply_settings(cls, project_settings): ) ] - except Exception: + except DeadlineWebserviceError: cls.log.warning(f"Unable to connect to {deadline_server_name}") for items in [ From 81afc71222dbcc4ae7d4a58a7565169931c544ec Mon Sep 17 00:00:00 2001 From: Petr Kalis Date: Tue, 3 Dec 2024 14:55:18 +0100 Subject: [PATCH 6/6] Ruff --- client/ayon_deadline/lib.py | 1 - 1 file changed, 1 deletion(-) diff --git a/client/ayon_deadline/lib.py b/client/ayon_deadline/lib.py index ec5d1dcf37..6d580850b0 100644 --- a/client/ayon_deadline/lib.py +++ b/client/ayon_deadline/lib.py @@ -1,5 +1,4 @@ import os -import sys import json from dataclasses import dataclass, field, asdict from functools import partial