Skip to content

Commit

Permalink
move simple_creators and editorial_creators to a better place and…
Browse files Browse the repository at this point in the history
… implement conversion
  • Loading branch information
MustafaJafar committed Nov 27, 2024
1 parent 8a575cf commit ec9647c
Show file tree
Hide file tree
Showing 7 changed files with 78 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ def __init__(self, *args, **kwargs):

def apply_settings(self, project_settings):
editorial_creators = deepcopy(
project_settings["traypublisher"]["editorial_creators"]
project_settings["traypublisher"]["create"]["editorial_creators"]
)
creator_settings = editorial_creators.get(self.identifier)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def initialize():
project_name = os.environ["AYON_PROJECT_NAME"]
project_settings = get_project_settings(project_name)

simple_creators = project_settings["traypublisher"]["simple_creators"]
simple_creators = project_settings["traypublisher"]["create"]["simple_creators"]

global_variables = globals()
for item in simple_creators:
Expand Down
20 changes: 19 additions & 1 deletion server/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
from typing import Any

from ayon_server.addons import BaseServerAddon

from .settings import TraypublisherSettings, DEFAULT_TRAYPUBLISHER_SETTING
from .settings import (
TraypublisherSettings,
DEFAULT_TRAYPUBLISHER_SETTING,
convert_settings_overrides,
)


class Traypublisher(BaseServerAddon):
Expand All @@ -9,3 +15,15 @@ class Traypublisher(BaseServerAddon):
async def get_default_settings(self):
settings_model_cls = self.get_settings_model()
return settings_model_cls(**DEFAULT_TRAYPUBLISHER_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
)

3 changes: 3 additions & 0 deletions server/settings/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@
TraypublisherSettings,
DEFAULT_TRAYPUBLISHER_SETTING,
)
from .conversion import convert_settings_overrides


__all__ = (
"TraypublisherSettings",
"DEFAULT_TRAYPUBLISHER_SETTING",

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


def _convert_simple_creators_0_2_9(overrides):
if "simple_creators" not in overrides:
return

if overrides.get("create") is None:
overrides.update({
"create": {}
})

overrides["create"]["simple_creators"] = overrides.pop("simple_creators")


def _convert_editorial_creators_0_2_9(overrides):
if "editorial_creators" not in overrides:
return

if overrides.get("create") is None:
overrides.update({
"create": {}
})

overrides["create"]["editorial_creators"] = overrides.pop("editorial_creators")


def convert_settings_overrides(
source_version: str,
overrides: dict[str, Any],
) -> dict[str, Any]:
_convert_simple_creators_0_2_9(overrides)
_convert_editorial_creators_0_2_9(overrides)
return overrides
19 changes: 19 additions & 0 deletions server/settings/creator_plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,15 @@
from ayon_server.settings.validators import ensure_unique_names
from ayon_server.exceptions import BadRequestException

from .simple_creators import (
SimpleCreatorPlugin,
DEFAULT_SIMPLE_CREATORS,
)
from .editorial_creators import (
TraypublisherEditorialCreatorPlugins,
DEFAULT_EDITORIAL_CREATORS,
)


class BatchMovieCreatorPlugin(BaseSettingsModel):
"""Allows to publish multiple video files in one go. <br />Name of matching
Expand Down Expand Up @@ -229,13 +238,23 @@ class TrayPublisherCreatePluginsModel(BaseSettingsModel):
title="Batch Movie Creator",
default_factory=BatchMovieCreatorPlugin
)
editorial_creators: TraypublisherEditorialCreatorPlugins = SettingsField(
title="Editorial Creators",
default_factory=TraypublisherEditorialCreatorPlugins,
)
IngestCSV: IngestCSVPluginModel = SettingsField(
title="Ingest CSV",
default_factory=IngestCSVPluginModel
)
simple_creators: list[SimpleCreatorPlugin] = SettingsField(
title="Simple Create Plugins",
default_factory=SimpleCreatorPlugin,
)


DEFAULT_CREATORS = {
"simple_creators": DEFAULT_SIMPLE_CREATORS,
"editorial_creators": DEFAULT_EDITORIAL_CREATORS,
"BatchMovieCreator": {
"default_variants": [
"Main"
Expand Down
19 changes: 1 addition & 18 deletions server/settings/main.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
from ayon_server.settings import BaseSettingsModel, SettingsField

from .imageio import TrayPublisherImageIOModel
from .simple_creators import (
SimpleCreatorPlugin,
DEFAULT_SIMPLE_CREATORS,
)
from .editorial_creators import (
TraypublisherEditorialCreatorPlugins,
DEFAULT_EDITORIAL_CREATORS,
)

from .creator_plugins import (
TrayPublisherCreatePluginsModel,
DEFAULT_CREATORS,
Expand All @@ -25,14 +18,6 @@ class TraypublisherSettings(BaseSettingsModel):
default_factory=TrayPublisherImageIOModel,
title="Color Management (ImageIO)"
)
simple_creators: list[SimpleCreatorPlugin] = SettingsField(
title="Simple Create Plugins",
default_factory=SimpleCreatorPlugin,
)
editorial_creators: TraypublisherEditorialCreatorPlugins = SettingsField(
title="Editorial Creators",
default_factory=TraypublisherEditorialCreatorPlugins,
)
create: TrayPublisherCreatePluginsModel = SettingsField(
title="Create",
default_factory=TrayPublisherCreatePluginsModel
Expand All @@ -44,8 +29,6 @@ class TraypublisherSettings(BaseSettingsModel):


DEFAULT_TRAYPUBLISHER_SETTING = {
"simple_creators": DEFAULT_SIMPLE_CREATORS,
"editorial_creators": DEFAULT_EDITORIAL_CREATORS,
"create": DEFAULT_CREATORS,
"publish": DEFAULT_PUBLISH_PLUGINS,
}

0 comments on commit ec9647c

Please sign in to comment.