From 5e4d618be47515e9088329958ed6ea8aaee9456c Mon Sep 17 00:00:00 2001 From: Jakub Trllo Date: Mon, 25 Apr 2022 18:19:20 +0200 Subject: [PATCH] fixed new imports of avalon --- openpype/hosts/aftereffects/api/pipeline.py | 12 +++++----- .../plugins/create/create_render.py | 7 +++--- .../plugins/create/workfile_creator.py | 20 ++++++++-------- .../plugins/publish/collect_workfile.py | 3 ++- openpype/hosts/photoshop/api/pipeline.py | 7 +++--- .../photoshop/plugins/create/create_image.py | 6 ++--- .../plugins/create/workfile_creator.py | 23 +++++++++++-------- .../plugins/publish/collect_batch_data.py | 7 +++--- openpype/lib/avalon_context.py | 4 ++-- 9 files changed, 48 insertions(+), 41 deletions(-) diff --git a/openpype/hosts/aftereffects/api/pipeline.py b/openpype/hosts/aftereffects/api/pipeline.py index 3a41b4f26d..0d739df748 100644 --- a/openpype/hosts/aftereffects/api/pipeline.py +++ b/openpype/hosts/aftereffects/api/pipeline.py @@ -13,6 +13,7 @@ from openpype.pipeline import ( deregister_loader_plugin_path, deregister_creator_plugin_path, AVALON_CONTAINER_ID, + legacy_io, ) import openpype.hosts.aftereffects from openpype.lib import register_event_callback @@ -142,9 +143,9 @@ def check_inventory(): outdated_containers = [] for container in host.ls(): representation = container['representation'] - representation_doc = io.find_one( + representation_doc = legacy_io.find_one( { - "_id": io.ObjectId(representation), + "_id": legacy_io.ObjectId(representation), "type": "representation" }, projection={"parent": True} @@ -280,11 +281,10 @@ def update_context_data(data, changes): def get_context_title(): """Returns title for Creator window""" - import avalon.api - project_name = avalon.api.Session["AVALON_PROJECT"] - asset_name = avalon.api.Session["AVALON_ASSET"] - task_name = avalon.api.Session["AVALON_TASK"] + project_name = legacy_io.Session["AVALON_PROJECT"] + asset_name = legacy_io.Session["AVALON_ASSET"] + task_name = legacy_io.Session["AVALON_TASK"] return "{}/{}/{}".format(project_name, asset_name, task_name) diff --git a/openpype/hosts/aftereffects/plugins/create/create_render.py b/openpype/hosts/aftereffects/plugins/create/create_render.py index 78d43d259a..215c148f37 100644 --- a/openpype/hosts/aftereffects/plugins/create/create_render.py +++ b/openpype/hosts/aftereffects/plugins/create/create_render.py @@ -1,12 +1,11 @@ -from avalon import api as avalon_api - from openpype import resources from openpype.lib import BoolDef, UISeparatorDef from openpype.hosts.aftereffects import api from openpype.pipeline import ( Creator, CreatedInstance, - CreatorError + CreatorError, + legacy_io, ) @@ -116,7 +115,7 @@ class RenderCreator(Creator): instance_data.pop("uuid") if not instance_data.get("task"): - instance_data["task"] = avalon_api.Session.get("AVALON_TASK") + instance_data["task"] = legacy_io.Session.get("AVALON_TASK") if not instance_data.get("creator_attributes"): is_old_farm = instance_data["family"] != "renderLocal" diff --git a/openpype/hosts/aftereffects/plugins/create/workfile_creator.py b/openpype/hosts/aftereffects/plugins/create/workfile_creator.py index 2d9d42ee8c..7cc9bb54d4 100644 --- a/openpype/hosts/aftereffects/plugins/create/workfile_creator.py +++ b/openpype/hosts/aftereffects/plugins/create/workfile_creator.py @@ -1,9 +1,8 @@ -from avalon import io - import openpype.hosts.aftereffects.api as api from openpype.pipeline import ( AutoCreator, - CreatedInstance + CreatedInstance, + legacy_io, ) @@ -36,13 +35,13 @@ class AEWorkfileCreator(AutoCreator): break variant = '' - project_name = io.Session["AVALON_PROJECT"] - asset_name = io.Session["AVALON_ASSET"] - task_name = io.Session["AVALON_TASK"] - host_name = io.Session["AVALON_APP"] + project_name = legacy_io.Session["AVALON_PROJECT"] + asset_name = legacy_io.Session["AVALON_ASSET"] + task_name = legacy_io.Session["AVALON_TASK"] + host_name = legacy_io.Session["AVALON_APP"] if existing_instance is None: - asset_doc = io.find_one({"type": "asset", "name": asset_name}) + asset_doc = legacy_io.find_one({"type": "asset", "name": asset_name}) subset_name = self.get_subset_name( variant, task_name, asset_doc, project_name, host_name ) @@ -67,7 +66,10 @@ class AEWorkfileCreator(AutoCreator): existing_instance["asset"] != asset_name or existing_instance["task"] != task_name ): - asset_doc = io.find_one({"type": "asset", "name": asset_name}) + asset_doc = legacy_io.find_one({ + "type": "asset", + "name": asset_name + }) subset_name = self.get_subset_name( variant, task_name, asset_doc, project_name, host_name ) diff --git a/openpype/hosts/aftereffects/plugins/publish/collect_workfile.py b/openpype/hosts/aftereffects/plugins/publish/collect_workfile.py index 06b73f4b5d..9cb6900b0a 100644 --- a/openpype/hosts/aftereffects/plugins/publish/collect_workfile.py +++ b/openpype/hosts/aftereffects/plugins/publish/collect_workfile.py @@ -2,6 +2,7 @@ import os import pyblish.api from openpype.lib import get_subset_name_with_asset_doc +from openpype.pipeline import legacy_io class CollectWorkfile(pyblish.api.ContextPlugin): @@ -41,7 +42,7 @@ class CollectWorkfile(pyblish.api.ContextPlugin): instance.data["publish"] = instance.data["active"] # for DL def _get_new_instance(self, context, scene_file): - task = api.Session["AVALON_TASK"] + task = legacy_io.Session["AVALON_TASK"] version = context.data["version"] asset_entity = context.data["assetEntity"] project_entity = context.data["projectEntity"] diff --git a/openpype/hosts/photoshop/api/pipeline.py b/openpype/hosts/photoshop/api/pipeline.py index fc90be8716..6db4470428 100644 --- a/openpype/hosts/photoshop/api/pipeline.py +++ b/openpype/hosts/photoshop/api/pipeline.py @@ -260,9 +260,8 @@ def update_context_data(data, changes): def get_context_title(): """Returns title for Creator window""" - import avalon.api - project_name = avalon.api.Session["AVALON_PROJECT"] - asset_name = avalon.api.Session["AVALON_ASSET"] - task_name = avalon.api.Session["AVALON_TASK"] + project_name = legacy_io.Session["AVALON_PROJECT"] + asset_name = legacy_io.Session["AVALON_ASSET"] + task_name = legacy_io.Session["AVALON_TASK"] return "{}/{}/{}".format(project_name, asset_name, task_name) diff --git a/openpype/hosts/photoshop/plugins/create/create_image.py b/openpype/hosts/photoshop/plugins/create/create_image.py index c2fe8b6c78..f15068b031 100644 --- a/openpype/hosts/photoshop/plugins/create/create_image.py +++ b/openpype/hosts/photoshop/plugins/create/create_image.py @@ -1,9 +1,9 @@ -from avalon import api as avalon_api from openpype.hosts.photoshop import api from openpype.lib import BoolDef from openpype.pipeline import ( Creator, - CreatedInstance + CreatedInstance, + legacy_io ) @@ -133,7 +133,7 @@ class ImageCreator(Creator): instance_data.pop("uuid") if not instance_data.get("task"): - instance_data["task"] = avalon_api.Session.get("AVALON_TASK") + instance_data["task"] = legacy_io.Session.get("AVALON_TASK") if not instance_data.get("variant"): instance_data["variant"] = '' diff --git a/openpype/hosts/photoshop/plugins/create/workfile_creator.py b/openpype/hosts/photoshop/plugins/create/workfile_creator.py index d66a05cad7..875a9b8a94 100644 --- a/openpype/hosts/photoshop/plugins/create/workfile_creator.py +++ b/openpype/hosts/photoshop/plugins/create/workfile_creator.py @@ -1,9 +1,8 @@ -from avalon import io - import openpype.hosts.photoshop.api as api from openpype.pipeline import ( AutoCreator, - CreatedInstance + CreatedInstance, + legacy_io ) @@ -36,12 +35,15 @@ class PSWorkfileCreator(AutoCreator): break variant = '' - project_name = io.Session["AVALON_PROJECT"] - asset_name = io.Session["AVALON_ASSET"] - task_name = io.Session["AVALON_TASK"] - host_name = io.Session["AVALON_APP"] + project_name = legacy_io.Session["AVALON_PROJECT"] + asset_name = legacy_io.Session["AVALON_ASSET"] + task_name = legacy_io.Session["AVALON_TASK"] + host_name = legacy_io.Session["AVALON_APP"] if existing_instance is None: - asset_doc = io.find_one({"type": "asset", "name": asset_name}) + asset_doc = legacy_io.find_one({ + "type": "asset", + "name": asset_name + }) subset_name = self.get_subset_name( variant, task_name, asset_doc, project_name, host_name ) @@ -65,7 +67,10 @@ class PSWorkfileCreator(AutoCreator): existing_instance["asset"] != asset_name or existing_instance["task"] != task_name ): - asset_doc = io.find_one({"type": "asset", "name": asset_name}) + asset_doc = legacy_io.find_one({ + "type": "asset", + "name": asset_name + }) subset_name = self.get_subset_name( variant, task_name, asset_doc, project_name, host_name ) diff --git a/openpype/hosts/photoshop/plugins/publish/collect_batch_data.py b/openpype/hosts/photoshop/plugins/publish/collect_batch_data.py index 5e6e916611..448493d370 100644 --- a/openpype/hosts/photoshop/plugins/publish/collect_batch_data.py +++ b/openpype/hosts/photoshop/plugins/publish/collect_batch_data.py @@ -16,11 +16,12 @@ shouldn't be pushed into general publish plugins. import os import pyblish.api -from avalon import io + from openpype.lib.plugin_tools import ( parse_json, get_batch_asset_task_info ) +from openpype.pipeline import legacy_io class CollectBatchData(pyblish.api.ContextPlugin): @@ -62,9 +63,9 @@ class CollectBatchData(pyblish.api.ContextPlugin): ) os.environ["AVALON_ASSET"] = asset_name - io.Session["AVALON_ASSET"] = asset_name os.environ["AVALON_TASK"] = task_name - io.Session["AVALON_TASK"] = task_name + legacy_io.Session["AVALON_ASSET"] = asset_name + legacy_io.Session["AVALON_TASK"] = task_name context.data["asset"] = asset_name context.data["task"] = task_name diff --git a/openpype/lib/avalon_context.py b/openpype/lib/avalon_context.py index 3d57ee4b91..3fcddef745 100644 --- a/openpype/lib/avalon_context.py +++ b/openpype/lib/avalon_context.py @@ -1969,7 +1969,7 @@ def get_last_workfile( return filename -@with_avalon +@with_pipeline_io 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). @@ -1987,7 +1987,7 @@ def get_linked_ids_for_representations(project_name, repre_ids, dbcon=None, """ # Create new dbcon if not passed and use passed project name if not dbcon: - from avalon.api import AvalonMongoDB + from openpype.pipeline import AvalonMongoDB dbcon = AvalonMongoDB() dbcon.Session["AVALON_PROJECT"] = project_name # Validate that passed dbcon has same project