Chore: Remove deprecated functions (#5323)

* removed deprecated files from root of openpype

* removed deprecated content from openype/lib

* fix imports
This commit is contained in:
Jakub Trllo 2023-07-25 16:19:14 +02:00 committed by GitHub
parent cc1e522dfb
commit f0801cb098
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 3 additions and 1620 deletions

View file

@ -1,135 +0,0 @@
import warnings
import functools
import pyblish.api
class ActionDeprecatedWarning(DeprecationWarning):
pass
def deprecated(new_destination):
"""Mark functions as deprecated.
It will result in a warning being emitted when the function is used.
"""
func = None
if callable(new_destination):
func = new_destination
new_destination = None
def _decorator(decorated_func):
if new_destination is None:
warning_message = (
" Please check content of deprecated function to figure out"
" possible replacement."
)
else:
warning_message = " Please replace your usage with '{}'.".format(
new_destination
)
@functools.wraps(decorated_func)
def wrapper(*args, **kwargs):
warnings.simplefilter("always", ActionDeprecatedWarning)
warnings.warn(
(
"Call to deprecated function '{}'"
"\nFunction was moved or removed.{}"
).format(decorated_func.__name__, warning_message),
category=ActionDeprecatedWarning,
stacklevel=4
)
return decorated_func(*args, **kwargs)
return wrapper
if func is None:
return _decorator
return _decorator(func)
@deprecated("openpype.pipeline.publish.get_errored_instances_from_context")
def get_errored_instances_from_context(context, plugin=None):
"""
Deprecated:
Since 3.14.* will be removed in 3.16.* or later.
"""
from openpype.pipeline.publish import get_errored_instances_from_context
return get_errored_instances_from_context(context, plugin=plugin)
@deprecated("openpype.pipeline.publish.get_errored_plugins_from_context")
def get_errored_plugins_from_data(context):
"""
Deprecated:
Since 3.14.* will be removed in 3.16.* or later.
"""
from openpype.pipeline.publish import get_errored_plugins_from_context
return get_errored_plugins_from_context(context)
class RepairAction(pyblish.api.Action):
"""Repairs the action
To process the repairing this requires a static `repair(instance)` method
is available on the plugin.
Deprecated:
'RepairAction' and 'RepairContextAction' were moved to
'openpype.pipeline.publish' please change you imports.
There is no "reasonable" way hot mark these classes as deprecated
to show warning of wrong import. Deprecated since 3.14.* will be
removed in 3.16.*
"""
label = "Repair"
on = "failed" # This action is only available on a failed plug-in
icon = "wrench" # Icon from Awesome Icon
def process(self, context, plugin):
if not hasattr(plugin, "repair"):
raise RuntimeError("Plug-in does not have repair method.")
# Get the errored instances
self.log.info("Finding failed instances..")
errored_instances = get_errored_instances_from_context(context,
plugin=plugin)
for instance in errored_instances:
plugin.repair(instance)
class RepairContextAction(pyblish.api.Action):
"""Repairs the action
To process the repairing this requires a static `repair(instance)` method
is available on the plugin.
Deprecated:
'RepairAction' and 'RepairContextAction' were moved to
'openpype.pipeline.publish' please change you imports.
There is no "reasonable" way hot mark these classes as deprecated
to show warning of wrong import. Deprecated since 3.14.* will be
removed in 3.16.*
"""
label = "Repair"
on = "failed" # This action is only available on a failed plug-in
def process(self, context, plugin):
if not hasattr(plugin, "repair"):
raise RuntimeError("Plug-in does not have repair method.")
# Get the errored instances
self.log.info("Finding failed instances..")
errored_plugins = get_errored_plugins_from_data(context)
# Apply pyblish.logic to get the instances for the plug-in
if plugin in errored_plugins:
self.log.info("Attempting fix ...")
plugin.repair(context)

View file

@ -53,7 +53,6 @@ from .env_tools import (
from .terminal import Terminal
from .execute import (
get_openpype_execute_args,
get_pype_execute_args,
get_linux_launcher_args,
execute,
run_subprocess,
@ -65,7 +64,6 @@ from .execute import (
)
from .log import (
Logger,
PypeLogger,
)
from .path_templates import (
@ -77,12 +75,6 @@ from .path_templates import (
FormatObject,
)
from .mongo import (
get_default_components,
validate_mongo_connection,
OpenPypeMongoConnection
)
from .dateutils import (
get_datetime_data,
get_timestamp,
@ -115,25 +107,6 @@ from .transcoding import (
convert_ffprobe_fps_value,
convert_ffprobe_fps_to_float,
)
from .avalon_context import (
CURRENT_DOC_SCHEMAS,
create_project,
get_workfile_template_key,
get_workfile_template_key_from_context,
get_last_workfile_with_version,
get_last_workfile,
BuildWorkfile,
get_creator_by_name,
get_custom_workfile_template,
get_custom_workfile_template_by_context,
get_custom_workfile_template_by_string_context,
get_custom_workfile_template
)
from .local_settings import (
IniSettingRegistry,
@ -163,9 +136,6 @@ from .applications import (
)
from .plugin_tools import (
TaskNotSetError,
get_subset_name,
get_subset_name_with_asset_doc,
prepare_template_data,
source_hash,
)
@ -177,9 +147,6 @@ from .path_tools import (
version_up,
get_version_from_path,
get_last_version_from_path,
create_project_folders,
create_workdir_extra_folders,
get_project_basic_paths,
)
from .openpype_version import (
@ -207,7 +174,6 @@ __all__ = [
"find_executable",
"get_openpype_execute_args",
"get_pype_execute_args",
"get_linux_launcher_args",
"execute",
"run_subprocess",
@ -257,22 +223,6 @@ __all__ = [
"convert_ffprobe_fps_value",
"convert_ffprobe_fps_to_float",
"CURRENT_DOC_SCHEMAS",
"create_project",
"get_workfile_template_key",
"get_workfile_template_key_from_context",
"get_last_workfile_with_version",
"get_last_workfile",
"BuildWorkfile",
"get_creator_by_name",
"get_custom_workfile_template_by_context",
"get_custom_workfile_template_by_string_context",
"get_custom_workfile_template",
"IniSettingRegistry",
"JSONSettingRegistry",
"OpenPypeSecureRegistry",
@ -298,9 +248,7 @@ __all__ = [
"filter_profiles",
"TaskNotSetError",
"get_subset_name",
"get_subset_name_with_asset_doc",
"prepare_template_data",
"source_hash",
"format_file_size",
@ -323,15 +271,6 @@ __all__ = [
"get_formatted_current_time",
"Logger",
"PypeLogger",
"get_default_components",
"validate_mongo_connection",
"OpenPypeMongoConnection",
"create_project_folders",
"create_workdir_extra_folders",
"get_project_basic_paths",
"op_version_control_available",
"get_openpype_version",

View file

@ -1,654 +0,0 @@
"""Should be used only inside of hosts."""
import platform
import logging
import functools
import warnings
import six
from openpype.client import (
get_project,
get_asset_by_name,
)
from openpype.client.operations import (
CURRENT_ASSET_DOC_SCHEMA,
CURRENT_PROJECT_SCHEMA,
CURRENT_PROJECT_CONFIG_SCHEMA,
)
from .profiles_filtering import filter_profiles
from .path_templates import StringTemplate
legacy_io = None
log = logging.getLogger("AvalonContext")
# Backwards compatibility - should not be used anymore
# - Will be removed in OP 3.16.*
CURRENT_DOC_SCHEMAS = {
"project": CURRENT_PROJECT_SCHEMA,
"asset": CURRENT_ASSET_DOC_SCHEMA,
"config": CURRENT_PROJECT_CONFIG_SCHEMA
}
class AvalonContextDeprecatedWarning(DeprecationWarning):
pass
def deprecated(new_destination):
"""Mark functions as deprecated.
It will result in a warning being emitted when the function is used.
"""
func = None
if callable(new_destination):
func = new_destination
new_destination = None
def _decorator(decorated_func):
if new_destination is None:
warning_message = (
" Please check content of deprecated function to figure out"
" possible replacement."
)
else:
warning_message = " Please replace your usage with '{}'.".format(
new_destination
)
@functools.wraps(decorated_func)
def wrapper(*args, **kwargs):
warnings.simplefilter("always", AvalonContextDeprecatedWarning)
warnings.warn(
(
"Call to deprecated function '{}'"
"\nFunction was moved or removed.{}"
).format(decorated_func.__name__, warning_message),
category=AvalonContextDeprecatedWarning,
stacklevel=4
)
return decorated_func(*args, **kwargs)
return wrapper
if func is None:
return _decorator
return _decorator(func)
@deprecated("openpype.client.operations.create_project")
def create_project(
project_name, project_code, library_project=False, dbcon=None
):
"""Create project using OpenPype settings.
This project creation function is not validating project document on
creation. It is because project document is created blindly with only
minimum required information about project which is it's name, code, type
and schema.
Entered project name must be unique and project must not exist yet.
Args:
project_name(str): New project name. Should be unique.
project_code(str): Project's code should be unique too.
library_project(bool): Project is library project.
dbcon(AvalonMongoDB): Object of connection to MongoDB.
Raises:
ValueError: When project name already exists in MongoDB.
Returns:
dict: Created project document.
Deprecated:
Function will be removed after release version 3.16.*
"""
from openpype.client.operations import create_project
return create_project(project_name, project_code, library_project)
def with_pipeline_io(func):
@functools.wraps(func)
def wrapped(*args, **kwargs):
global legacy_io
if legacy_io is None:
from openpype.pipeline import legacy_io
return func(*args, **kwargs)
return wrapped
@deprecated("openpype.client.get_linked_asset_ids")
def get_linked_asset_ids(asset_doc):
"""Return linked asset ids for `asset_doc` from DB
Args:
asset_doc (dict): Asset document from DB.
Returns:
(list): MongoDB ids of input links.
Deprecated:
Function will be removed after release version 3.16.*
"""
from openpype.client import get_linked_asset_ids
from openpype.pipeline import legacy_io
project_name = legacy_io.active_project()
return get_linked_asset_ids(project_name, asset_doc=asset_doc)
@deprecated(
"openpype.pipeline.workfile.get_workfile_template_key_from_context")
def get_workfile_template_key_from_context(
asset_name, task_name, host_name, project_name=None,
dbcon=None, project_settings=None
):
"""Helper function to get template key for workfile template.
Do the same as `get_workfile_template_key` but returns value for "session
context".
It is required to pass one of 'dbcon' with already set project name or
'project_name' arguments.
Args:
asset_name(str): Name of asset document.
task_name(str): Task name for which is template key retrieved.
Must be available on asset document under `data.tasks`.
host_name(str): Name of host implementation for which is workfile
used.
project_name(str): Project name where asset and task is. Not required
when 'dbcon' is passed.
dbcon(AvalonMongoDB): Connection to mongo with already set project
under `AVALON_PROJECT`. Not required when 'project_name' is passed.
project_settings(dict): Project settings for passed 'project_name'.
Not required at all but makes function faster.
Raises:
ValueError: When both 'dbcon' and 'project_name' were not
passed.
Deprecated:
Function will be removed after release version 3.16.*
"""
from openpype.pipeline.workfile import (
get_workfile_template_key_from_context
)
if not project_name:
if not dbcon:
raise ValueError((
"`get_workfile_template_key_from_context` requires to pass"
" one of 'dbcon' or 'project_name' arguments."
))
project_name = dbcon.active_project()
return get_workfile_template_key_from_context(
asset_name, task_name, host_name, project_name, project_settings
)
@deprecated(
"openpype.pipeline.workfile.get_workfile_template_key")
def get_workfile_template_key(
task_type, host_name, project_name=None, project_settings=None
):
"""Workfile template key which should be used to get workfile template.
Function is using profiles from project settings to return right template
for passet task type and host name.
One of 'project_name' or 'project_settings' must be passed it is preferred
to pass settings if are already available.
Args:
task_type(str): Name of task type.
host_name(str): Name of host implementation (e.g. "maya", "nuke", ...)
project_name(str): Name of project in which context should look for
settings. Not required if `project_settings` are passed.
project_settings(dict): Prepare project settings for project name.
Not needed if `project_name` is passed.
Raises:
ValueError: When both 'project_name' and 'project_settings' were not
passed.
Deprecated:
Function will be removed after release version 3.16.*
"""
from openpype.pipeline.workfile import get_workfile_template_key
return get_workfile_template_key(
task_type, host_name, project_name, project_settings
)
@deprecated("openpype.pipeline.context_tools.compute_session_changes")
def compute_session_changes(
session, task=None, asset=None, app=None, template_key=None
):
"""Compute the changes for a Session object on asset, task or app switch
This does *NOT* update the Session object, but returns the changes
required for a valid update of the Session.
Args:
session (dict): The initial session to compute changes to.
This is required for computing the full Work Directory, as that
also depends on the values that haven't changed.
task (str, Optional): Name of task to switch to.
asset (str or dict, Optional): Name of asset to switch to.
You can also directly provide the Asset dictionary as returned
from the database to avoid an additional query. (optimization)
app (str, Optional): Name of app to switch to.
Returns:
dict: The required changes in the Session dictionary.
Deprecated:
Function will be removed after release version 3.16.*
"""
from openpype.pipeline import legacy_io
from openpype.pipeline.context_tools import compute_session_changes
if isinstance(asset, six.string_types):
project_name = legacy_io.active_project()
asset = get_asset_by_name(project_name, asset)
return compute_session_changes(
session,
asset,
task,
template_key
)
@deprecated("openpype.pipeline.context_tools.get_workdir_from_session")
def get_workdir_from_session(session=None, template_key=None):
"""Calculate workdir path based on session data.
Args:
session (Union[None, Dict[str, str]]): Session to use. If not passed
current context session is used (from legacy_io).
template_key (Union[str, None]): Precalculate template key to define
workfile template name in Anatomy.
Returns:
str: Workdir path.
Deprecated:
Function will be removed after release version 3.16.*
"""
from openpype.pipeline.context_tools import get_workdir_from_session
return get_workdir_from_session(session, template_key)
@deprecated("openpype.pipeline.context_tools.change_current_context")
def update_current_task(task=None, asset=None, app=None, template_key=None):
"""Update active Session to a new task work area.
This updates the live Session to a different `asset`, `task` or `app`.
Args:
task (str): The task to set.
asset (str): The asset to set.
app (str): The app to set.
Returns:
dict: The changed key, values in the current Session.
Deprecated:
Function will be removed after release version 3.16.*
"""
from openpype.pipeline import legacy_io
from openpype.pipeline.context_tools import change_current_context
project_name = legacy_io.active_project()
if isinstance(asset, six.string_types):
asset = get_asset_by_name(project_name, asset)
return change_current_context(asset, task, template_key)
@deprecated("openpype.pipeline.workfile.BuildWorkfile")
def BuildWorkfile():
"""Build workfile class was moved to workfile pipeline.
Deprecated:
Function will be removed after release version 3.16.*
"""
from openpype.pipeline.workfile import BuildWorkfile
return BuildWorkfile()
@deprecated("openpype.pipeline.create.get_legacy_creator_by_name")
def get_creator_by_name(creator_name, case_sensitive=False):
"""Find creator plugin by name.
Args:
creator_name (str): Name of creator class that should be returned.
case_sensitive (bool): Match of creator plugin name is case sensitive.
Set to `False` by default.
Returns:
Creator: Return first matching plugin or `None`.
Deprecated:
Function will be removed after release version 3.16.*
"""
from openpype.pipeline.create import get_legacy_creator_by_name
return get_legacy_creator_by_name(creator_name, case_sensitive)
def _get_task_context_data_for_anatomy(
project_doc, asset_doc, task_name, anatomy=None
):
"""Prepare Task context for anatomy data.
WARNING: this data structure is currently used only in workfile templates.
Key "task" is currently in rest of pipeline used as string with task
name.
Args:
project_doc (dict): Project document with available "name" and
"data.code" keys.
asset_doc (dict): Asset document from MongoDB.
task_name (str): Name of context task.
anatomy (Anatomy): Optionally Anatomy for passed project name can be
passed as Anatomy creation may be slow.
Returns:
dict: With Anatomy context data.
"""
from openpype.pipeline.template_data import get_general_template_data
if anatomy is None:
from openpype.pipeline import Anatomy
anatomy = Anatomy(project_doc["name"])
asset_name = asset_doc["name"]
project_task_types = anatomy["tasks"]
# get relevant task type from asset doc
assert task_name in asset_doc["data"]["tasks"], (
"Task name \"{}\" not found on asset \"{}\"".format(
task_name, asset_name
)
)
task_type = asset_doc["data"]["tasks"][task_name].get("type")
assert task_type, (
"Task name \"{}\" on asset \"{}\" does not have specified task type."
).format(asset_name, task_name)
# get short name for task type defined in default anatomy settings
project_task_type_data = project_task_types.get(task_type)
assert project_task_type_data, (
"Something went wrong. Default anatomy tasks are not holding"
"requested task type: `{}`".format(task_type)
)
data = {
"project": {
"name": project_doc["name"],
"code": project_doc["data"].get("code")
},
"asset": asset_name,
"task": {
"name": task_name,
"type": task_type,
"short": project_task_type_data["short_name"]
}
}
system_general_data = get_general_template_data()
data.update(system_general_data)
return data
@deprecated(
"openpype.pipeline.workfile.get_custom_workfile_template_by_context")
def get_custom_workfile_template_by_context(
template_profiles, project_doc, asset_doc, task_name, anatomy=None
):
"""Filter and fill workfile template profiles by passed context.
It is expected that passed argument are already queried documents of
project and asset as parents of processing task name.
Existence of formatted path is not validated.
Args:
template_profiles(list): Template profiles from settings.
project_doc(dict): Project document from MongoDB.
asset_doc(dict): Asset document from MongoDB.
task_name(str): Name of task for which templates are filtered.
anatomy(Anatomy): Optionally passed anatomy object for passed project
name.
Returns:
str: Path to template or None if none of profiles match current
context. (Existence of formatted path is not validated.)
Deprecated:
Function will be removed after release version 3.16.*
"""
if anatomy is None:
from openpype.pipeline import Anatomy
anatomy = Anatomy(project_doc["name"])
# get project, asset, task anatomy context data
anatomy_context_data = _get_task_context_data_for_anatomy(
project_doc, asset_doc, task_name, anatomy
)
# add root dict
anatomy_context_data["root"] = anatomy.roots
# get task type for the task in context
current_task_type = anatomy_context_data["task"]["type"]
# get path from matching profile
matching_item = filter_profiles(
template_profiles,
{"task_types": current_task_type}
)
# when path is available try to format it in case
# there are some anatomy template strings
if matching_item:
template = matching_item["path"][platform.system().lower()]
return StringTemplate.format_strict_template(
template, anatomy_context_data
)
return None
@deprecated(
"openpype.pipeline.workfile.get_custom_workfile_template_by_string_context"
)
def get_custom_workfile_template_by_string_context(
template_profiles, project_name, asset_name, task_name,
dbcon=None, anatomy=None
):
"""Filter and fill workfile template profiles by passed context.
Passed context are string representations of project, asset and task.
Function will query documents of project and asset to be able use
`get_custom_workfile_template_by_context` for rest of logic.
Args:
template_profiles(list): Loaded workfile template profiles.
project_name(str): Project name.
asset_name(str): Asset name.
task_name(str): Task name.
dbcon(AvalonMongoDB): Optional avalon implementation of mongo
connection with context Session.
anatomy(Anatomy): Optionally prepared anatomy object for passed
project.
Returns:
str: Path to template or None if none of profiles match current
context. (Existence of formatted path is not validated.)
Deprecated:
Function will be removed after release version 3.16.*
"""
project_name = None
if anatomy is not None:
project_name = anatomy.project_name
if not project_name and dbcon is not None:
project_name = dbcon.active_project()
if not project_name:
raise ValueError("Can't determina project")
project_doc = get_project(project_name, fields=["name", "data.code"])
asset_doc = get_asset_by_name(
project_name, asset_name, fields=["name", "data.tasks"])
return get_custom_workfile_template_by_context(
template_profiles, project_doc, asset_doc, task_name, anatomy
)
@deprecated("openpype.pipeline.context_tools.get_custom_workfile_template")
def get_custom_workfile_template(template_profiles):
"""Filter and fill workfile template profiles by current context.
Current context is defined by `legacy_io.Session`. That's why this
function should be used only inside host where context is set and stable.
Args:
template_profiles(list): Template profiles from settings.
Returns:
str: Path to template or None if none of profiles match current
context. (Existence of formatted path is not validated.)
Deprecated:
Function will be removed after release version 3.16.*
"""
from openpype.pipeline import legacy_io
return get_custom_workfile_template_by_string_context(
template_profiles,
legacy_io.Session["AVALON_PROJECT"],
legacy_io.Session["AVALON_ASSET"],
legacy_io.Session["AVALON_TASK"],
legacy_io
)
@deprecated("openpype.pipeline.workfile.get_last_workfile_with_version")
def get_last_workfile_with_version(
workdir, file_template, fill_data, extensions
):
"""Return last workfile version.
Args:
workdir(str): Path to dir where workfiles are stored.
file_template(str): Template of file name.
fill_data(dict): Data for filling template.
extensions(list, tuple): All allowed file extensions of workfile.
Returns:
tuple: Last workfile<str> with version<int> if there is any otherwise
returns (None, None).
Deprecated:
Function will be removed after release version 3.16.*
"""
from openpype.pipeline.workfile import get_last_workfile_with_version
return get_last_workfile_with_version(
workdir, file_template, fill_data, extensions
)
@deprecated("openpype.pipeline.workfile.get_last_workfile")
def get_last_workfile(
workdir, file_template, fill_data, extensions, full_path=False
):
"""Return last workfile filename.
Returns file with version 1 if there is not workfile yet.
Args:
workdir(str): Path to dir where workfiles are stored.
file_template(str): Template of file name.
fill_data(dict): Data for filling template.
extensions(list, tuple): All allowed file extensions of workfile.
full_path(bool): Full path to file is returned if set to True.
Returns:
str: Last or first workfile as filename of full path to filename.
Deprecated:
Function will be removed after release version 3.16.*
"""
from openpype.pipeline.workfile import get_last_workfile
return get_last_workfile(
workdir, file_template, fill_data, extensions, full_path
)
@deprecated("openpype.client.get_linked_representation_id")
def get_linked_ids_for_representations(
project_name, repre_ids, dbcon=None, link_type=None, max_depth=0
):
"""Returns list of linked ids of particular type (if provided).
Goes from representations to version, back to representations
Args:
project_name (str)
repre_ids (list) or (ObjectId)
dbcon (avalon.mongodb.AvalonMongoDB, optional): Avalon Mongo connection
with Session.
link_type (str): ['reference', '..]
max_depth (int): limit how many levels of recursion
Returns:
(list) of ObjectId - linked representations
Deprecated:
Function will be removed after release version 3.16.*
"""
from openpype.client import get_linked_representation_id
if not isinstance(repre_ids, list):
repre_ids = [repre_ids]
output = []
for repre_id in repre_ids:
output.extend(get_linked_representation_id(
project_name,
repre_id=repre_id,
link_type=link_type,
max_depth=max_depth
))
return output

View file

@ -1,252 +0,0 @@
"""Functions useful for delivery action or loader"""
import os
import shutil
import functools
import warnings
class DeliveryDeprecatedWarning(DeprecationWarning):
pass
def deprecated(new_destination):
"""Mark functions as deprecated.
It will result in a warning being emitted when the function is used.
"""
func = None
if callable(new_destination):
func = new_destination
new_destination = None
def _decorator(decorated_func):
if new_destination is None:
warning_message = (
" Please check content of deprecated function to figure out"
" possible replacement."
)
else:
warning_message = " Please replace your usage with '{}'.".format(
new_destination
)
@functools.wraps(decorated_func)
def wrapper(*args, **kwargs):
warnings.simplefilter("always", DeliveryDeprecatedWarning)
warnings.warn(
(
"Call to deprecated function '{}'"
"\nFunction was moved or removed.{}"
).format(decorated_func.__name__, warning_message),
category=DeliveryDeprecatedWarning,
stacklevel=4
)
return decorated_func(*args, **kwargs)
return wrapper
if func is None:
return _decorator
return _decorator(func)
@deprecated("openpype.lib.path_tools.collect_frames")
def collect_frames(files):
"""Returns dict of source path and its frame, if from sequence
Uses clique as most precise solution, used when anatomy template that
created files is not known.
Assumption is that frames are separated by '.', negative frames are not
allowed.
Args:
files(list) or (set with single value): list of source paths
Returns:
(dict): {'/asset/subset_v001.0001.png': '0001', ....}
Deprecated:
Function was moved to different location and will be removed
after 3.16.* release.
"""
from .path_tools import collect_frames
return collect_frames(files)
@deprecated("openpype.lib.path_tools.format_file_size")
def sizeof_fmt(num, suffix=None):
"""Returns formatted string with size in appropriate unit
Deprecated:
Function was moved to different location and will be removed
after 3.16.* release.
"""
from .path_tools import format_file_size
return format_file_size(num, suffix)
@deprecated("openpype.pipeline.load.get_representation_path_with_anatomy")
def path_from_representation(representation, anatomy):
"""Get representation path using representation document and anatomy.
Args:
representation (Dict[str, Any]): Representation document.
anatomy (Anatomy): Project anatomy.
Deprecated:
Function was moved to different location and will be removed
after 3.16.* release.
"""
from openpype.pipeline.load import get_representation_path_with_anatomy
return get_representation_path_with_anatomy(representation, anatomy)
@deprecated
def copy_file(src_path, dst_path):
"""Hardlink file if possible(to save space), copy if not"""
from openpype.lib import create_hard_link # safer importing
if os.path.exists(dst_path):
return
try:
create_hard_link(
src_path,
dst_path
)
except OSError:
shutil.copyfile(src_path, dst_path)
@deprecated("openpype.pipeline.delivery.get_format_dict")
def get_format_dict(anatomy, location_path):
"""Returns replaced root values from user provider value.
Args:
anatomy (Anatomy)
location_path (str): user provided value
Returns:
(dict): prepared for formatting of a template
Deprecated:
Function was moved to different location and will be removed
after 3.16.* release.
"""
from openpype.pipeline.delivery import get_format_dict
return get_format_dict(anatomy, location_path)
@deprecated("openpype.pipeline.delivery.check_destination_path")
def check_destination_path(repre_id,
anatomy, anatomy_data,
datetime_data, template_name):
""" Try to create destination path based on 'template_name'.
In the case that path cannot be filled, template contains unmatched
keys, provide error message to filter out repre later.
Args:
anatomy (Anatomy)
anatomy_data (dict): context to fill anatomy
datetime_data (dict): values with actual date
template_name (str): to pick correct delivery template
Returns:
(collections.defauldict): {"TYPE_OF_ERROR":"ERROR_DETAIL"}
Deprecated:
Function was moved to different location and will be removed
after 3.16.* release.
"""
from openpype.pipeline.delivery import check_destination_path
return check_destination_path(
repre_id,
anatomy,
anatomy_data,
datetime_data,
template_name
)
@deprecated("openpype.pipeline.delivery.deliver_single_file")
def process_single_file(
src_path, repre, anatomy, template_name, anatomy_data, format_dict,
report_items, log
):
"""Copy single file to calculated path based on template
Args:
src_path(str): path of source representation file
_repre (dict): full repre, used only in process_sequence, here only
as to share same signature
anatomy (Anatomy)
template_name (string): user selected delivery template name
anatomy_data (dict): data from repre to fill anatomy with
format_dict (dict): root dictionary with names and values
report_items (collections.defaultdict): to return error messages
log (Logger): for log printing
Returns:
(collections.defaultdict , int)
Deprecated:
Function was moved to different location and will be removed
after 3.16.* release.
"""
from openpype.pipeline.delivery import deliver_single_file
return deliver_single_file(
src_path, repre, anatomy, template_name, anatomy_data, format_dict,
report_items, log
)
@deprecated("openpype.pipeline.delivery.deliver_sequence")
def process_sequence(
src_path, repre, anatomy, template_name, anatomy_data, format_dict,
report_items, log
):
""" For Pype2(mainly - works in 3 too) where representation might not
contain files.
Uses listing physical files (not 'files' on repre as a)might not be
present, b)might not be reliable for representation and copying them.
TODO Should be refactored when files are sufficient to drive all
representations.
Args:
src_path(str): path of source representation file
repre (dict): full representation
anatomy (Anatomy)
template_name (string): user selected delivery template name
anatomy_data (dict): data from repre to fill anatomy with
format_dict (dict): root dictionary with names and values
report_items (collections.defaultdict): to return error messages
log (Logger): for log printing
Returns:
(collections.defaultdict , int)
Deprecated:
Function was moved to different location and will be removed
after 3.16.* release.
"""
from openpype.pipeline.delivery import deliver_sequence
return deliver_sequence(
src_path, repre, anatomy, template_name, anatomy_data, format_dict,
report_items, log
)

View file

@ -296,18 +296,6 @@ def path_to_subprocess_arg(path):
return subprocess.list2cmdline([path])
def get_pype_execute_args(*args):
"""Backwards compatible function for 'get_openpype_execute_args'."""
import traceback
log = Logger.get_logger("get_pype_execute_args")
stack = "\n".join(traceback.format_stack())
log.warning((
"Using deprecated function 'get_pype_execute_args'. Called from:\n{}"
).format(stack))
return get_openpype_execute_args(*args)
def get_openpype_execute_args(*args):
"""Arguments to run pype command.

View file

@ -492,21 +492,3 @@ class Logger:
cls.initialize()
return OpenPypeMongoConnection.get_mongo_client()
class PypeLogger(Logger):
"""Duplicate of 'Logger'.
Deprecated:
Class will be removed after release version 3.16.*
"""
@classmethod
def get_logger(cls, *args, **kwargs):
logger = Logger.get_logger(*args, **kwargs)
# TODO uncomment when replaced most of places
logger.warning((
"'openpype.lib.PypeLogger' is deprecated class."
" Please use 'openpype.lib.Logger' instead."
))
return logger

View file

@ -1,61 +0,0 @@
import warnings
import functools
from openpype.client.mongo import (
MongoEnvNotSet,
OpenPypeMongoConnection,
)
class MongoDeprecatedWarning(DeprecationWarning):
pass
def mongo_deprecated(func):
"""Mark functions as deprecated.
It will result in a warning being emitted when the function is used.
"""
@functools.wraps(func)
def new_func(*args, **kwargs):
warnings.simplefilter("always", MongoDeprecatedWarning)
warnings.warn(
(
"Call to deprecated function '{}'."
" Function was moved to 'openpype.client.mongo'."
).format(func.__name__),
category=MongoDeprecatedWarning,
stacklevel=2
)
return func(*args, **kwargs)
return new_func
@mongo_deprecated
def get_default_components():
from openpype.client.mongo import get_default_components
return get_default_components()
@mongo_deprecated
def should_add_certificate_path_to_mongo_url(mongo_url):
from openpype.client.mongo import should_add_certificate_path_to_mongo_url
return should_add_certificate_path_to_mongo_url(mongo_url)
@mongo_deprecated
def validate_mongo_connection(mongo_uri):
from openpype.client.mongo import validate_mongo_connection
return validate_mongo_connection(mongo_uri)
__all__ = (
"MongoEnvNotSet",
"OpenPypeMongoConnection",
"get_default_components",
"should_add_certificate_path_to_mongo_url",
"validate_mongo_connection",
)

View file

@ -2,59 +2,12 @@ import os
import re
import logging
import platform
import functools
import warnings
import clique
log = logging.getLogger(__name__)
class PathToolsDeprecatedWarning(DeprecationWarning):
pass
def deprecated(new_destination):
"""Mark functions as deprecated.
It will result in a warning being emitted when the function is used.
"""
func = None
if callable(new_destination):
func = new_destination
new_destination = None
def _decorator(decorated_func):
if new_destination is None:
warning_message = (
" Please check content of deprecated function to figure out"
" possible replacement."
)
else:
warning_message = " Please replace your usage with '{}'.".format(
new_destination
)
@functools.wraps(decorated_func)
def wrapper(*args, **kwargs):
warnings.simplefilter("always", PathToolsDeprecatedWarning)
warnings.warn(
(
"Call to deprecated function '{}'"
"\nFunction was moved or removed.{}"
).format(decorated_func.__name__, warning_message),
category=PathToolsDeprecatedWarning,
stacklevel=4
)
return decorated_func(*args, **kwargs)
return wrapper
if func is None:
return _decorator
return _decorator(func)
def format_file_size(file_size, suffix=None):
"""Returns formatted string with size in appropriate unit.
@ -269,99 +222,3 @@ def get_last_version_from_path(path_dir, filter):
return filtred_files[-1]
return None
@deprecated("openpype.pipeline.project_folders.concatenate_splitted_paths")
def concatenate_splitted_paths(split_paths, anatomy):
"""
Deprecated:
Function will be removed after release version 3.16.*
"""
from openpype.pipeline.project_folders import concatenate_splitted_paths
return concatenate_splitted_paths(split_paths, anatomy)
@deprecated
def get_format_data(anatomy):
"""
Deprecated:
Function will be removed after release version 3.16.*
"""
from openpype.pipeline.template_data import get_project_template_data
data = get_project_template_data(project_name=anatomy.project_name)
data["root"] = anatomy.roots
return data
@deprecated("openpype.pipeline.project_folders.fill_paths")
def fill_paths(path_list, anatomy):
"""
Deprecated:
Function will be removed after release version 3.16.*
"""
from openpype.pipeline.project_folders import fill_paths
return fill_paths(path_list, anatomy)
@deprecated("openpype.pipeline.project_folders.create_project_folders")
def create_project_folders(basic_paths, project_name):
"""
Deprecated:
Function will be removed after release version 3.16.*
"""
from openpype.pipeline.project_folders import create_project_folders
return create_project_folders(project_name, basic_paths)
@deprecated("openpype.pipeline.project_folders.get_project_basic_paths")
def get_project_basic_paths(project_name):
"""
Deprecated:
Function will be removed after release version 3.16.*
"""
from openpype.pipeline.project_folders import get_project_basic_paths
return get_project_basic_paths(project_name)
@deprecated("openpype.pipeline.workfile.create_workdir_extra_folders")
def create_workdir_extra_folders(
workdir, host_name, task_type, task_name, project_name,
project_settings=None
):
"""Create extra folders in work directory based on context.
Args:
workdir (str): Path to workdir where workfiles is stored.
host_name (str): Name of host implementation.
task_type (str): Type of task for which extra folders should be
created.
task_name (str): Name of task for which extra folders should be
created.
project_name (str): Name of project on which task is.
project_settings (dict): Prepared project settings. Are loaded if not
passed.
Deprecated:
Function will be removed after release version 3.16.*
"""
from openpype.pipeline.project_folders import create_workdir_extra_folders
return create_workdir_extra_folders(
workdir,
host_name,
task_type,
task_name,
project_name,
project_settings
)

View file

@ -4,157 +4,9 @@ import os
import logging
import re
import warnings
import functools
from openpype.client import get_asset_by_id
log = logging.getLogger(__name__)
class PluginToolsDeprecatedWarning(DeprecationWarning):
pass
def deprecated(new_destination):
"""Mark functions as deprecated.
It will result in a warning being emitted when the function is used.
"""
func = None
if callable(new_destination):
func = new_destination
new_destination = None
def _decorator(decorated_func):
if new_destination is None:
warning_message = (
" Please check content of deprecated function to figure out"
" possible replacement."
)
else:
warning_message = " Please replace your usage with '{}'.".format(
new_destination
)
@functools.wraps(decorated_func)
def wrapper(*args, **kwargs):
warnings.simplefilter("always", PluginToolsDeprecatedWarning)
warnings.warn(
(
"Call to deprecated function '{}'"
"\nFunction was moved or removed.{}"
).format(decorated_func.__name__, warning_message),
category=PluginToolsDeprecatedWarning,
stacklevel=4
)
return decorated_func(*args, **kwargs)
return wrapper
if func is None:
return _decorator
return _decorator(func)
@deprecated("openpype.pipeline.create.TaskNotSetError")
def TaskNotSetError(*args, **kwargs):
from openpype.pipeline.create import TaskNotSetError
return TaskNotSetError(*args, **kwargs)
@deprecated("openpype.pipeline.create.get_subset_name")
def get_subset_name_with_asset_doc(
family,
variant,
task_name,
asset_doc,
project_name=None,
host_name=None,
default_template=None,
dynamic_data=None
):
"""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.
That's main reason why so many arguments are required to calculate subset
name.
Args:
family (str): Instance family.
variant (str): In most of cases it is user input during creation.
task_name (str): Task name on which context is instance created.
asset_doc (dict): Queried asset document with it's tasks in data.
Used to get task type.
project_name (str): Name of project on which is instance created.
Important for project settings that are loaded.
host_name (str): One of filtering criteria for template profile
filters.
default_template (str): Default template if any profile does not match
passed context. Constant 'DEFAULT_SUBSET_TEMPLATE' is used if
is not passed.
dynamic_data (dict): Dynamic data specific for a creator which creates
instance.
"""
from openpype.pipeline.create import get_subset_name
return get_subset_name(
family,
variant,
task_name,
asset_doc,
project_name,
host_name,
default_template,
dynamic_data
)
@deprecated
def get_subset_name(
family,
variant,
task_name,
asset_id,
project_name=None,
host_name=None,
default_template=None,
dynamic_data=None,
dbcon=None
):
"""Calculate subset name using OpenPype settings.
This variant of function expects asset id as argument.
This is legacy function should be replaced with
`get_subset_name_with_asset_doc` where asset document is expected.
"""
from openpype.pipeline.create import get_subset_name
if project_name is None:
project_name = dbcon.project_name
asset_doc = get_asset_by_id(project_name, asset_id, fields=["data.tasks"])
return get_subset_name(
family,
variant,
task_name,
asset_doc,
project_name,
host_name,
default_template,
dynamic_data
)
def prepare_template_data(fill_pairs):
"""
Prepares formatted data for filling template.

View file

@ -1,7 +1,5 @@
import os
import pyblish.api
from openpype.lib.mongo import OpenPypeMongoConnection
from openpype.client.mongo import OpenPypeMongoConnection
class CollectShotgridEntities(pyblish.api.ContextPlugin):

View file

@ -1,128 +0,0 @@
import functools
import warnings
import pyblish.api
# New location of orders: openpype.pipeline.publish.constants
# - can be imported as
# 'from openpype.pipeline.publish import ValidatePipelineOrder'
ValidatePipelineOrder = pyblish.api.ValidatorOrder + 0.05
ValidateContentsOrder = pyblish.api.ValidatorOrder + 0.1
ValidateSceneOrder = pyblish.api.ValidatorOrder + 0.2
ValidateMeshOrder = pyblish.api.ValidatorOrder + 0.3
class PluginDeprecatedWarning(DeprecationWarning):
pass
def _deprecation_warning(item_name, warning_message):
warnings.simplefilter("always", PluginDeprecatedWarning)
warnings.warn(
(
"Call to deprecated function '{}'"
"\nFunction was moved or removed.{}"
).format(item_name, warning_message),
category=PluginDeprecatedWarning,
stacklevel=4
)
def deprecated(new_destination):
"""Mark functions as deprecated.
It will result in a warning being emitted when the function is used.
"""
func = None
if callable(new_destination):
func = new_destination
new_destination = None
def _decorator(decorated_func):
if new_destination is None:
warning_message = (
" Please check content of deprecated function to figure out"
" possible replacement."
)
else:
warning_message = " Please replace your usage with '{}'.".format(
new_destination
)
@functools.wraps(decorated_func)
def wrapper(*args, **kwargs):
_deprecation_warning(decorated_func.__name__, warning_message)
return decorated_func(*args, **kwargs)
return wrapper
if func is None:
return _decorator
return _decorator(func)
# Classes just inheriting from pyblish classes
# - seems to be unused in code (not 100% sure)
# - they should be removed but because it is not clear if they're used
# we'll keep then and log deprecation warning
# Deprecated since 3.14.* will be removed in 3.16.*
class ContextPlugin(pyblish.api.ContextPlugin):
def __init__(self, *args, **kwargs):
_deprecation_warning(
"openpype.plugin.ContextPlugin",
" Please replace your usage with 'pyblish.api.ContextPlugin'."
)
super(ContextPlugin, self).__init__(*args, **kwargs)
# Deprecated since 3.14.* will be removed in 3.16.*
class InstancePlugin(pyblish.api.InstancePlugin):
def __init__(self, *args, **kwargs):
_deprecation_warning(
"openpype.plugin.ContextPlugin",
" Please replace your usage with 'pyblish.api.InstancePlugin'."
)
super(InstancePlugin, self).__init__(*args, **kwargs)
class Extractor(pyblish.api.InstancePlugin):
"""Extractor base class.
The extractor base class implements a "staging_dir" function used to
generate a temporary directory for an instance to extract to.
This temporary directory is generated through `tempfile.mkdtemp()`
"""
order = 2.0
def staging_dir(self, instance):
"""Provide a temporary directory in which to store extracted files
Upon calling this method the staging directory is stored inside
the instance.data['stagingDir']
"""
from openpype.pipeline.publish import get_instance_staging_dir
return get_instance_staging_dir(instance)
@deprecated("openpype.pipeline.publish.context_plugin_should_run")
def contextplugin_should_run(plugin, context):
"""Return whether the ContextPlugin should run on the given context.
This is a helper function to work around a bug pyblish-base#250
Whenever a ContextPlugin sets specific families it will still trigger even
when no instances are present that have those families.
This actually checks it correctly and returns whether it should run.
Deprecated:
Since 3.14.* will be removed in 3.16.* or later.
"""
from openpype.pipeline.publish import context_plugin_should_run
return context_plugin_should_run(plugin, context)

View file

@ -1803,10 +1803,7 @@ class MongoLocalSettingsHandler(LocalSettingsHandler):
def __init__(self, local_site_id=None):
# Get mongo connection
from openpype.lib import (
OpenPypeMongoConnection,
get_local_site_id
)
from openpype.lib import get_local_site_id
if local_site_id is None:
local_site_id = get_local_site_id()