From da500701b8fb0f55e2d4f2772bbdfda52a87abf5 Mon Sep 17 00:00:00 2001 From: Jakub Jezek Date: Wed, 11 Jan 2023 16:31:21 +0100 Subject: [PATCH] global: reworking config path settings to be multipath with order --- openpype/pipeline/colorspace.py | 72 ++++++++++++++----- .../defaults/project_anatomy/attributes.json | 3 +- .../project_settings/aftereffects.json | 6 +- .../defaults/project_settings/blender.json | 6 +- .../defaults/project_settings/celaction.json | 6 +- .../defaults/project_settings/flame.json | 6 +- .../defaults/project_settings/fusion.json | 6 +- .../defaults/project_settings/global.json | 14 ++-- .../defaults/project_settings/harmony.json | 6 +- .../defaults/project_settings/hiero.json | 6 +- .../defaults/project_settings/houdini.json | 6 +- .../defaults/project_settings/maya.json | 44 ++++++------ .../defaults/project_settings/nuke.json | 6 +- .../defaults/project_settings/photoshop.json | 6 +- .../defaults/project_settings/resolve.json | 6 +- .../project_settings/traypublisher.json | 6 +- .../defaults/project_settings/tvpaint.json | 6 +- .../defaults/project_settings/unreal.json | 6 +- .../project_settings/webpublisher.json | 6 +- .../schema_project_global.json | 15 +++- .../schemas/schema_imageio_config.json | 4 +- 21 files changed, 114 insertions(+), 128 deletions(-) diff --git a/openpype/pipeline/colorspace.py b/openpype/pipeline/colorspace.py index a1c7c359da..df83d041c4 100644 --- a/openpype/pipeline/colorspace.py +++ b/openpype/pipeline/colorspace.py @@ -330,7 +330,6 @@ def get_imageio_config( """ project_settings = project_settings or get_project_settings(project_name) anatomy = anatomy or Anatomy(project_name) - current_platform = platform.system().lower() if not anatomy_data: from openpype.pipeline.context_tools import ( @@ -344,34 +343,75 @@ def get_imageio_config( imageio_global, imageio_host = _get_imageio_settings( project_settings, host_name) - # get config path from either global or host_name - config_global = imageio_global["ocio_config"] config_host = imageio_host["ocio_config"] - # set config path - config_path = None - if config_global["enabled"]: - config_path = config_global["filepath"][current_platform] if config_host["enabled"]: - config_path = config_host["filepath"][current_platform] + print(config_host["filepath"]) + config_data = _get_config_data( + config_host["filepath"], anatomy_data + ) + else: + config_data = None - if not config_path: - return + if not config_data: + # get config path from either global or host_name + config_global = imageio_global["ocio_config"] + print(config_global["filepath"]) + config_data = _get_config_data( + config_global["filepath"], anatomy_data + ) + if not config_data: + raise FileExistsError( + "No OCIO config found in settings. It is " + "either missing or there is typo in path inputs" + ) + + return config_data + + +def _get_config_data(path_list, anatomy_data): + """Path formating in interation + + Args: + path_list (list[str]): list of abs paths + anatomy_data (dict): formating data + + Returns: + dict: config data + """ + # first try host config paths + for path_ in path_list: + formated_path = _format_path(path_, anatomy_data) + if not os.path.exists(formated_path): + continue + + return { + "path": os.path.normpath(formated_path), + "template": path_ + } + + +def _format_path(tempate_path, anatomy_data): + """Single template path formating. + + Args: + tempate_path (str): template string + anatomy_data (dict): formating data + + Returns: + str: absolute formated path + """ formatting_data = deepcopy(anatomy_data) # format the path for potential env vars formatting_data.update(dict(**os.environ)) # format path for anatomy keys - formatted_path = StringTemplate(config_path).format( + formatted_path = StringTemplate(tempate_path).format( formatting_data) - abs_path = os.path.abspath(formatted_path) - return { - "path": os.path.normpath(abs_path), - "template": config_path - } + return os.path.abspath(formatted_path) def get_imageio_file_rules(project_name, host_name, project_settings=None): diff --git a/openpype/settings/defaults/project_anatomy/attributes.json b/openpype/settings/defaults/project_anatomy/attributes.json index 983ac603f9..bf8bbef8de 100644 --- a/openpype/settings/defaults/project_anatomy/attributes.json +++ b/openpype/settings/defaults/project_anatomy/attributes.json @@ -19,8 +19,7 @@ "blender/2-91", "harmony/20", "photoshop/2021", - "aftereffects/2021", - "unreal/4-26" + "aftereffects/2021" ], "tools_env": [], "active": true diff --git a/openpype/settings/defaults/project_settings/aftereffects.json b/openpype/settings/defaults/project_settings/aftereffects.json index 16a6be9478..e4b957fb85 100644 --- a/openpype/settings/defaults/project_settings/aftereffects.json +++ b/openpype/settings/defaults/project_settings/aftereffects.json @@ -2,11 +2,7 @@ "imageio": { "ocio_config": { "enabled": false, - "filepath": { - "windows": "", - "darwin": "", - "linux": "" - } + "filepath": [] }, "file_rules": { "enabled": false, diff --git a/openpype/settings/defaults/project_settings/blender.json b/openpype/settings/defaults/project_settings/blender.json index 239dd4b767..12a322cb98 100644 --- a/openpype/settings/defaults/project_settings/blender.json +++ b/openpype/settings/defaults/project_settings/blender.json @@ -2,11 +2,7 @@ "imageio": { "ocio_config": { "enabled": false, - "filepath": { - "windows": "", - "darwin": "", - "linux": "" - } + "filepath": [] }, "file_rules": { "enabled": false, diff --git a/openpype/settings/defaults/project_settings/celaction.json b/openpype/settings/defaults/project_settings/celaction.json index b7d1421bc8..ad01e62d95 100644 --- a/openpype/settings/defaults/project_settings/celaction.json +++ b/openpype/settings/defaults/project_settings/celaction.json @@ -2,11 +2,7 @@ "imageio": { "ocio_config": { "enabled": false, - "filepath": { - "windows": "", - "darwin": "", - "linux": "" - } + "filepath": [] }, "file_rules": { "enabled": false, diff --git a/openpype/settings/defaults/project_settings/flame.json b/openpype/settings/defaults/project_settings/flame.json index 7771033c83..cbd99c4560 100644 --- a/openpype/settings/defaults/project_settings/flame.json +++ b/openpype/settings/defaults/project_settings/flame.json @@ -2,11 +2,7 @@ "imageio": { "ocio_config": { "enabled": false, - "filepath": { - "windows": "", - "darwin": "", - "linux": "" - } + "filepath": [] }, "file_rules": { "enabled": false, diff --git a/openpype/settings/defaults/project_settings/fusion.json b/openpype/settings/defaults/project_settings/fusion.json index 4e61b5456f..720178e17a 100644 --- a/openpype/settings/defaults/project_settings/fusion.json +++ b/openpype/settings/defaults/project_settings/fusion.json @@ -2,11 +2,7 @@ "imageio": { "ocio_config": { "enabled": false, - "filepath": { - "windows": "", - "darwin": "", - "linux": "" - } + "filepath": [] }, "file_rules": { "enabled": false, diff --git a/openpype/settings/defaults/project_settings/global.json b/openpype/settings/defaults/project_settings/global.json index 0b4e4c74e6..0e078dc157 100644 --- a/openpype/settings/defaults/project_settings/global.json +++ b/openpype/settings/defaults/project_settings/global.json @@ -1,12 +1,10 @@ { "imageio": { "ocio_config": { - "enabled": true, - "filepath": { - "windows": "{OPENPYPE_ROOT}/vendor/bin/ocioconfig/OpenColorIOConfigs/aces_1.2/config.ocio", - "darwin": "{OPENPYPE_ROOT}/vendor/bin/ocioconfig/OpenColorIOConfigs/aces_1.2/config.ocio", - "linux": "{OPENPYPE_ROOT}/vendor/bin/ocioconfig/OpenColorIOConfigs/aces_1.2/config.ocio" - } + "filepath": [ + "{OPENPYPE_ROOT}/vendor/bin/ocioconfig/OpenColorIOConfigs/aces_1.2/config.ocio", + "{OPENPYPE_ROOT}/vendor/bin/ocioconfig/OpenColorIOConfigs/nuke-default/config.ocio" + ] }, "file_rules": { "enabled": false, @@ -442,7 +440,9 @@ "template": "{family}{Task}" }, { - "families": ["render"], + "families": [ + "render" + ], "hosts": [ "aftereffects" ], diff --git a/openpype/settings/defaults/project_settings/harmony.json b/openpype/settings/defaults/project_settings/harmony.json index 65d549fb50..1f4ea88272 100644 --- a/openpype/settings/defaults/project_settings/harmony.json +++ b/openpype/settings/defaults/project_settings/harmony.json @@ -2,11 +2,7 @@ "imageio": { "ocio_config": { "enabled": false, - "filepath": { - "windows": "", - "darwin": "", - "linux": "" - } + "filepath": [] }, "file_rules": { "enabled": false, diff --git a/openpype/settings/defaults/project_settings/hiero.json b/openpype/settings/defaults/project_settings/hiero.json index bfe9f70140..c6180d0a58 100644 --- a/openpype/settings/defaults/project_settings/hiero.json +++ b/openpype/settings/defaults/project_settings/hiero.json @@ -2,11 +2,7 @@ "imageio": { "ocio_config": { "enabled": false, - "filepath": { - "windows": "", - "darwin": "", - "linux": "" - } + "filepath": [] }, "file_rules": { "enabled": false, diff --git a/openpype/settings/defaults/project_settings/houdini.json b/openpype/settings/defaults/project_settings/houdini.json index 90748f1f28..68cc8945fe 100644 --- a/openpype/settings/defaults/project_settings/houdini.json +++ b/openpype/settings/defaults/project_settings/houdini.json @@ -2,11 +2,7 @@ "imageio": { "ocio_config": { "enabled": false, - "filepath": { - "windows": "", - "darwin": "", - "linux": "" - } + "filepath": [] }, "file_rules": { "enabled": false, diff --git a/openpype/settings/defaults/project_settings/maya.json b/openpype/settings/defaults/project_settings/maya.json index 99f6874541..d9498c3bc3 100644 --- a/openpype/settings/defaults/project_settings/maya.json +++ b/openpype/settings/defaults/project_settings/maya.json @@ -2,11 +2,7 @@ "imageio": { "ocio_config": { "enabled": false, - "filepath": { - "windows": "", - "darwin": "", - "linux": "" - } + "filepath": [] }, "file_rules": { "enabled": false, @@ -170,24 +166,6 @@ "Main" ] }, - "CreateMultiverseUsd": { - "enabled": true, - "defaults": [ - "Main" - ] - }, - "CreateMultiverseUsdComp": { - "enabled": true, - "defaults": [ - "Main" - ] - }, - "CreateMultiverseUsdOver": { - "enabled": true, - "defaults": [ - "Main" - ] - }, "CreateAss": { "enabled": true, "defaults": [ @@ -208,6 +186,24 @@ "maskColor_manager": false, "maskOperator": false }, + "CreateMultiverseUsd": { + "enabled": true, + "defaults": [ + "Main" + ] + }, + "CreateMultiverseUsdComp": { + "enabled": true, + "defaults": [ + "Main" + ] + }, + "CreateMultiverseUsdOver": { + "enabled": true, + "defaults": [ + "Main" + ] + }, "CreateAssembly": { "enabled": true, "defaults": [ @@ -1052,4 +1048,4 @@ "ValidateNoAnimation": false } } -} +} \ No newline at end of file diff --git a/openpype/settings/defaults/project_settings/nuke.json b/openpype/settings/defaults/project_settings/nuke.json index 08d741ee24..cde216d53e 100644 --- a/openpype/settings/defaults/project_settings/nuke.json +++ b/openpype/settings/defaults/project_settings/nuke.json @@ -12,11 +12,7 @@ "enabled": false, "ocio_config": { "enabled": false, - "filepath": { - "windows": "", - "darwin": "", - "linux": "" - } + "filepath": [] }, "file_rules": { "enabled": false, diff --git a/openpype/settings/defaults/project_settings/photoshop.json b/openpype/settings/defaults/project_settings/photoshop.json index ba82fe4f04..cdfab0c439 100644 --- a/openpype/settings/defaults/project_settings/photoshop.json +++ b/openpype/settings/defaults/project_settings/photoshop.json @@ -2,11 +2,7 @@ "imageio": { "ocio_config": { "enabled": false, - "filepath": { - "windows": "", - "darwin": "", - "linux": "" - } + "filepath": [] }, "file_rules": { "enabled": false, diff --git a/openpype/settings/defaults/project_settings/resolve.json b/openpype/settings/defaults/project_settings/resolve.json index 4cf52bc7f8..66013c5ac7 100644 --- a/openpype/settings/defaults/project_settings/resolve.json +++ b/openpype/settings/defaults/project_settings/resolve.json @@ -2,11 +2,7 @@ "imageio": { "ocio_config": { "enabled": false, - "filepath": { - "windows": "", - "darwin": "", - "linux": "" - } + "filepath": [] }, "file_rules": { "enabled": false, diff --git a/openpype/settings/defaults/project_settings/traypublisher.json b/openpype/settings/defaults/project_settings/traypublisher.json index 6b0f0a70dc..8a222a6dd2 100644 --- a/openpype/settings/defaults/project_settings/traypublisher.json +++ b/openpype/settings/defaults/project_settings/traypublisher.json @@ -2,11 +2,7 @@ "imageio": { "ocio_config": { "enabled": false, - "filepath": { - "windows": "", - "darwin": "", - "linux": "" - } + "filepath": [] }, "file_rules": { "enabled": false, diff --git a/openpype/settings/defaults/project_settings/tvpaint.json b/openpype/settings/defaults/project_settings/tvpaint.json index 0dfbfde0a5..5a3e1dc2df 100644 --- a/openpype/settings/defaults/project_settings/tvpaint.json +++ b/openpype/settings/defaults/project_settings/tvpaint.json @@ -2,11 +2,7 @@ "imageio": { "ocio_config": { "enabled": false, - "filepath": { - "windows": "", - "darwin": "", - "linux": "" - } + "filepath": [] }, "file_rules": { "enabled": false, diff --git a/openpype/settings/defaults/project_settings/unreal.json b/openpype/settings/defaults/project_settings/unreal.json index a33ee33729..b06bf28714 100644 --- a/openpype/settings/defaults/project_settings/unreal.json +++ b/openpype/settings/defaults/project_settings/unreal.json @@ -2,11 +2,7 @@ "imageio": { "ocio_config": { "enabled": false, - "filepath": { - "windows": "", - "darwin": "", - "linux": "" - } + "filepath": [] }, "file_rules": { "enabled": false, diff --git a/openpype/settings/defaults/project_settings/webpublisher.json b/openpype/settings/defaults/project_settings/webpublisher.json index d0752915c4..27eac131b7 100644 --- a/openpype/settings/defaults/project_settings/webpublisher.json +++ b/openpype/settings/defaults/project_settings/webpublisher.json @@ -2,11 +2,7 @@ "imageio": { "ocio_config": { "enabled": false, - "filepath": { - "windows": "", - "darwin": "", - "linux": "" - } + "filepath": [] }, "file_rules": { "enabled": false, diff --git a/openpype/settings/entities/schemas/projects_schema/schema_project_global.json b/openpype/settings/entities/schemas/projects_schema/schema_project_global.json index b8fa4cab5a..6f31f4f685 100644 --- a/openpype/settings/entities/schemas/projects_schema/schema_project_global.json +++ b/openpype/settings/entities/schemas/projects_schema/schema_project_global.json @@ -12,8 +12,19 @@ "is_group": true, "children": [ { - "type": "schema", - "name": "schema_imageio_config" + "key": "ocio_config", + "type": "dict", + "label": "OCIO config", + "collapsible": true, + "children": [ + { + "type": "path", + "key": "filepath", + "label": "Config path", + "multiplatform": false, + "multipath": true + } + ] }, { "type": "schema", diff --git a/openpype/settings/entities/schemas/projects_schema/schemas/schema_imageio_config.json b/openpype/settings/entities/schemas/projects_schema/schemas/schema_imageio_config.json index 3425ea1987..e7cff969d3 100644 --- a/openpype/settings/entities/schemas/projects_schema/schemas/schema_imageio_config.json +++ b/openpype/settings/entities/schemas/projects_schema/schemas/schema_imageio_config.json @@ -14,8 +14,8 @@ "type": "path", "key": "filepath", "label": "Config path", - "multiplatform": true, - "multipath": false + "multiplatform": false, + "multipath": true } ] } \ No newline at end of file