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

Make LakeFS distribution of USD Libs and AYON USD Resolver optional #72

Merged
merged 8 commits into from
Oct 28, 2024
60 changes: 28 additions & 32 deletions client/ayon_usd/addon.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,23 +38,39 @@ 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):
"""Start tray module.

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):
BigRoy marked this conversation as resolved.
Show resolved Hide resolved
self.log.info("USD Binary distribution is disabled.")
return

os.makedirs(DOWNLOAD_DIR, exist_ok=True)

Expand All @@ -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)
Expand Down Expand Up @@ -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
26 changes: 16 additions & 10 deletions client/ayon_usd/hooks/pre_resolver_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
BigRoy marked this conversation as resolved.
Show resolved Hide resolved
self.log.info(
"USD 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:
Expand Down Expand Up @@ -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)
44 changes: 21 additions & 23 deletions server/settings/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,13 @@ class AppPlatformURIModel(BaseSettingsModel):
)


class LakeFsSettings(BaseSettingsModel):
"""LakeFs Settings / Download Settings ?"""
class BinaryDistributionSettings(BaseSettingsModel):
"""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",
Expand Down Expand Up @@ -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(
Expand All @@ -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"
lakefs: BinaryDistributionSettings = SettingsField(
default_factory=BinaryDistributionSettings, title="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")