From 03a3a1180b9bf236502223f8c5176e4921285c44 Mon Sep 17 00:00:00 2001 From: Roy Nieterau Date: Fri, 18 Oct 2024 16:08:01 +0200 Subject: [PATCH 1/7] Make LakeFS distribution of USD Libs and AYON USD Resolver optional + Remove the experimental checkbox, which is now the "enable" button on the LakeFS distribution section. + Cleanup setting titles/docstrings --- client/ayon_usd/addon.py | 60 ++++++++++------------ client/ayon_usd/hooks/pre_resolver_init.py | 26 ++++++---- server/settings/main.py | 40 +++++++-------- 3 files changed, 63 insertions(+), 63 deletions(-) diff --git a/client/ayon_usd/addon.py b/client/ayon_usd/addon.py index e646900..563564a 100644 --- a/client/ayon_usd/addon.py +++ b/client/ayon_usd/addon.py @@ -38,16 +38,6 @@ def tray_init(self): def initialize(self, studio_settings): """Initialize USD Addon.""" - if not studio_settings["usd"]["allow_addon_start"]: - self.log.error( - "The experimental AYON USD addon is currently activated, " - "but you haven't yet acknowledged the user agreement " - "indicating your understanding that this feature is " - "experimental. Please go to the Studio Settings and " - "check the agreement checkbox. The AYON USD addon will now " - "be disabled" - ) - self.enabled = False self._download_window = None def tray_start(self): @@ -55,6 +45,32 @@ def tray_start(self): Download USD if needed. """ + self._download_global_lakefs_binaries() + + def tray_exit(self): + """Exit tray module.""" + pass + + def tray_menu(self, tray_menu): + """Add menu items to tray menu.""" + pass + + def get_launch_hook_paths(self): + """Get paths to launch hooks.""" + return [os.path.join(USD_ADDON_DIR, "hooks")] + + def get_plugin_paths(self): + return { + "publish": [ + os.path.join(USD_ADDON_DIR, "plugins", "publish") + ] + } + + def _download_global_lakefs_binaries(self): + settings = get_studio_settings() + if not settings["usd"]["lakefs"].get("enabled", False): + self.log.info("USD LakeFS binary distribution is disabled.") + return os.makedirs(DOWNLOAD_DIR, exist_ok=True) @@ -66,9 +82,8 @@ def tray_start(self): } json.dump(init_data, json_file) - settings = get_studio_settings() if not utils.is_usd_lib_download_needed(settings): - print("usd is already downloaded") + self.log.info("USD Libs already available. Skipping download.") return lake_fs_usd_lib_path = config.get_lakefs_usdlib_path(settings) @@ -133,23 +148,4 @@ def tray_start(self): ) download_ui.setStyleSheet(style.load_stylesheet()) download_ui.start() - self._download_window = download_ui - - def tray_exit(self): - """Exit tray module.""" - pass - - def tray_menu(self, tray_menu): - """Add menu items to tray menu.""" - pass - - def get_launch_hook_paths(self): - """Get paths to launch hooks.""" - return [os.path.join(USD_ADDON_DIR, "hooks")] - - def get_plugin_paths(self): - return { - "publish": [ - os.path.join(USD_ADDON_DIR, "plugins", "publish") - ] - } + self._download_window = download_ui \ No newline at end of file diff --git a/client/ayon_usd/hooks/pre_resolver_init.py b/client/ayon_usd/hooks/pre_resolver_init.py index 547aa78..d31860a 100644 --- a/client/ayon_usd/hooks/pre_resolver_init.py +++ b/client/ayon_usd/hooks/pre_resolver_init.py @@ -16,19 +16,15 @@ class InitializeAssetResolver(PreLaunchHook): app_groups = {"maya", "houdini", "unreal"} launch_types = {LaunchTypes.local} - def _setup_resolver(self, local_resolver, settings): - self.log.info( - f"Initializing USD asset resolver for application: {self.app_name}" - ) - - updated_env = utils.get_resolver_setup_info( - local_resolver, settings, env=self.launch_context.env - ) - self.launch_context.env.update(updated_env) - def execute(self): """Pre-launch hook entry method.""" project_settings = self.data["project_settings"] + if not project_settings["usd"]["lakefs"].get("enabled", False): + self.log.info( + "USD LakeFS binary distribution for AYON USD Resolver is" + " disabled.") + return + resolver_lake_fs_path = utils.get_resolver_to_download( project_settings, self.app_name) if not resolver_lake_fs_path: @@ -85,3 +81,13 @@ def execute(self): json.dump(addon_data_json, addon_json) self._setup_resolver(local_resolver, project_settings) + + def _setup_resolver(self, local_resolver, settings): + self.log.info( + f"Initializing USD asset resolver for application: {self.app_name}" + ) + + updated_env = utils.get_resolver_setup_info( + local_resolver, settings, env=self.launch_context.env + ) + self.launch_context.env.update(updated_env) diff --git a/server/settings/main.py b/server/settings/main.py index 552ca06..c0d54b9 100644 --- a/server/settings/main.py +++ b/server/settings/main.py @@ -98,10 +98,12 @@ class AppPlatformURIModel(BaseSettingsModel): class LakeFsSettings(BaseSettingsModel): - """LakeFs Settings / Download Settings ?""" + """LakeFS binary distribution of USD and AYON USD Resolver""" _layout = "collapsed" + enabled: bool = SettingsField(False) + server_uri: str = SettingsField( "https://lake.ayon.cloud", title="LakeFs Server Uri", @@ -238,41 +240,41 @@ class LakeFsSettings(BaseSettingsModel): class AyonResolverSettings(BaseSettingsModel): - """LakeFs Settings / Download Settings ?""" + """AYON USD resolver Settings""" _layout = "collapsed" ayon_log_lvl: str = SettingsField( "WARN", - title="AyonResolver Log Lvl", + title="Resolver Log Lvl", enum_resolver=log_lvl_enum, description="Set verbosity of the AyonUsdResolver logger", ) ayon_file_logger_enabled: str = SettingsField( "OFF", - title="AyonResolver File Logger Enabled ", + title="Resolver File Logger Enabled ", enum_resolver=file_logger_enum, description="Enable or disable AyonUsdResolver file logger", ) - ayon_logger_logging_keys: str = SettingsField( - "", - title="AyonCppApi Logging Keys", - enum_resolver=logger_logging_keys_enum, - description="List of extra logging options for the AyonCppApi", - ) file_logger_file_path: str = SettingsField( "", - title="AyonResolver File logger file path", + title="Resolver File logger file path", description=( "Allows you to set a custom location where the file logger will " "export to. This can be a relative or absolute path. This is only " "used if `ayon_file_logger_enabled` is enabled." ), ) + ayon_logger_logging_keys: str = SettingsField( + "", + title="AyonCppApi Logging Keys", + enum_resolver=logger_logging_keys_enum, + description="List of extra logging options for the AyonCppApi", + ) -class UsdSettings(BaseSettingsModel): - """LakeFs Settings / Download Settings ?""" +class UsdLibConfigSettings(BaseSettingsModel): + """Settings for USD""" _layout = "collapsed" usd_tf_debug: str = SettingsField( @@ -283,18 +285,14 @@ class UsdSettings(BaseSettingsModel): class USDSettings(BaseSettingsModel): - """USD settings.""" - - allow_addon_start: bool = SettingsField( - False, title=("I understand and accept that this is an experimental feature") - ) lakefs: LakeFsSettings = SettingsField( - default_factory=LakeFsSettings, title="LakeFs Config" + default_factory=LakeFsSettings, title="LakeFs Binary Distribution" ) ayon_usd_resolver: AyonResolverSettings = SettingsField( - default_factory=AyonResolverSettings, title="UsdResolver Config" + default_factory=AyonResolverSettings, title="AYON USD Resolver Config" ) - usd: UsdSettings = SettingsField(default_factory=UsdSettings, title="UsdLib Config") + usd: UsdLibConfigSettings = SettingsField( + default_factory=UsdLibConfigSettings, title="USD Library Config") From de90ddfc038ad7e5ca4f2f9a682acb214c26fe42 Mon Sep 17 00:00:00 2001 From: Roy Nieterau Date: Fri, 18 Oct 2024 18:08:10 +0200 Subject: [PATCH 2/7] Remove LakeFS from labels regarding the binary distribution --- client/ayon_usd/addon.py | 2 +- client/ayon_usd/hooks/pre_resolver_init.py | 2 +- server/settings/main.py | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/client/ayon_usd/addon.py b/client/ayon_usd/addon.py index 563564a..e4b59c6 100644 --- a/client/ayon_usd/addon.py +++ b/client/ayon_usd/addon.py @@ -69,7 +69,7 @@ def get_plugin_paths(self): def _download_global_lakefs_binaries(self): settings = get_studio_settings() if not settings["usd"]["lakefs"].get("enabled", False): - self.log.info("USD LakeFS binary distribution is disabled.") + self.log.info("USD Binary distribution is disabled.") return os.makedirs(DOWNLOAD_DIR, exist_ok=True) diff --git a/client/ayon_usd/hooks/pre_resolver_init.py b/client/ayon_usd/hooks/pre_resolver_init.py index d31860a..362c45e 100644 --- a/client/ayon_usd/hooks/pre_resolver_init.py +++ b/client/ayon_usd/hooks/pre_resolver_init.py @@ -21,7 +21,7 @@ def execute(self): project_settings = self.data["project_settings"] if not project_settings["usd"]["lakefs"].get("enabled", False): self.log.info( - "USD LakeFS binary distribution for AYON USD Resolver is" + "USD Binary distribution for AYON USD Resolver is" " disabled.") return diff --git a/server/settings/main.py b/server/settings/main.py index c0d54b9..948b1c6 100644 --- a/server/settings/main.py +++ b/server/settings/main.py @@ -97,8 +97,8 @@ class AppPlatformURIModel(BaseSettingsModel): ) -class LakeFsSettings(BaseSettingsModel): - """LakeFS binary distribution of USD and AYON USD Resolver""" +class BinaryDistributionSettings(BaseSettingsModel): + """Binary distribution of USD and AYON USD Resolver""" _layout = "collapsed" @@ -286,8 +286,8 @@ class UsdLibConfigSettings(BaseSettingsModel): class USDSettings(BaseSettingsModel): - lakefs: LakeFsSettings = SettingsField( - default_factory=LakeFsSettings, title="LakeFs Binary Distribution" + lakefs: BinaryDistributionSettings = SettingsField( + default_factory=BinaryDistributionSettings, title="Binary Distribution" ) ayon_usd_resolver: AyonResolverSettings = SettingsField( From 08c4e8d8ca4a4dd9465891bb0aa8eea2ba6211bf Mon Sep 17 00:00:00 2001 From: Roy Nieterau Date: Mon, 21 Oct 2024 11:26:23 +0200 Subject: [PATCH 3/7] Update client/ayon_usd/hooks/pre_resolver_init.py Co-authored-by: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> --- client/ayon_usd/hooks/pre_resolver_init.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/ayon_usd/hooks/pre_resolver_init.py b/client/ayon_usd/hooks/pre_resolver_init.py index 362c45e..726bf55 100644 --- a/client/ayon_usd/hooks/pre_resolver_init.py +++ b/client/ayon_usd/hooks/pre_resolver_init.py @@ -19,7 +19,7 @@ class InitializeAssetResolver(PreLaunchHook): def execute(self): """Pre-launch hook entry method.""" project_settings = self.data["project_settings"] - if not project_settings["usd"]["lakefs"].get("enabled", False): + if not project_settings["usd"]["lakefs"]["enabled"]: self.log.info( "USD Binary distribution for AYON USD Resolver is" " disabled.") From 8c56f8429966e17c76f2e7568a94716f829d8c9a Mon Sep 17 00:00:00 2001 From: Roy Nieterau Date: Mon, 21 Oct 2024 11:26:30 +0200 Subject: [PATCH 4/7] Update client/ayon_usd/addon.py Co-authored-by: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> --- client/ayon_usd/addon.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/ayon_usd/addon.py b/client/ayon_usd/addon.py index e4b59c6..1a08bfa 100644 --- a/client/ayon_usd/addon.py +++ b/client/ayon_usd/addon.py @@ -68,7 +68,7 @@ def get_plugin_paths(self): def _download_global_lakefs_binaries(self): settings = get_studio_settings() - if not settings["usd"]["lakefs"].get("enabled", False): + if not settings["usd"]["lakefs"]["enabled"]: self.log.info("USD Binary distribution is disabled.") return From 524221e9c88e85be687f9cc2a4f83d95fa0328ea Mon Sep 17 00:00:00 2001 From: Roy Nieterau Date: Thu, 24 Oct 2024 01:05:59 +0200 Subject: [PATCH 5/7] Make labels less specific about distribution method (lakefs) --- server/settings/main.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/server/settings/main.py b/server/settings/main.py index 948b1c6..dc02eef 100644 --- a/server/settings/main.py +++ b/server/settings/main.py @@ -64,7 +64,7 @@ class AppPlatformPathModel(BaseSettingsModel): description="windows / linux / darwin", ) lake_fs_path: str = SettingsField( - title="LakeFs Object Path", + title="Repository Object Path", description=( "The LakeFs internal path to the resolver zip, e.g: " "`AyonUsdResolverBin/Hou/ayon-usd-resolver_hou19.5_linux_py37.zip`" @@ -89,7 +89,7 @@ class AppPlatformURIModel(BaseSettingsModel): description="windows / linux / darwin", ) uri: str = SettingsField( - title="LakeFs Object Uri", + title="Repository Object Uri", description=( "Path to USD Asset Resolver plugin zip file on the LakeFs server, " "e.g: `lakefs://ayon-usd/V001/AyonUsdResolverBin/Hou/ayon-usd-resolver_hou19.5_linux_py37.zip`" # noqa @@ -106,21 +106,21 @@ class BinaryDistributionSettings(BaseSettingsModel): server_uri: str = SettingsField( "https://lake.ayon.cloud", - title="LakeFs Server Uri", + title="Server Uri", description="The url to your LakeFs server.", ) server_repo: str = SettingsField( "lakefs://ayon-usd/v0.2.0/", - title="LakeFs Repository Uri", + title="Repository Uri", description="The url to your LakeFs Repository Path", ) access_key_id: str = SettingsField( - "{Ayon_LakeFs_Key_Id}", + "{AYON_Distribution_Key_Id}", title="Access Key Id", description="LakeFs Access Key Id", ) secret_access_key: str = SettingsField( - "{Ayon_LakeFs_Key}", + "{AYON_Distribution_Access_Key}", title="Access Key", description="LakeFs Access Key", ) From fec7046ad322acadbd3a6153128d41852b9bf193 Mon Sep 17 00:00:00 2001 From: Roy Nieterau Date: Thu, 24 Oct 2024 01:10:20 +0200 Subject: [PATCH 6/7] Refactor `lakefs` settings key to `distribution` (note: this makes settings backwards incompatible) --- client/ayon_usd/addon.py | 2 +- client/ayon_usd/config.py | 10 +++++----- client/ayon_usd/hooks/pre_resolver_init.py | 2 +- client/ayon_usd/utils.py | 10 +++++----- server/settings/main.py | 2 +- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/client/ayon_usd/addon.py b/client/ayon_usd/addon.py index e4b59c6..0e662af 100644 --- a/client/ayon_usd/addon.py +++ b/client/ayon_usd/addon.py @@ -68,7 +68,7 @@ def get_plugin_paths(self): def _download_global_lakefs_binaries(self): settings = get_studio_settings() - if not settings["usd"]["lakefs"].get("enabled", False): + if not settings["usd"]["distribution"].get("enabled", False): self.log.info("USD Binary distribution is disabled.") return diff --git a/client/ayon_usd/config.py b/client/ayon_usd/config.py index e700b1e..9bb8582 100644 --- a/client/ayon_usd/config.py +++ b/client/ayon_usd/config.py @@ -28,11 +28,11 @@ def get_global_lake_instance(settings=None): if not settings: settings = get_studio_settings() - lakefs = settings["usd"]["lakefs"] + distribution = settings["usd"]["distribution"] return wrapper.LakeCtl( - server_url=lakefs["server_uri"], - access_key_id=lakefs["access_key_id"], - secret_access_key=lakefs["secret_access_key"], + server_url=distribution["server_uri"], + access_key_id=distribution["access_key_id"], + secret_access_key=distribution["secret_access_key"], ) @@ -59,6 +59,6 @@ def get_lakefs_usdlib_name(lake_fs_repo: str) -> str: def get_lakefs_usdlib_path(settings: dict) -> str: """Return AyonUsdBin/usd LakeFS full url for current platform. """ - lake_fs_repo = settings["usd"]["lakefs"]["server_repo"] + lake_fs_repo = settings["usd"]["distribution"]["server_repo"] usd_lib_conf = get_lakefs_usdlib_name(lake_fs_repo) return f"{lake_fs_repo}{usd_lib_conf}" diff --git a/client/ayon_usd/hooks/pre_resolver_init.py b/client/ayon_usd/hooks/pre_resolver_init.py index 362c45e..8d94cc6 100644 --- a/client/ayon_usd/hooks/pre_resolver_init.py +++ b/client/ayon_usd/hooks/pre_resolver_init.py @@ -19,7 +19,7 @@ class InitializeAssetResolver(PreLaunchHook): def execute(self): """Pre-launch hook entry method.""" project_settings = self.data["project_settings"] - if not project_settings["usd"]["lakefs"].get("enabled", False): + if not project_settings["usd"]["distribution"].get("enabled", False): self.log.info( "USD Binary distribution for AYON USD Resolver is" " disabled.") diff --git a/client/ayon_usd/utils.py b/client/ayon_usd/utils.py index 87311cb..535f19d 100644 --- a/client/ayon_usd/utils.py +++ b/client/ayon_usd/utils.py @@ -51,7 +51,7 @@ def is_usd_lib_download_needed(settings: dict) -> bool: bool: When true, a new download is required. """ - lake_fs_repo = settings["usd"]["lakefs"]["server_repo"] + lake_fs_repo = settings["usd"]["distribution"]["server_repo"] usd_lib_dir = os.path.abspath(get_downloaded_usd_root(lake_fs_repo)) if not os.path.exists(usd_lib_dir): return True @@ -119,8 +119,8 @@ def get_resolver_to_download(settings, app_name: str) -> str: Returns: str: LakeFs object path to be used with lake_fs_py wrapper """ - lakefs = settings["usd"]["lakefs"] - resolver_overwrite_list = lakefs["lake_fs_overrides"] + distribution = settings["usd"]["distribution"] + resolver_overwrite_list = distribution["lake_fs_overrides"] if resolver_overwrite_list: resolver_overwrite = next( ( @@ -134,7 +134,7 @@ def get_resolver_to_download(settings, app_name: str) -> str: if resolver_overwrite: return resolver_overwrite["lake_fs_path"] - resolver_list = lakefs["asset_resolvers"] + resolver_list = distribution["asset_resolvers"] if not resolver_list: return "" @@ -150,7 +150,7 @@ def get_resolver_to_download(settings, app_name: str) -> str: if not resolver: return "" - lake_fs_repo_uri = lakefs["server_repo"] + lake_fs_repo_uri = distribution["server_repo"] resolver_lake_path = lake_fs_repo_uri + resolver["lake_fs_path"] return resolver_lake_path diff --git a/server/settings/main.py b/server/settings/main.py index dc02eef..1ac40ad 100644 --- a/server/settings/main.py +++ b/server/settings/main.py @@ -286,7 +286,7 @@ class UsdLibConfigSettings(BaseSettingsModel): class USDSettings(BaseSettingsModel): - lakefs: BinaryDistributionSettings = SettingsField( + distribution: BinaryDistributionSettings = SettingsField( default_factory=BinaryDistributionSettings, title="Binary Distribution" ) From e3158a65dd1a4b9d2df7819cfa7bf97b41d0cb12 Mon Sep 17 00:00:00 2001 From: Roy Nieterau Date: Thu, 24 Oct 2024 01:31:48 +0200 Subject: [PATCH 7/7] Remove `LakeFs` from label + cosmetics --- server/settings/main.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server/settings/main.py b/server/settings/main.py index 1ac40ad..b745f4d 100644 --- a/server/settings/main.py +++ b/server/settings/main.py @@ -125,7 +125,7 @@ class BinaryDistributionSettings(BaseSettingsModel): description="LakeFs Access Key", ) asset_resolvers: list[AppPlatformPathModel] = SettingsField( - title="Resolver Application LakeFs Paths", + title="Resolver Application Paths", description="Allows an admin to define a specific Resolver Zip for a specific Application", default=[ AppPlatformPathModel( @@ -231,7 +231,7 @@ class BinaryDistributionSettings(BaseSettingsModel): ], ) lake_fs_overrides: list[AppPlatformURIModel] = SettingsField( - title="Resolver Application overwrites", + title="Resolver Application Overwrites", description=( "Allows to define a specific Resolver Zip for a specific Application" ),