Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom staging dir functionality migration #887

Open
wants to merge 16 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 8 additions & 19 deletions client/ayon_core/pipeline/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@

from .anatomy import Anatomy

from .tempdir import get_temp_dir

from .stagingdir import get_staging_dir

from .create import (
BaseCreator,
Creator,
Expand Down Expand Up @@ -116,104 +120,89 @@
"AYON_CONTAINER_ID",
"AYON_INSTANCE_ID",
"HOST_WORKFILE_EXTENSIONS",

jakubjezek001 marked this conversation as resolved.
Show resolved Hide resolved
# --- Anatomy ---
"Anatomy",

# --- Temp dir ---
"get_temp_dir",
# --- Staging dir ---
"get_staging_dir",
# --- Create ---
"BaseCreator",
"Creator",
"AutoCreator",
"HiddenCreator",
"CreatedInstance",
"CreatorError",

"CreatorError",

# - legacy creation
"LegacyCreator",
"legacy_create",

"discover_creator_plugins",
"discover_legacy_creator_plugins",
"register_creator_plugin",
"deregister_creator_plugin",
"register_creator_plugin_path",
"deregister_creator_plugin_path",

# --- Load ---
"HeroVersionType",
"IncompatibleLoaderError",
"LoaderPlugin",
"ProductLoaderPlugin",

"discover_loader_plugins",
"register_loader_plugin",
"deregister_loader_plugin_path",
"register_loader_plugin_path",
"deregister_loader_plugin",

"load_container",
"remove_container",
"update_container",
"switch_container",

"loaders_from_representation",
"get_representation_path",
"get_representation_context",
"get_repres_contexts",

# --- Publish ---
"PublishValidationError",
"PublishXmlValidationError",
"KnownPublishError",
"AYONPyblishPluginMixin",
"OpenPypePyblishPluginMixin",
"OptionalPyblishPluginMixin",

# --- Actions ---
"LauncherAction",
"InventoryAction",

"discover_launcher_actions",
"register_launcher_action",
"register_launcher_action_path",

"discover_inventory_actions",
"register_inventory_action",
"register_inventory_action_path",
"deregister_inventory_action",
"deregister_inventory_action_path",

# --- Process context ---
"install_ayon_plugins",
"install_openpype_plugins",
"install_host",
"uninstall_host",
"is_installed",

"register_root",
"registered_root",

"register_host",
"registered_host",
"deregister_host",
"get_process_id",

"get_global_context",
"get_current_context",
"get_current_host_name",
"get_current_project_name",
"get_current_folder_path",
"get_current_task_name",

# Workfile templates
"discover_workfile_build_plugins",
"register_workfile_build_plugin",
"deregister_workfile_build_plugin",
"register_workfile_build_plugin_path",
"deregister_workfile_build_plugin_path",

# Backwards compatible function names
"install",
"uninstall",
Expand Down
55 changes: 55 additions & 0 deletions client/ayon_core/pipeline/create/creator_plugins.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# -*- coding: utf-8 -*-
import os
import copy
import collections
from typing import TYPE_CHECKING, Optional
Expand All @@ -14,6 +15,7 @@
deregister_plugin,
deregister_plugin_path
)
from ayon_core.pipeline import get_staging_dir

from .constants import DEFAULT_VARIANT_VALUE
from .product_name import get_product_name
Expand Down Expand Up @@ -782,6 +784,59 @@ def get_pre_create_attr_defs(self):
"""
return self.pre_create_attr_defs

def apply_staging_dir(self, instance):
"""Apply staging dir with persistence to instance's transient data.

Method is called on instance creation and on instance update.

Args:
instance (CreatedInstance): Instance for which should be staging
dir applied.

Returns:
str: Path to staging dir.
"""
create_ctx = self.create_context
product_name = instance.get("productName")
product_type = instance.get("productType")
folder_path = instance.get("folderPath")
if not any([product_name, folder_path]):
jakubjezek001 marked this conversation as resolved.
Show resolved Hide resolved
return None

version = instance.get("version")
if version is not None:
formatting_data = {"version": version}

staging_dir_data = get_staging_dir(
create_ctx.host_name,
create_ctx.get_current_project_entity(),
create_ctx.get_current_folder_entity(),
create_ctx.get_current_task_entity(),
product_type,
product_name,
create_ctx.get_current_project_anatomy(),
create_ctx.get_current_project_settings(),
always_return_path=False,
log=self.log,
formatting_data=formatting_data,
)

if not staging_dir_data:
return None

staging_dir_path = staging_dir_data["stagingDir"]

# TODO: not sure if this is necessary
# path might be already created by get_staging_dir
if not os.path.exists(staging_dir_path):
os.makedirs(staging_dir_path)
jakubjezek001 marked this conversation as resolved.
Show resolved Hide resolved

instance.transient_data.update(staging_dir_data)

self.log.info(f"Applied staging dir to instance: {staging_dir_path}")

return staging_dir_path


class HiddenCreator(BaseCreator):
@abstractmethod
Expand Down
1 change: 0 additions & 1 deletion client/ayon_core/pipeline/publish/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,3 @@

DEFAULT_PUBLISH_TEMPLATE = "default"
DEFAULT_HERO_PUBLISH_TEMPLATE = "default"
TRANSIENT_DIR_TEMPLATE = "default"
Loading
Loading