mirror of
https://github.com/ynput/ayon-core.git
synced 2026-01-01 16:34:53 +01:00
Address feedback from PR.
This commit is contained in:
parent
eabe9674e0
commit
e96133b348
4 changed files with 31 additions and 37 deletions
|
|
@ -873,7 +873,7 @@ class Creator(BaseCreator):
|
|||
)
|
||||
|
||||
if not staging_dir_info:
|
||||
return
|
||||
return None
|
||||
|
||||
staging_dir_path = staging_dir_info["stagingDir"]
|
||||
|
||||
|
|
|
|||
|
|
@ -707,6 +707,7 @@ def get_instance_staging_dir(instance):
|
|||
anatomy=context.data["anatomy"],
|
||||
project_settings=context.data["project_settings"],
|
||||
template_data=template_data,
|
||||
always_return_path=True,
|
||||
)
|
||||
|
||||
staging_dir_path = staging_dir_info["stagingDir"]
|
||||
|
|
|
|||
|
|
@ -77,7 +77,7 @@ def get_staging_dir_config(
|
|||
# template should always be found either from anatomy or from profile
|
||||
raise ValueError(
|
||||
"Staging dir profile is misconfigured! "
|
||||
"No template was found for profile! "
|
||||
f"No template was found for profile: {profile}! "
|
||||
"Check your project settings at: "
|
||||
"'ayon+settings://core/tools/publish/custom_staging_dir_profiles'"
|
||||
)
|
||||
|
|
@ -112,10 +112,11 @@ def get_staging_dir_info(
|
|||
anatomy=None,
|
||||
project_settings=None,
|
||||
template_data=None,
|
||||
always_return_path=None,
|
||||
force_tmp_dir=None,
|
||||
always_return_path=True,
|
||||
force_tmp_dir=False,
|
||||
logger=None,
|
||||
**kwargs
|
||||
prefix=None,
|
||||
suffix=None,
|
||||
):
|
||||
"""Get staging dir info data.
|
||||
|
||||
|
|
@ -141,11 +142,8 @@ def get_staging_dir_info(
|
|||
force_tmp_dir (Optional[bool]): If True, staging dir will be created as
|
||||
tempdir.
|
||||
logger (Optional[logging.Logger]): Logger instance.
|
||||
**kwargs: Arbitrary keyword arguments. See below.
|
||||
|
||||
Keyword Arguments:
|
||||
prefix (str): Prefix for staging dir.
|
||||
suffix (str): Suffix for staging dir.
|
||||
prefix (Optional[str]) Optional prefix for staging dir name.
|
||||
suffix (Optional[str]): Optional suffix for staging dir name.
|
||||
|
||||
Returns:
|
||||
Optional[Dict[str, Any]]: Staging dir info data
|
||||
|
|
@ -153,10 +151,6 @@ def get_staging_dir_info(
|
|||
"""
|
||||
log = logger or Logger.get_logger("get_staging_dir_info")
|
||||
|
||||
# make sure always_return_path is set to true by default
|
||||
if always_return_path is None:
|
||||
always_return_path = True
|
||||
|
||||
if anatomy is None:
|
||||
anatomy = Anatomy(
|
||||
project_entity["name"], project_entity=project_entity
|
||||
|
|
@ -166,11 +160,11 @@ def get_staging_dir_info(
|
|||
return get_temp_dir(
|
||||
project_name=project_entity["name"],
|
||||
anatomy=anatomy,
|
||||
prefix=kwargs.get("prefix"),
|
||||
suffix=kwargs.get("suffix"),
|
||||
prefix=prefix,
|
||||
suffix=suffix,
|
||||
)
|
||||
|
||||
# making fewer queries to database
|
||||
# making few queries to database
|
||||
ctx_data = get_template_data(
|
||||
project_entity, folder_entity, task_entity, host_name
|
||||
)
|
||||
|
|
@ -192,8 +186,8 @@ def get_staging_dir_info(
|
|||
staging_dir_config = get_staging_dir_config(
|
||||
host_name,
|
||||
project_entity["name"],
|
||||
task_entity["type"],
|
||||
task_entity["name"],
|
||||
task_entity.get("type"),
|
||||
task_entity.get("name"),
|
||||
product_type,
|
||||
product_name,
|
||||
project_settings=project_settings,
|
||||
|
|
@ -201,19 +195,19 @@ def get_staging_dir_info(
|
|||
log=log,
|
||||
)
|
||||
|
||||
# if no preset matching and always_get_some_dir is set, return tempdir
|
||||
if not staging_dir_config and always_return_path:
|
||||
return {
|
||||
"stagingDir": get_temp_dir(
|
||||
project_name=project_entity["name"],
|
||||
anatomy=anatomy,
|
||||
prefix=kwargs.get("prefix"),
|
||||
suffix=kwargs.get("suffix"),
|
||||
),
|
||||
"stagingDir_persistent": False,
|
||||
}
|
||||
if not staging_dir_config:
|
||||
return None
|
||||
if always_return_path: # no config found but force an output
|
||||
return {
|
||||
"stagingDir": get_temp_dir(
|
||||
project_name=project_entity["name"],
|
||||
anatomy=anatomy,
|
||||
prefix=kwargs.get("prefix"),
|
||||
suffix=kwargs.get("suffix"),
|
||||
),
|
||||
"stagingDir_persistent": False,
|
||||
}
|
||||
else:
|
||||
return None
|
||||
|
||||
return {
|
||||
"stagingDir": StringTemplate.format_template(
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ Temporary folder operations
|
|||
import os
|
||||
import tempfile
|
||||
from pathlib import Path
|
||||
|
||||
from ayon_core.lib import StringTemplate
|
||||
from ayon_core.pipeline import Anatomy
|
||||
|
||||
|
|
@ -48,7 +49,7 @@ def get_temp_dir(
|
|||
# get customized tempdir path from `OPENPYPE_TMPDIR` env var
|
||||
custom_temp_dir = _create_custom_tempdir(anatomy.project_name, anatomy)
|
||||
|
||||
return _create_local_staging_dir(prefix, suffix, custom_temp_dir)
|
||||
return _create_local_staging_dir(prefix, suffix, dirpath=custom_temp_dir)
|
||||
|
||||
|
||||
def _create_local_staging_dir(prefix, suffix, dirpath=None):
|
||||
|
|
@ -70,7 +71,7 @@ def _create_local_staging_dir(prefix, suffix, dirpath=None):
|
|||
return staging_dir.as_posix()
|
||||
|
||||
|
||||
def _create_custom_tempdir(project_name, anatomy=None):
|
||||
def _create_custom_tempdir(project_name, anatomy):
|
||||
""" Create custom tempdir
|
||||
|
||||
Template path formatting is supporting:
|
||||
|
|
@ -81,19 +82,17 @@ def _create_custom_tempdir(project_name, anatomy=None):
|
|||
|
||||
Args:
|
||||
project_name (str): project name
|
||||
anatomy (ayon_core.pipeline.Anatomy)[optional]: Anatomy object
|
||||
anatomy (ayon_core.pipeline.Anatomy): Anatomy object
|
||||
|
||||
Returns:
|
||||
str | None: formatted path or None
|
||||
"""
|
||||
env_tmpdir = os.getenv("AYON_TMPDIR")
|
||||
if not env_tmpdir:
|
||||
return
|
||||
return None
|
||||
|
||||
custom_tempdir = None
|
||||
if "{" in env_tmpdir:
|
||||
if anatomy is None:
|
||||
anatomy = Anatomy(project_name)
|
||||
# create base formate data
|
||||
template_data = {
|
||||
"root": anatomy.roots,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue