From 5e8aca34204e3c065217e314880ea89b2d2373af Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Mon, 3 Jun 2024 13:36:26 +0200 Subject: [PATCH 01/14] added version property to addon class --- client/ayon_core/addon/base.py | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/client/ayon_core/addon/base.py b/client/ayon_core/addon/base.py index d2c072c50c..9eb5773927 100644 --- a/client/ayon_core/addon/base.py +++ b/client/ayon_core/addon/base.py @@ -8,7 +8,7 @@ import inspect import logging import threading import collections - +import warnings from uuid import uuid4 from abc import ABCMeta, abstractmethod @@ -551,6 +551,9 @@ class AYONAddon(object): enabled = True _id = None + # Temporary variable for 'version' property + _missing_version_warned = False + def __init__(self, manager, settings): self.manager = manager @@ -581,6 +584,25 @@ class AYONAddon(object): pass + @property + def version(self): + """Addon version. + + Todo: + Should be abstract property (required). Introduced in + ayon-core 0.3.3 . + + Returns: + str: Addon version as semver compatible string. + + """ + if not self.__class__._missing_version_warned: + self.__class__._missing_version_warned = True + warnings.warn( + f"Addon '{self.name}' does not have defined version." + ) + return "0.0.0" + def initialize(self, settings): """Initialization of addon attributes. From 8f0522ac3e846cb62fb29cf6fb0059274cc60231 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Mon, 3 Jun 2024 13:36:40 +0200 Subject: [PATCH 02/14] log addon version and show it in report --- client/ayon_core/addon/base.py | 98 ++++++++++++++++++++++++---------- 1 file changed, 69 insertions(+), 29 deletions(-) diff --git a/client/ayon_core/addon/base.py b/client/ayon_core/addon/base.py index 9eb5773927..a70c1b7961 100644 --- a/client/ayon_core/addon/base.py +++ b/client/ayon_core/addon/base.py @@ -718,6 +718,30 @@ class OpenPypeAddOn(OpenPypeModule): enabled = True +class _AddonReportInfo: + def __init__( + self, class_name, name, version, report_value_by_label + ): + self.class_name = class_name + self.name = name + self.version = version + self.report_value_by_label = report_value_by_label + + @classmethod + def from_addon(cls, addon, report): + class_name = addon.__class__.__name__ + report_value_by_label = { + label: reported.get(class_name) + for label, reported in report.items() + } + return cls( + addon.__class__.__name__, + addon.name, + addon.version, + report_value_by_label + ) + + class AddonsManager: """Manager of addons that helps to load and prepare them to work. @@ -894,10 +918,10 @@ class AddonsManager: name_alias = getattr(addon, "openpype_alias", None) if name_alias: aliased_names.append((name_alias, addon)) - enabled_str = "X" - if not addon.enabled: - enabled_str = " " - self.log.debug("[{}] {}".format(enabled_str, name)) + enabled_str = "X" if addon.enabled else " " + self.log.debug( + f"[{enabled_str}] {addon.name} ({addon.version})" + ) now = time.time() report[addon.__class__.__name__] = now - prev_start_time @@ -1197,39 +1221,55 @@ class AddonsManager: available_col_names |= set(addon_names.keys()) # Prepare ordered dictionary for columns - cols = collections.OrderedDict() - # Add addon names to first columnt - cols["Addon name"] = list(sorted( - addon.__class__.__name__ + addons_info = [ + _AddonReportInfo.from_addon(addon, self._report) for addon in self.addons if addon.__class__.__name__ in available_col_names - )) + ] + addons_info.sort(key=lambda x: x.name) + + addon_name_rows = [ + addon_info.name + for addon_info in addons_info + ] + addon_version_rows = [ + addon_info.version + for addon_info in addons_info + ] + # Add total key (as last addon) - cols["Addon name"].append(self._report_total_key) + addon_name_rows.append(self._report_total_key) + addon_version_rows.append(f"({len(addons_info)})") + + cols = collections.OrderedDict() + # Add addon names to first columnt + cols["Addon name"] = addon_name_rows + cols["Version"] = addon_version_rows # Add columns from report + total_by_addon = { + row: 0 + for row in addon_name_rows + } for label in self._report.keys(): - cols[label] = [] - - total_addon_times = {} - for addon_name in cols["Addon name"]: - total_addon_times[addon_name] = 0 - - for label, reported in self._report.items(): - for addon_name in cols["Addon name"]: - col_time = reported.get(addon_name) - if col_time is None: - cols[label].append("N/A") + rows = [] + col_total = 0 + for addon_info in addons_info: + value = addon_info.report_value_by_label.get(label) + if value is None: + rows.append("N/A") continue - cols[label].append("{:.3f}".format(col_time)) - total_addon_times[addon_name] += col_time - + rows.append("{:.3f}".format(value)) + total_by_addon[addon_info.name] += value + col_total += value + total_by_addon[self._report_total_key] += col_total + rows.append("{:.3f}".format(col_total)) + cols[label] = rows # Add to also total column that should sum the row - cols[self._report_total_key] = [] - for addon_name in cols["Addon name"]: - cols[self._report_total_key].append( - "{:.3f}".format(total_addon_times[addon_name]) - ) + cols[self._report_total_key] = [ + "{:.3f}".format(total_by_addon[addon_name]) + for addon_name in cols["Addon name"] + ] # Prepare column widths and total row count # - column width is by From 3e9c08205ee83d1b4006c9f25d3f3bd50c62d03a Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Mon, 3 Jun 2024 13:40:18 +0200 Subject: [PATCH 03/14] added version to job queue --- client/ayon_core/modules/job_queue/__init__.py | 3 +++ client/ayon_core/modules/job_queue/addon.py | 3 +++ client/ayon_core/modules/job_queue/version.py | 1 + 3 files changed, 7 insertions(+) create mode 100644 client/ayon_core/modules/job_queue/version.py diff --git a/client/ayon_core/modules/job_queue/__init__.py b/client/ayon_core/modules/job_queue/__init__.py index 0a4c62abfb..041782dd29 100644 --- a/client/ayon_core/modules/job_queue/__init__.py +++ b/client/ayon_core/modules/job_queue/__init__.py @@ -1,6 +1,9 @@ +from .version import __version__ from .addon import JobQueueAddon __all__ = ( + "__version__", + "JobQueueAddon", ) diff --git a/client/ayon_core/modules/job_queue/addon.py b/client/ayon_core/modules/job_queue/addon.py index 0fa54eb2f0..96f6ff0d4d 100644 --- a/client/ayon_core/modules/job_queue/addon.py +++ b/client/ayon_core/modules/job_queue/addon.py @@ -44,9 +44,12 @@ import platform from ayon_core.addon import AYONAddon, click_wrap from ayon_core.settings import get_studio_settings +from .version import __version__ + class JobQueueAddon(AYONAddon): name = "job_queue" + version = __version__ def initialize(self, studio_settings): addon_settings = studio_settings.get(self.name) or {} diff --git a/client/ayon_core/modules/job_queue/version.py b/client/ayon_core/modules/job_queue/version.py new file mode 100644 index 0000000000..5becc17c04 --- /dev/null +++ b/client/ayon_core/modules/job_queue/version.py @@ -0,0 +1 @@ +__version__ = "1.0.0" From b7e2b83efce5ee9f5d2c22a03f4fe3562f230acd Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Mon, 3 Jun 2024 13:40:29 +0200 Subject: [PATCH 04/14] added version to timers manager --- client/ayon_core/modules/timers_manager/__init__.py | 3 +++ client/ayon_core/modules/timers_manager/timers_manager.py | 2 ++ client/ayon_core/modules/timers_manager/version.py | 1 + 3 files changed, 6 insertions(+) create mode 100644 client/ayon_core/modules/timers_manager/version.py diff --git a/client/ayon_core/modules/timers_manager/__init__.py b/client/ayon_core/modules/timers_manager/__init__.py index 5d7a4166d3..1ec0d9b74b 100644 --- a/client/ayon_core/modules/timers_manager/__init__.py +++ b/client/ayon_core/modules/timers_manager/__init__.py @@ -1,7 +1,10 @@ +from .version import __version__ from .timers_manager import ( TimersManager ) __all__ = ( + "__version__", + "TimersManager", ) diff --git a/client/ayon_core/modules/timers_manager/timers_manager.py b/client/ayon_core/modules/timers_manager/timers_manager.py index 4212ff6b25..2aac7b2a49 100644 --- a/client/ayon_core/modules/timers_manager/timers_manager.py +++ b/client/ayon_core/modules/timers_manager/timers_manager.py @@ -10,6 +10,7 @@ from ayon_core.addon import ( ) from ayon_core.lib.events import register_event_callback +from .version import __version__ from .exceptions import InvalidContextError TIMER_MODULE_DIR = os.path.dirname(os.path.abspath(__file__)) @@ -96,6 +97,7 @@ class TimersManager( See `ExampleTimersManagerConnector`. """ name = "timers_manager" + version = __version__ label = "Timers Service" _required_methods = ( diff --git a/client/ayon_core/modules/timers_manager/version.py b/client/ayon_core/modules/timers_manager/version.py new file mode 100644 index 0000000000..5becc17c04 --- /dev/null +++ b/client/ayon_core/modules/timers_manager/version.py @@ -0,0 +1 @@ +__version__ = "1.0.0" From 090208d8bc1cd2653487babb9d0af19820fd1362 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Mon, 3 Jun 2024 13:43:05 +0200 Subject: [PATCH 05/14] fix timers manager version --- client/ayon_core/modules/timers_manager/version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/ayon_core/modules/timers_manager/version.py b/client/ayon_core/modules/timers_manager/version.py index 5becc17c04..485f44ac21 100644 --- a/client/ayon_core/modules/timers_manager/version.py +++ b/client/ayon_core/modules/timers_manager/version.py @@ -1 +1 @@ -__version__ = "1.0.0" +__version__ = "0.1.1" From 75f55101f8a70bc09106813ab8a1054fc2ab2cbb Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Mon, 3 Jun 2024 13:43:24 +0200 Subject: [PATCH 06/14] added version to webserver --- client/ayon_core/modules/webserver/__init__.py | 3 +++ client/ayon_core/modules/webserver/version.py | 1 + client/ayon_core/modules/webserver/webserver_module.py | 3 +++ 3 files changed, 7 insertions(+) create mode 100644 client/ayon_core/modules/webserver/version.py diff --git a/client/ayon_core/modules/webserver/__init__.py b/client/ayon_core/modules/webserver/__init__.py index 0d3f767638..a978b94bc4 100644 --- a/client/ayon_core/modules/webserver/__init__.py +++ b/client/ayon_core/modules/webserver/__init__.py @@ -1,8 +1,11 @@ +from .version import __version__ from .webserver_module import ( WebServerAddon ) __all__ = ( + "__version__", + "WebServerAddon", ) diff --git a/client/ayon_core/modules/webserver/version.py b/client/ayon_core/modules/webserver/version.py new file mode 100644 index 0000000000..5becc17c04 --- /dev/null +++ b/client/ayon_core/modules/webserver/version.py @@ -0,0 +1 @@ +__version__ = "1.0.0" diff --git a/client/ayon_core/modules/webserver/webserver_module.py b/client/ayon_core/modules/webserver/webserver_module.py index c324e0dd18..997b6f754c 100644 --- a/client/ayon_core/modules/webserver/webserver_module.py +++ b/client/ayon_core/modules/webserver/webserver_module.py @@ -26,9 +26,12 @@ import socket from ayon_core import resources from ayon_core.addon import AYONAddon, ITrayService +from .version import __version__ + class WebServerAddon(AYONAddon, ITrayService): name = "webserver" + version = __version__ label = "WebServer" webserver_url_env = "AYON_WEBSERVER_URL" From c687ec7430497ab7fd306cf03830d1784e5bebff Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Mon, 3 Jun 2024 13:43:59 +0200 Subject: [PATCH 07/14] use version in deadline addon --- client/ayon_core/modules/deadline/deadline_module.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/client/ayon_core/modules/deadline/deadline_module.py b/client/ayon_core/modules/deadline/deadline_module.py index b1089bbfe2..ea0350d2d9 100644 --- a/client/ayon_core/modules/deadline/deadline_module.py +++ b/client/ayon_core/modules/deadline/deadline_module.py @@ -7,6 +7,8 @@ import six from ayon_core.lib import Logger from ayon_core.modules import AYONAddon, IPluginPaths +from .version import __version__ + class DeadlineWebserviceError(Exception): """ @@ -16,6 +18,7 @@ class DeadlineWebserviceError(Exception): class DeadlineModule(AYONAddon, IPluginPaths): name = "deadline" + version = __version__ def initialize(self, studio_settings): # This module is always enabled From 1bf0421e7af8104c89ffe21c3cdd99e1d708c2bd Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Mon, 3 Jun 2024 13:44:09 +0200 Subject: [PATCH 08/14] define version if actions --- client/ayon_core/modules/launcher_action.py | 1 + client/ayon_core/modules/loader_action.py | 1 + 2 files changed, 2 insertions(+) diff --git a/client/ayon_core/modules/launcher_action.py b/client/ayon_core/modules/launcher_action.py index 38e88d36ca..344b0bc389 100644 --- a/client/ayon_core/modules/launcher_action.py +++ b/client/ayon_core/modules/launcher_action.py @@ -7,6 +7,7 @@ from ayon_core.addon import AYONAddon, ITrayAction class LauncherAction(AYONAddon, ITrayAction): label = "Launcher" name = "launcher_tool" + version = "1.0.0" def initialize(self, settings): diff --git a/client/ayon_core/modules/loader_action.py b/client/ayon_core/modules/loader_action.py index 1e45db05dc..a58d7fd456 100644 --- a/client/ayon_core/modules/loader_action.py +++ b/client/ayon_core/modules/loader_action.py @@ -3,6 +3,7 @@ from ayon_core.addon import AYONAddon, ITrayAddon class LoaderAddon(AYONAddon, ITrayAddon): name = "loader_tool" + version = "1.0.0" def initialize(self, settings): # Tray attributes From 8e27a2238d3474c3f394422328206425e85e4454 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Mon, 3 Jun 2024 13:45:50 +0200 Subject: [PATCH 09/14] added version to royal render --- client/ayon_core/modules/royalrender/__init__.py | 3 +++ client/ayon_core/modules/royalrender/addon.py | 3 +++ client/ayon_core/modules/royalrender/version.py | 1 + 3 files changed, 7 insertions(+) create mode 100644 client/ayon_core/modules/royalrender/version.py diff --git a/client/ayon_core/modules/royalrender/__init__.py b/client/ayon_core/modules/royalrender/__init__.py index 121530beda..8bf207e7db 100644 --- a/client/ayon_core/modules/royalrender/__init__.py +++ b/client/ayon_core/modules/royalrender/__init__.py @@ -1,6 +1,9 @@ +from .version import __version__ from .addon import RoyalRenderAddon __all__ = ( + "__version__", + "RoyalRenderAddon", ) diff --git a/client/ayon_core/modules/royalrender/addon.py b/client/ayon_core/modules/royalrender/addon.py index e69cf9feec..264d3516c1 100644 --- a/client/ayon_core/modules/royalrender/addon.py +++ b/client/ayon_core/modules/royalrender/addon.py @@ -4,10 +4,13 @@ import os from ayon_core.addon import AYONAddon, IPluginPaths +from .version import __version__ + class RoyalRenderAddon(AYONAddon, IPluginPaths): """Class providing basic Royal Render implementation logic.""" name = "royalrender" + version = __version__ # _rr_api = None # @property diff --git a/client/ayon_core/modules/royalrender/version.py b/client/ayon_core/modules/royalrender/version.py new file mode 100644 index 0000000000..485f44ac21 --- /dev/null +++ b/client/ayon_core/modules/royalrender/version.py @@ -0,0 +1 @@ +__version__ = "0.1.1" From 807e931d0a9513ed79c4bf970332ecd5468c1241 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Mon, 3 Jun 2024 13:46:04 +0200 Subject: [PATCH 10/14] added version to python console action --- client/ayon_core/modules/python_console_interpreter/addon.py | 1 + 1 file changed, 1 insertion(+) diff --git a/client/ayon_core/modules/python_console_interpreter/addon.py b/client/ayon_core/modules/python_console_interpreter/addon.py index ffad3ce707..b0dce2585e 100644 --- a/client/ayon_core/modules/python_console_interpreter/addon.py +++ b/client/ayon_core/modules/python_console_interpreter/addon.py @@ -4,6 +4,7 @@ from ayon_core.addon import AYONAddon, ITrayAction class PythonInterpreterAction(AYONAddon, ITrayAction): label = "Console" name = "python_interpreter" + version = "1.0.0" admin_action = True def initialize(self, settings): From 8ae140fc6cfb70f1e6d19a311e3f4355c47ca3a5 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Mon, 3 Jun 2024 13:47:20 +0200 Subject: [PATCH 11/14] change warning to print --- client/ayon_core/addon/base.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/client/ayon_core/addon/base.py b/client/ayon_core/addon/base.py index a70c1b7961..bbefc4ca1d 100644 --- a/client/ayon_core/addon/base.py +++ b/client/ayon_core/addon/base.py @@ -8,7 +8,6 @@ import inspect import logging import threading import collections -import warnings from uuid import uuid4 from abc import ABCMeta, abstractmethod @@ -598,8 +597,9 @@ class AYONAddon(object): """ if not self.__class__._missing_version_warned: self.__class__._missing_version_warned = True - warnings.warn( - f"Addon '{self.name}' does not have defined version." + print( + f"DEV WARNING: Addon '{self.name}' does not have" + f" defined version." ) return "0.0.0" From e531b94981b76b91197c3590cfd1c5d90a503880 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Mon, 3 Jun 2024 13:49:34 +0200 Subject: [PATCH 12/14] make sure '_initializing_addons' is set to 'False' --- client/ayon_core/tools/tray/tray.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/client/ayon_core/tools/tray/tray.py b/client/ayon_core/tools/tray/tray.py index 957518afe4..eca87eb11d 100644 --- a/client/ayon_core/tools/tray/tray.py +++ b/client/ayon_core/tools/tray/tray.py @@ -447,8 +447,10 @@ class SystemTrayIcon(QtWidgets.QSystemTrayIcon): def initialize_addons(self): self._initializing_addons = True - self.tray_man.initialize_addons() - self._initializing_addons = False + try: + self.tray_man.initialize_addons() + finally: + self._initializing_addons = False def _click_timer_timeout(self): self._click_timer.stop() From 33bd9a82eb3fef006bb549c6f0a36f8a4e9d05c8 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Mon, 3 Jun 2024 16:56:58 +0200 Subject: [PATCH 13/14] log addons alphabetically --- client/ayon_core/addon/base.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/client/ayon_core/addon/base.py b/client/ayon_core/addon/base.py index bbefc4ca1d..87c40b096c 100644 --- a/client/ayon_core/addon/base.py +++ b/client/ayon_core/addon/base.py @@ -918,10 +918,6 @@ class AddonsManager: name_alias = getattr(addon, "openpype_alias", None) if name_alias: aliased_names.append((name_alias, addon)) - enabled_str = "X" if addon.enabled else " " - self.log.debug( - f"[{enabled_str}] {addon.name} ({addon.version})" - ) now = time.time() report[addon.__class__.__name__] = now - prev_start_time @@ -933,6 +929,13 @@ class AddonsManager: exc_info=True ) + for addon_name in sorted(self._addons_by_name.keys()): + addon = self._addons_by_name[addon_name] + enabled_str = "X" if addon.enabled else " " + self.log.debug( + f"[{enabled_str}] {addon.name} ({addon.version})" + ) + for item in aliased_names: name_alias, addon = item if name_alias not in self._addons_by_name: From 91edccbd703154e23692998ba3f453f0e58efae9 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Mon, 3 Jun 2024 17:15:46 +0200 Subject: [PATCH 14/14] fix indentation --- client/ayon_core/addon/base.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/client/ayon_core/addon/base.py b/client/ayon_core/addon/base.py index 3fbba6c619..13f1550e6e 100644 --- a/client/ayon_core/addon/base.py +++ b/client/ayon_core/addon/base.py @@ -930,12 +930,12 @@ class AddonsManager: exc_info=True ) - for addon_name in sorted(self._addons_by_name.keys()): - addon = self._addons_by_name[addon_name] - enabled_str = "X" if addon.enabled else " " - self.log.debug( - f"[{enabled_str}] {addon.name} ({addon.version})" - ) + for addon_name in sorted(self._addons_by_name.keys()): + addon = self._addons_by_name[addon_name] + enabled_str = "X" if addon.enabled else " " + self.log.debug( + f"[{enabled_str}] {addon.name} ({addon.version})" + ) for item in aliased_names: name_alias, addon = item