Skip to content

Commit

Permalink
Merge pull request #74 from ynput/enhancement/OP-8206_Core-use-AYON-s…
Browse files Browse the repository at this point in the history
…ettings

Core: Use AYON settings
  • Loading branch information
iLLiCiTiT authored Feb 19, 2024
2 parents 26162d4 + 76ffe57 commit 8f8358e
Show file tree
Hide file tree
Showing 25 changed files with 182 additions and 302 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -194,13 +194,13 @@ def get_detail_description(self):
name into created subset name.
Position of composition name could be set in
`project_settings/global/tools/creator/subset_name_profiles` with some
form of '{composition}' placeholder.
`project_settings/global/tools/creator/product_name_profiles` with
some form of '{composition}' placeholder.
Composition name will be used implicitly if multiple composition should
be handled at same time.
If {composition} placeholder is not us 'subset_name_profiles'
If {composition} placeholder is not us 'product_name_profiles'
composition name will be capitalized and set at the end of subset name
if necessary.
Expand Down
2 changes: 1 addition & 1 deletion client/ayon_core/hosts/nuke/api/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,7 @@ def get_colorspace_from_node(node):
def get_review_presets_config():
settings = get_current_project_settings()
review_profiles = (
settings["global"]
settings["core"]
["publish"]
["ExtractReview"]
["profiles"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,8 @@ def get_detail_description(self):
'Use layer name in subset' will explicitly add layer name into subset
name. Position of this name is configurable in
`project_settings/global/tools/creator/subset_name_profiles`.
If layer placeholder ({layer}) is not used in `subset_name_profiles`
`project_settings/global/tools/creator/product_name_profiles`.
If layer placeholder ({layer}) is not used in `product_name_profiles`
but layer name should be used (set explicitly in UI or implicitly if
multiple images should be created), it is added in capitalized form
as a suffix to subset name.
Expand Down
7 changes: 4 additions & 3 deletions client/ayon_core/lib/applications.py
Original file line number Diff line number Diff line change
Expand Up @@ -1656,8 +1656,9 @@ def apply_project_environments_value(
if project_settings is None:
project_settings = get_project_settings(project_name)

env_value = project_settings["global"]["project_environments"]
env_value = project_settings["core"]["project_environments"]
if env_value:
env_value = json.loads(env_value)
parsed_value = parse_environments(env_value, env_group)
env.update(acre.compute(
_merge_env(parsed_value, env),
Expand Down Expand Up @@ -1916,7 +1917,7 @@ def should_start_last_workfile(
project_settings = get_project_settings(project_name)
profiles = (
project_settings
["global"]
["core"]
["tools"]
["Workfiles"]
["last_workfile_on_startup"]
Expand Down Expand Up @@ -1966,7 +1967,7 @@ def should_workfile_tool_start(
project_settings = get_project_settings(project_name)
profiles = (
project_settings
["global"]
["core"]
["tools"]
["Workfiles"]
["open_workfile_tool_on_startup"]
Expand Down
9 changes: 6 additions & 3 deletions client/ayon_core/lib/transcoding.py
Original file line number Diff line number Diff line change
Expand Up @@ -1385,23 +1385,26 @@ def _get_image_dimensions(application, input_path, log):

def convert_color_values(application, color_value):
"""Get color mapping for ffmpeg and oiiotool.
Args:
application (str): Application for which command should be created.
color_value (list[int]): List of 8bit int values for RGBA.
color_value (tuple[int, int, int, float]): List of 8bit int values
for RGBA.
Returns:
str: ffmpeg returns hex string, oiiotool is string with floats.
"""
red, green, blue, alpha = color_value

if application == "ffmpeg":
return "{0:0>2X}{1:0>2X}{2:0>2X}@{3}".format(
red, green, blue, (alpha / 255.0)
red, green, blue, alpha
)
elif application == "oiiotool":
red = float(red / 255)
green = float(green / 255)
blue = float(blue / 255)
alpha = float(alpha / 255)

return "{0:.3f},{1:.3f},{2:.3f},{3:.3f}".format(
red, green, blue, alpha)
Expand Down
2 changes: 1 addition & 1 deletion client/ayon_core/pipeline/colorspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -1018,7 +1018,7 @@ def _get_imageio_settings(project_settings, host_name):
tuple[dict, dict]: image io settings for global and host
"""
# get image io from global and host_name
imageio_global = project_settings["global"]["imageio"]
imageio_global = project_settings["core"]["imageio"]
# host is optional, some might not have any settings
imageio_host = project_settings.get(host_name, {}).get("imageio", {})

Expand Down
4 changes: 2 additions & 2 deletions client/ayon_core/pipeline/context_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,8 @@ def install_ayon_plugins(project_name=None, host_name=None):
platform_name = platform.system().lower()
project_plugins = (
project_settings
.get("global", {})
.get("project_plugins", {})
["core"]
["project_plugins"]
.get(platform_name)
) or []
for path in project_plugins:
Expand Down
2 changes: 1 addition & 1 deletion client/ayon_core/pipeline/create/legacy_create.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def apply_settings(cls, project_settings, system_settings):
)
global_type_settings = (
project_settings
.get("global", {})
.get("core", {})
.get(plugin_type, {})
)
if not global_type_settings and not plugin_type_settings:
Expand Down
26 changes: 19 additions & 7 deletions client/ayon_core/pipeline/create/subset_name.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ def get_subset_name_template(

if project_settings is None:
project_settings = get_project_settings(project_name)
tools_settings = project_settings["global"]["tools"]
profiles = tools_settings["creator"]["subset_name_profiles"]
tools_settings = project_settings["core"]["tools"]
profiles = tools_settings["creator"]["product_name_profiles"]
filtering_criteria = {
"families": family,
"product_types": family,
"hosts": host_name,
"tasks": task_name,
"task_types": task_type
Expand All @@ -59,7 +59,19 @@ def get_subset_name_template(
matching_profile = filter_profiles(profiles, filtering_criteria)
template = None
if matching_profile:
template = matching_profile["template"]
# TODO remove formatting keys replacement
template = (
matching_profile["template"]
.replace("{task[name]}", "{task}")
.replace("{Task[name]}", "{Task}")
.replace("{TASK[NAME]}", "{TASK}")
.replace("{product[type]}", "{family}")
.replace("{Product[type]}", "{Family}")
.replace("{PRODUCT[TYPE]}", "{FAMILY}")
.replace("{folder[name]}", "{asset}")
.replace("{Folder[name]}", "{Asset}")
.replace("{FOLDER[NAME]}", "{ASSET}")
)

# Make sure template is set (matching may have empty string)
if not template:
Expand All @@ -82,9 +94,9 @@ def get_subset_name(
"""Calculate subset name based on passed context and OpenPype settings.
Subst name templates are defined in `project_settings/global/tools/creator
/subset_name_profiles` where are profiles with host name, family, task name
and task type filters. If context does not match any profile then
`DEFAULT_SUBSET_TEMPLATE` is used as default template.
/product_name_profiles` where are profiles with host name, family,
task name and task type filters. If context does not match any profile
then `DEFAULT_SUBSET_TEMPLATE` is used as default template.
That's main reason why so many arguments are required to calculate subset
name.
Expand Down
2 changes: 1 addition & 1 deletion client/ayon_core/pipeline/load/plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def apply_settings(cls, project_settings, system_settings):
)
global_type_settings = (
project_settings
.get("global", {})
.get("core", {})
.get(plugin_type, {})
)
if not global_type_settings and not plugin_type_settings:
Expand Down
2 changes: 1 addition & 1 deletion client/ayon_core/pipeline/project_folders.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def _list_path_items(folder_structure):
def get_project_basic_paths(project_name):
project_settings = get_project_settings(project_name)
folder_structure = (
project_settings["global"]["project_folder_structure"]
project_settings["core"]["project_folder_structure"]
)
if not folder_structure:
return []
Expand Down
10 changes: 5 additions & 5 deletions client/ayon_core/pipeline/publish/lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def get_template_name_profiles(

return copy.deepcopy(
project_settings
["global"]
["core"]
["tools"]
["publish"]
["template_name_profiles"]
Expand Down Expand Up @@ -95,7 +95,7 @@ def get_hero_template_name_profiles(

return copy.deepcopy(
project_settings
["global"]
["core"]
["tools"]
["publish"]
["hero_template_name_profiles"]
Expand Down Expand Up @@ -138,7 +138,7 @@ def get_publish_template_name(
template = None
filter_criteria = {
"hosts": host_name,
"families": family,
"product_types": family,
"task_names": task_name,
"task_types": task_type,
}
Expand Down Expand Up @@ -383,7 +383,7 @@ def get_plugin_settings(plugin, project_settings, log, category=None):

# TODO: change after all plugins are moved one level up
if category_from_file in ("ayon_core", "openpype"):
category_from_file = "global"
category_from_file = "core"

try:
return (
Expand Down Expand Up @@ -744,7 +744,7 @@ def get_custom_staging_dir_info(project_name, host_name, family, task_name,
ValueError - if misconfigured template should be used
"""
settings = project_settings or get_project_settings(project_name)
custom_staging_dir_profiles = (settings["global"]
custom_staging_dir_profiles = (settings["core"]
["tools"]
["publish"]
["custom_staging_dir_profiles"])
Expand Down
2 changes: 1 addition & 1 deletion client/ayon_core/pipeline/version_start.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def get_versioning_start(
project_settings = get_project_settings(project_name)

version_start = 1
settings = project_settings["global"]
settings = project_settings["core"]
profiles = settings.get("version_start_category", {}).get("profiles", [])

if not profiles:
Expand Down
2 changes: 1 addition & 1 deletion client/ayon_core/pipeline/workfile/lock_workfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def is_workfile_lock_enabled(host_name, project_name, project_setting=None):
project_setting = get_project_settings(project_name)
workfile_lock_profiles = (
project_setting
["global"]
["core"]
["tools"]
["Workfiles"]
["workfile_lock_profiles"])
Expand Down
4 changes: 2 additions & 2 deletions client/ayon_core/pipeline/workfile/path_resolving.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def get_workfile_template_key(
try:
profiles = (
project_settings
["global"]
["core"]
["tools"]
["Workfiles"]
["workfile_template_profiles"]
Expand Down Expand Up @@ -507,7 +507,7 @@ def create_workdir_extra_folders(

# Load extra folders profiles
extra_folders_profiles = (
project_settings["global"]["tools"]["Workfiles"]["extra_folders"]
project_settings["core"]["tools"]["Workfiles"]["extra_folders"]
)
# Skip if are empty
if not extra_folders_profiles:
Expand Down
20 changes: 10 additions & 10 deletions client/ayon_core/plugins/publish/cleanup.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class CleanUp(pyblish.api.InstancePlugin):
active = True

# Presets
paterns = None # list of regex paterns
patterns = None # list of regex patterns
remove_temp_renders = True

def process(self, instance):
Expand Down Expand Up @@ -115,10 +115,10 @@ def clean_renders(self, instance, skip_cleanup_filepaths):
src = os.path.normpath(src)
dest = os.path.normpath(dest)

# add src dir into clearing dir paths (regex paterns)
# add src dir into clearing dir paths (regex patterns)
transfers_dirs.append(os.path.dirname(src))

# add dest dir into clearing dir paths (regex paterns)
# add dest dir into clearing dir paths (regex patterns)
transfers_dirs.append(os.path.dirname(dest))

if src in skip_cleanup_filepaths:
Expand All @@ -141,13 +141,13 @@ def clean_renders(self, instance, skip_cleanup_filepaths):
# add dir for cleanup
dirnames.append(os.path.dirname(src))

# clean by regex paterns
# clean by regex patterns
# make unique set
transfers_dirs = set(transfers_dirs)

self.log.debug("__ transfers_dirs: `{}`".format(transfers_dirs))
self.log.debug("__ self.paterns: `{}`".format(self.paterns))
if self.paterns:
self.log.debug("__ self.patterns: `{}`".format(self.patterns))
if self.patterns:
files = list()
# get list of all available content of dirs
for _dir in transfers_dirs:
Expand All @@ -159,14 +159,14 @@ def clean_renders(self, instance, skip_cleanup_filepaths):

self.log.debug("__ files: `{}`".format(files))

# remove all files which match regex patern
# remove all files which match regex pattern
for f in files:
if os.path.normpath(f) in skip_cleanup_filepaths:
continue

for p in self.paterns:
patern = re.compile(p)
if not patern.findall(f):
for p in self.patterns:
pattern = re.compile(p)
if not pattern.findall(f):
continue
if not os.path.exists(f):
continue
Expand Down
2 changes: 1 addition & 1 deletion client/ayon_core/plugins/publish/collect_comment.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def process(self, instance):

@classmethod
def apply_settings(cls, project_setting, _):
plugin_settings = project_setting["global"]["publish"].get(
plugin_settings = project_setting["core"]["publish"].get(
"collect_comment_per_instance"
)
if not plugin_settings:
Expand Down
Loading

0 comments on commit 8f8358e

Please sign in to comment.