AYON: Addon settings in OpenPype (#5347)

* copied addons from 'ayon-addon-settings'

* added AE, photoshop and harmony addon

* moved openpype to subfolder

* cleanup repository files

* updated create package script and README.md

* formatting fixes

* added cli flags to be able keep server structure

* print progress and output dir

* another formatting fixes
This commit is contained in:
Jakub Trllo 2023-07-26 14:08:42 +02:00 committed by GitHub
parent e6d9697e23
commit 2b37b8af48
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
167 changed files with 15525 additions and 146 deletions

View file

@ -0,0 +1,15 @@
from ayon_server.addons import BaseServerAddon
from .settings import PhotoshopSettings, DEFAULT_PHOTOSHOP_SETTING
from .version import __version__
class Photoshop(BaseServerAddon):
name = "photoshop"
version = __version__
settings_model = PhotoshopSettings
async def get_default_settings(self):
settings_model_cls = self.get_settings_model()
return settings_model_cls(**DEFAULT_PHOTOSHOP_SETTING)

View file

@ -0,0 +1,10 @@
from .main import (
PhotoshopSettings,
DEFAULT_PHOTOSHOP_SETTING,
)
__all__ = (
"PhotoshopSettings",
"DEFAULT_PHOTOSHOP_SETTING",
)

View file

@ -0,0 +1,79 @@
from pydantic import Field
from ayon_server.settings import BaseSettingsModel
class CreateImagePluginModel(BaseSettingsModel):
enabled: bool = Field(True, title="Enabled")
active_on_create: bool = Field(True, title="Active by default")
mark_for_review: bool = Field(False, title="Review by default")
default_variants: list[str] = Field(
default_factory=list,
title="Default Variants"
)
class AutoImageCreatorPluginModel(BaseSettingsModel):
enabled: bool = Field(False, title="Enabled")
active_on_create: bool = Field(True, title="Active by default")
mark_for_review: bool = Field(False, title="Review by default")
default_variant: str = Field("", title="Default Variants")
class CreateReviewPlugin(BaseSettingsModel):
enabled: bool = Field(True, title="Enabled")
active_on_create: bool = Field(True, title="Active by default")
default_variant: str = Field("", title="Default Variants")
class CreateWorkfilelugin(BaseSettingsModel):
enabled: bool = Field(True, title="Enabled")
active_on_create: bool = Field(True, title="Active by default")
default_variant: str = Field("", title="Default Variants")
class PhotoshopCreatorPlugins(BaseSettingsModel):
ImageCreator: CreateImagePluginModel = Field(
title="Create Image",
default_factory=CreateImagePluginModel,
)
AutoImageCreator: AutoImageCreatorPluginModel = Field(
title="Create Flatten Image",
default_factory=AutoImageCreatorPluginModel,
)
ReviewCreator: CreateReviewPlugin = Field(
title="Create Review",
default_factory=CreateReviewPlugin,
)
WorkfileCreator: CreateWorkfilelugin = Field(
title="Create Workfile",
default_factory=CreateWorkfilelugin,
)
DEFAULT_CREATE_SETTINGS = {
"ImageCreator": {
"enabled": True,
"active_on_create": True,
"mark_for_review": False,
"default_variants": [
"Main"
]
},
"AutoImageCreator": {
"enabled": False,
"active_on_create": True,
"mark_for_review": False,
"default_variant": ""
},
"ReviewCreator": {
"enabled": True,
"active_on_create": True,
"default_variant": ""
},
"WorkfileCreator": {
"enabled": True,
"active_on_create": True,
"default_variant": "Main"
}
}

View file

@ -0,0 +1,64 @@
from pydantic import Field, validator
from ayon_server.settings import BaseSettingsModel
from ayon_server.settings.validators import ensure_unique_names
class ImageIOConfigModel(BaseSettingsModel):
override_global_config: bool = Field(
False,
title="Override global OCIO config"
)
filepath: list[str] = Field(
default_factory=list,
title="Config path"
)
class ImageIOFileRuleModel(BaseSettingsModel):
name: str = Field("", title="Rule name")
pattern: str = Field("", title="Regex pattern")
colorspace: str = Field("", title="Colorspace name")
ext: str = Field("", title="File extension")
class ImageIOFileRulesModel(BaseSettingsModel):
activate_host_rules: bool = Field(False)
rules: list[ImageIOFileRuleModel] = Field(
default_factory=list,
title="Rules"
)
@validator("rules")
def validate_unique_outputs(cls, value):
ensure_unique_names(value)
return value
class ImageIORemappingRulesModel(BaseSettingsModel):
host_native_name: str = Field(
title="Application native colorspace name"
)
ocio_name: str = Field(title="OCIO colorspace name")
class ImageIORemappingModel(BaseSettingsModel):
rules: list[ImageIORemappingRulesModel] = Field(
default_factory=list)
class PhotoshopImageIOModel(BaseSettingsModel):
activate_host_color_management: bool = Field(
True, title="Enable Color Management"
)
remapping: ImageIORemappingModel = Field(
title="Remapping colorspace names",
default_factory=ImageIORemappingModel
)
ocio_config: ImageIOConfigModel = Field(
default_factory=ImageIOConfigModel,
title="OCIO config"
)
file_rules: ImageIOFileRulesModel = Field(
default_factory=ImageIOFileRulesModel,
title="File Rules"
)

View file

@ -0,0 +1,41 @@
from pydantic import Field
from ayon_server.settings import BaseSettingsModel
from .imageio import PhotoshopImageIOModel
from .creator_plugins import PhotoshopCreatorPlugins, DEFAULT_CREATE_SETTINGS
from .publish_plugins import PhotoshopPublishPlugins, DEFAULT_PUBLISH_SETTINGS
from .workfile_builder import WorkfileBuilderPlugin
class PhotoshopSettings(BaseSettingsModel):
"""Photoshop Project Settings."""
imageio: PhotoshopImageIOModel = Field(
default_factory=PhotoshopImageIOModel,
title="OCIO config"
)
create: PhotoshopCreatorPlugins = Field(
default_factory=PhotoshopCreatorPlugins,
title="Creator plugins"
)
publish: PhotoshopPublishPlugins = Field(
default_factory=PhotoshopPublishPlugins,
title="Publish plugins"
)
workfile_builder: WorkfileBuilderPlugin = Field(
default_factory=WorkfileBuilderPlugin,
title="Workfile Builder"
)
DEFAULT_PHOTOSHOP_SETTING = {
"create": DEFAULT_CREATE_SETTINGS,
"publish": DEFAULT_PUBLISH_SETTINGS,
"workfile_builder": {
"create_first_version": False,
"custom_templates": []
}
}

View file

@ -0,0 +1,221 @@
from pydantic import Field
from ayon_server.settings import BaseSettingsModel
create_flatten_image_enum = [
{"value": "flatten_with_images", "label": "Flatten with images"},
{"value": "flatten_only", "label": "Flatten only"},
{"value": "no", "label": "No"},
]
color_code_enum = [
{"value": "red", "label": "Red"},
{"value": "orange", "label": "Orange"},
{"value": "yellowColor", "label": "Yellow"},
{"value": "grain", "label": "Green"},
{"value": "blue", "label": "Blue"},
{"value": "violet", "label": "Violet"},
{"value": "gray", "label": "Gray"},
]
class ColorCodeMappings(BaseSettingsModel):
color_code: list[str] = Field(
title="Color codes for layers",
default_factory=list,
enum_resolver=lambda: color_code_enum,
)
layer_name_regex: list[str] = Field(
"",
title="Layer name regex"
)
product_type: str = Field(
"",
title="Resulting product type"
)
product_name_template: str = Field(
"",
title="Product name template"
)
class ExtractedOptions(BaseSettingsModel):
tags: list[str] = Field(
title="Tags",
default_factory=list
)
class CollectColorCodedInstancesPlugin(BaseSettingsModel):
"""Set color for publishable layers, set its resulting product type
and template for product name. \n Can create flatten image from published
instances.
(Applicable only for remote publishing!)"""
enabled: bool = Field(True, title="Enabled")
create_flatten_image: str = Field(
"",
title="Create flatten image",
enum_resolver=lambda: create_flatten_image_enum,
)
flatten_product_type_template: str = Field(
"",
title="Subset template for flatten image"
)
color_code_mapping: list[ColorCodeMappings] = Field(
title="Color code mappings",
default_factory=ColorCodeMappings,
)
class CollectReviewPlugin(BaseSettingsModel):
"""Should review product be created"""
enabled: bool = Field(True, title="Enabled")
class CollectVersionPlugin(BaseSettingsModel):
"""Synchronize version for image and review instances by workfile version""" # noqa
enabled: bool = Field(True, title="Enabled")
class ValidateContainersPlugin(BaseSettingsModel):
"""Check that workfile contains latest version of loaded items""" # noqa
_isGroup = True
enabled: bool = True
optional: bool = Field(False, title="Optional")
active: bool = Field(True, title="Active")
class ValidateNamingPlugin(BaseSettingsModel):
"""Validate naming of products and layers""" # noqa
invalid_chars: str = Field(
'',
title="Regex pattern of invalid characters"
)
replace_char: str = Field(
'',
title="Replacement character"
)
class ExtractImagePlugin(BaseSettingsModel):
"""Currently only jpg and png are supported"""
formats: list[str] = Field(
title="Extract Formats",
default_factory=list,
)
class ExtractReviewPlugin(BaseSettingsModel):
make_image_sequence: bool = Field(
False,
title="Make an image sequence instead of flatten image"
)
max_downscale_size: int = Field(
8192,
title="Maximum size of sources for review",
description="FFMpeg can only handle limited resolution for creation of review and/or thumbnail", # noqa
gt=300, # greater than
le=16384, # less or equal
)
jpg_options: ExtractedOptions = Field(
title="Extracted jpg Options",
default_factory=ExtractedOptions
)
mov_options: ExtractedOptions = Field(
title="Extracted mov Options",
default_factory=ExtractedOptions
)
class PhotoshopPublishPlugins(BaseSettingsModel):
CollectColorCodedInstances: CollectColorCodedInstancesPlugin = Field(
title="Collect Color Coded Instances",
default_factory=CollectColorCodedInstancesPlugin,
)
CollectReview: CollectReviewPlugin = Field(
title="Collect Review",
default_factory=CollectReviewPlugin,
)
CollectVersion: CollectVersionPlugin = Field(
title="Create Image",
default_factory=CollectVersionPlugin,
)
ValidateContainers: ValidateContainersPlugin = Field(
title="Validate Containers",
default_factory=ValidateContainersPlugin,
)
ValidateNaming: ValidateNamingPlugin = Field(
title="Validate naming of products and layers",
default_factory=ValidateNamingPlugin,
)
ExtractImage: ExtractImagePlugin = Field(
title="Extract Image",
default_factory=ExtractImagePlugin,
)
ExtractReview: ExtractReviewPlugin = Field(
title="Extract Review",
default_factory=ExtractReviewPlugin,
)
DEFAULT_PUBLISH_SETTINGS = {
"CollectColorCodedInstances": {
"create_flatten_image": "no",
"flatten_product_type_template": "",
"color_code_mapping": []
},
"CollectReview": {
"enabled": True
},
"CollectVersion": {
"enabled": False
},
"ValidateContainers": {
"enabled": True,
"optional": True,
"active": True
},
"ValidateNaming": {
"invalid_chars": "[ \\\\/+\\*\\?\\(\\)\\[\\]\\{\\}:,;]",
"replace_char": "_"
},
"ExtractImage": {
"formats": [
"png",
"jpg"
]
},
"ExtractReview": {
"make_image_sequence": False,
"max_downscale_size": 8192,
"jpg_options": {
"tags": [
"review",
"ftrackreview"
]
},
"mov_options": {
"tags": [
"review",
"ftrackreview"
]
}
}
}

View file

@ -0,0 +1,41 @@
from pydantic import Field
from pathlib import Path
from ayon_server.settings import BaseSettingsModel
class PathsTemplate(BaseSettingsModel):
windows: Path = Field(
'',
title="Windows"
)
darwin: Path = Field(
'',
title="MacOS"
)
linux: Path = Field(
'',
title="Linux"
)
class CustomBuilderTemplate(BaseSettingsModel):
task_types: list[str] = Field(
default_factory=list,
title="Task types",
)
template_path: PathsTemplate = Field(
default_factory=PathsTemplate
)
class WorkfileBuilderPlugin(BaseSettingsModel):
_title = "Workfile Builder"
create_first_version: bool = Field(
False,
title="Create first workfile"
)
custom_templates: list[CustomBuilderTemplate] = Field(
default_factory=CustomBuilderTemplate
)

View file

@ -0,0 +1,3 @@
# -*- coding: utf-8 -*-
"""Package declaring addon version."""
__version__ = "0.1.0"