Don't use legacy_io session in global plugins

This commit is contained in:
Jakub Trllo 2022-11-24 10:54:46 +01:00
parent f1e1a1b238
commit d068ff4814
5 changed files with 11 additions and 22 deletions

View file

@ -4,8 +4,6 @@ import os
import shutil
import pyblish.api
from openpype.pipeline import legacy_io
class CleanUpFarm(pyblish.api.ContextPlugin):
"""Cleans up the staging directory after a successful publish.
@ -23,8 +21,8 @@ class CleanUpFarm(pyblish.api.ContextPlugin):
def process(self, context):
# Get source host from which farm publishing was started
src_host_name = legacy_io.Session.get("AVALON_APP")
self.log.debug("Host name from session is {}".format(src_host_name))
src_host_name = context.data["hostName"]
self.log.debug("Host name from context is {}".format(src_host_name))
# Skip process if is not in list of source hosts in which this
# plugin should run
if src_host_name not in self.allowed_hosts:

View file

@ -32,7 +32,6 @@ from openpype.client import (
get_subsets,
get_last_versions
)
from openpype.pipeline import legacy_io
class CollectAnatomyInstanceData(pyblish.api.ContextPlugin):
@ -49,7 +48,7 @@ class CollectAnatomyInstanceData(pyblish.api.ContextPlugin):
def process(self, context):
self.log.info("Collecting anatomy data for all instances.")
project_name = legacy_io.active_project()
project_name = context.data["projectName"]
self.fill_missing_asset_docs(context, project_name)
self.fill_instance_data_from_asset(context)
self.fill_latest_versions(context, project_name)

View file

@ -1,10 +1,7 @@
import pyblish.api
from openpype.client import get_representations
from openpype.pipeline import (
registered_host,
legacy_io,
)
from openpype.pipeline import registered_host
class CollectSceneLoadedVersions(pyblish.api.ContextPlugin):
@ -44,7 +41,7 @@ class CollectSceneLoadedVersions(pyblish.api.ContextPlugin):
for container in containers
}
project_name = legacy_io.active_project()
project_name = context.data["projectName"]
repre_docs = get_representations(
project_name,
representation_ids=repre_ids,

View file

@ -25,7 +25,6 @@ from openpype.client import (
)
from openpype.lib import source_hash
from openpype.lib.file_transaction import FileTransaction
from openpype.pipeline import legacy_io
from openpype.pipeline.publish import (
KnownPublishError,
get_publish_template_name,
@ -242,7 +241,7 @@ class IntegrateAsset(pyblish.api.InstancePlugin):
return filtered_repres
def register(self, instance, file_transactions, filtered_repres):
project_name = legacy_io.active_project()
project_name = instance.context["projectName"]
instance_stagingdir = instance.data.get("stagingDir")
if not instance_stagingdir:
@ -803,11 +802,11 @@ class IntegrateAsset(pyblish.api.InstancePlugin):
"""Return anatomy template name to use for integration"""
# Anatomy data is pre-filled by Collectors
project_name = legacy_io.active_project()
context = instance.context
project_name = context.data["projectName"]
# Task can be optional in anatomy data
host_name = instance.context.data["hostName"]
host_name = context.data["hostName"]
anatomy_data = instance.data["anatomyData"]
family = anatomy_data["family"]
task_info = anatomy_data.get("task") or {}
@ -818,7 +817,7 @@ class IntegrateAsset(pyblish.api.InstancePlugin):
family,
task_name=task_info.get("name"),
task_type=task_info.get("type"),
project_settings=instance.context.data["project_settings"],
project_settings=context.data["project_settings"],
logger=self.log
)

View file

@ -2,7 +2,6 @@ from pprint import pformat
import pyblish.api
from openpype.pipeline import legacy_io
from openpype.client import get_assets
@ -28,10 +27,7 @@ class ValidateEditorialAssetName(pyblish.api.ContextPlugin):
asset_and_parents = self.get_parents(context)
self.log.debug("__ asset_and_parents: {}".format(asset_and_parents))
if not legacy_io.Session:
legacy_io.install()
project_name = legacy_io.active_project()
project_name = context.data["projectName"]
db_assets = list(get_assets(
project_name, fields=["name", "data.parents"]
))