Skip to content

Commit

Permalink
Merge branch 'develop' into bugfix/avoid_invalid_containers
Browse files Browse the repository at this point in the history
  • Loading branch information
BigRoy authored Dec 30, 2024
2 parents d3298ec + d0a7561 commit ae13bdc
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 13 deletions.
4 changes: 1 addition & 3 deletions client/ayon_maya/api/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -1039,9 +1039,7 @@ def prepare_root_value(self, file_url, project_name):
(str)
"""
settings = get_project_settings(project_name)
use_env_var_as_root = (settings["maya"]
["maya_dirmap"]
["use_env_var_as_root"])
use_env_var_as_root = settings["maya"]["dirmap"]["use_env_var_as_root"]
if use_env_var_as_root:
anatomy = Anatomy(project_name)
file_url = anatomy.replace_root_with_env_key(file_url, '${{{}}}')
Expand Down
15 changes: 15 additions & 0 deletions server/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
"""Maya Addon Module"""
from typing import Any

from ayon_server.addons import BaseServerAddon

from .settings.main import MayaSettings, DEFAULT_MAYA_SETTING
from .settings.conversion import convert_settings_overrides


class MayaAddon(BaseServerAddon):
Expand All @@ -10,3 +13,15 @@ class MayaAddon(BaseServerAddon):
async def get_default_settings(self):
settings_model_cls = self.get_settings_model()
return settings_model_cls(**DEFAULT_MAYA_SETTING)

async def convert_settings_overrides(
self,
source_version: str,
overrides: dict[str, Any],
) -> dict[str, Any]:
convert_settings_overrides(source_version, overrides)
# Use super conversion
return await super().convert_settings_overrides(
source_version, overrides
)

22 changes: 22 additions & 0 deletions server/settings/conversion.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
from typing import Any


def _convert_dirmap_0_4_3(overrides):
"""maya_dirmap key was renamed to dirmap in 0.4.3"""
if "maya_dirmap" not in overrides:
# Legacy settings not found
return

if "dirmap" in overrides:
# Already new settings
return

overrides["dirmap"] = overrides.pop("maya_dirmap")


def convert_settings_overrides(
source_version: str,
overrides: dict[str, Any],
) -> dict[str, Any]:
_convert_dirmap_0_4_3(overrides)
return overrides
10 changes: 5 additions & 5 deletions server/settings/maya_dirmap.py → server/settings/dirmap.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from ayon_server.settings import BaseSettingsModel, SettingsField


class MayaDirmapPathsSubmodel(BaseSettingsModel):
class DirmapPathsSubmodel(BaseSettingsModel):
_layout = "compact"
source_path: list[str] = SettingsField(
default_factory=list, title="Source Paths"
Expand All @@ -11,7 +11,7 @@ class MayaDirmapPathsSubmodel(BaseSettingsModel):
)


class MayaDirmapModel(BaseSettingsModel):
class DirmapModel(BaseSettingsModel):
"""Maya dirmap settings."""
# _layout = "expanded"
_isGroup: bool = True
Expand All @@ -22,13 +22,13 @@ class MayaDirmapModel(BaseSettingsModel):
use_env_var_as_root: bool = SettingsField(
title="Use env var placeholder in referenced paths"
)
paths: MayaDirmapPathsSubmodel = SettingsField(
default_factory=MayaDirmapPathsSubmodel,
paths: DirmapPathsSubmodel = SettingsField(
default_factory=DirmapPathsSubmodel,
title="Dirmap Paths"
)


DEFAULT_MAYA_DIRMAP_SETTINGS = {
DEFAULT_DIRMAP_SETTINGS = {
"use_env_var_as_root": False,
"enabled": False,
"paths": {
Expand Down
10 changes: 5 additions & 5 deletions server/settings/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
ensure_unique_names,
)
from .imageio import ImageIOSettings, DEFAULT_IMAGEIO_SETTINGS
from .maya_dirmap import MayaDirmapModel, DEFAULT_MAYA_DIRMAP_SETTINGS
from .dirmap import DirmapModel, DEFAULT_DIRMAP_SETTINGS
from .include_handles import IncludeHandlesModel, DEFAULT_INCLUDE_HANDLES
from .explicit_plugins_loading import (
ExplicitPluginsLoadingModel, DEFAULT_EXPLITCIT_PLUGINS_LOADING_SETTINGS
Expand Down Expand Up @@ -51,8 +51,8 @@ class MayaSettings(BaseSettingsModel):
)
ext_mapping: list[ExtMappingItemModel] = SettingsField(
default_factory=list, title="Extension Mapping")
maya_dirmap: MayaDirmapModel = SettingsField(
default_factory=MayaDirmapModel, title="Maya dirmap Settings")
dirmap: DirmapModel = SettingsField(
default_factory=DirmapModel, title="Maya dirmap Settings")
include_handles: IncludeHandlesModel = SettingsField(
default_factory=IncludeHandlesModel,
title="Include/Exclude Handles in default playback & render range"
Expand Down Expand Up @@ -110,8 +110,8 @@ def validate_unique_outputs(cls, value):
{"name": "workfile", "value": "ma"},
{"name": "yetiRig", "value": "ma"}
],
# `maya_dirmap` was originally with dash - `maya-dirmap`
"maya_dirmap": DEFAULT_MAYA_DIRMAP_SETTINGS,
# `dirmap` was originally with dash - `maya-dirmap`
"dirmap": DEFAULT_DIRMAP_SETTINGS,
"include_handles": DEFAULT_INCLUDE_HANDLES,
"scriptsmenu": DEFAULT_SCRIPTSMENU_SETTINGS,
"render_settings": DEFAULT_RENDER_SETTINGS,
Expand Down

0 comments on commit ae13bdc

Please sign in to comment.