mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-24 21:04:40 +01:00
Append {version} regex to staging dir.
This commit is contained in:
parent
a60796eb73
commit
f5a67f099d
3 changed files with 33 additions and 15 deletions
|
|
@ -7,7 +7,7 @@ from typing import TYPE_CHECKING, Optional, Dict, Any
|
|||
from abc import ABC, abstractmethod
|
||||
|
||||
from ayon_core.settings import get_project_settings
|
||||
from ayon_core.lib import Logger
|
||||
from ayon_core.lib import Logger, get_version_from_path
|
||||
from ayon_core.pipeline.plugin_discover import (
|
||||
discover,
|
||||
register_plugin,
|
||||
|
|
@ -860,6 +860,14 @@ class Creator(BaseCreator):
|
|||
else:
|
||||
template_data = {}
|
||||
|
||||
# TODO: confirm feature
|
||||
anatomy_data_settings = self.project_settings["core"]["publish"]["CollectAnatomyInstanceData"]
|
||||
follow_workfile_version = anatomy_data_settings["follow_workfile_version"]
|
||||
if follow_workfile_version:
|
||||
current_workfile = self.create_context.get_current_workfile_path()
|
||||
workfile_version = get_version_from_path(current_workfile)
|
||||
template_data = {"version": int(workfile_version)}
|
||||
|
||||
staging_dir_info = get_staging_dir_info(
|
||||
create_ctx.get_current_project_entity(),
|
||||
create_ctx.get_current_folder_entity(),
|
||||
|
|
@ -877,12 +885,15 @@ class Creator(BaseCreator):
|
|||
if not staging_dir_info:
|
||||
return None
|
||||
|
||||
staging_dir_path = staging_dir_info["stagingDir"]
|
||||
staging_dir_path = staging_dir_info.dir
|
||||
|
||||
# path might be already created by get_staging_dir_info
|
||||
os.makedirs(staging_dir_path, exist_ok=True)
|
||||
|
||||
instance.transient_data.update(staging_dir_info)
|
||||
instance.transient_data.update({
|
||||
"stagingDir": staging_dir_path,
|
||||
"stagingDir_persistent": staging_dir_info.persistent,
|
||||
})
|
||||
|
||||
self.log.info(f"Applied staging dir to instance: {staging_dir_path}")
|
||||
|
||||
|
|
|
|||
|
|
@ -710,12 +710,14 @@ def get_instance_staging_dir(instance):
|
|||
always_return_path=True,
|
||||
)
|
||||
|
||||
staging_dir_path = staging_dir_info["stagingDir"]
|
||||
staging_dir_path = staging_dir_info.dir
|
||||
|
||||
# path might be already created by get_staging_dir_info
|
||||
os.makedirs(staging_dir_path, exist_ok=True)
|
||||
|
||||
instance.data.update(staging_dir_info)
|
||||
instance.data.update({
|
||||
"stagingDir": staging_dir_path,
|
||||
"stagingDir_persistent": staging_dir_info.persistent,
|
||||
})
|
||||
|
||||
return staging_dir_path
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
from collections import namedtuple
|
||||
|
||||
from ayon_core.lib import Logger, filter_profiles, StringTemplate
|
||||
from ayon_core.settings import get_project_settings
|
||||
|
||||
|
|
@ -6,6 +8,9 @@ from .anatomy import Anatomy
|
|||
from .tempdir import get_temp_dir
|
||||
|
||||
|
||||
StagingDir = namedtuple("StagingDir", ["dir", "persistent"])
|
||||
|
||||
|
||||
def get_staging_dir_config(
|
||||
project_name,
|
||||
task_type,
|
||||
|
|
@ -144,7 +149,7 @@ def get_staging_dir_info(
|
|||
suffix (Optional[str]): Optional suffix for staging dir name.
|
||||
|
||||
Returns:
|
||||
Optional[Dict[str, Any]]: Staging dir info data
|
||||
Optional[StagingDir]: Staging dir info data
|
||||
|
||||
"""
|
||||
task_entity = task_entity or {}
|
||||
|
|
@ -195,24 +200,24 @@ def get_staging_dir_info(
|
|||
)
|
||||
|
||||
if staging_dir_config:
|
||||
return {
|
||||
"stagingDir": StringTemplate.format_template(
|
||||
return StagingDir(
|
||||
StringTemplate.format_template(
|
||||
str(staging_dir_config["template"]["directory"]),
|
||||
ctx_data
|
||||
),
|
||||
"stagingDir_persistent": staging_dir_config["persistence"],
|
||||
}
|
||||
staging_dir_config["persistence"],
|
||||
)
|
||||
|
||||
# no config found but force an output
|
||||
if always_return_path:
|
||||
return {
|
||||
"stagingDir": get_temp_dir(
|
||||
return StagingDir(
|
||||
get_temp_dir(
|
||||
project_name=project_entity["name"],
|
||||
anatomy=anatomy,
|
||||
prefix=prefix,
|
||||
suffix=suffix,
|
||||
),
|
||||
"stagingDir_persistent": False,
|
||||
}
|
||||
False,
|
||||
)
|
||||
|
||||
return None
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue