Skip to content
This repository has been archived by the owner on Sep 20, 2024. It is now read-only.

General: Reduce usage of legacy io #4723

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
39849a7
General: Connect to AYON server (base) (#3924)
iLLiCiTiT Mar 24, 2023
1316e3b
replace 'legacy_io' with context functions in load plugins
iLLiCiTiT Mar 27, 2023
01ae9f3
added 'get_global_context' to pipeline init
iLLiCiTiT Mar 27, 2023
4546f88
use context getters instead of legacy_io in publish plugins
iLLiCiTiT Mar 27, 2023
beee910
use data on context instead of 'legacy_io' in submit publish job
iLLiCiTiT Mar 27, 2023
77d32b7
skip query of asset docs in collect nuke reads
iLLiCiTiT Mar 27, 2023
b34875c
use context functions on other places
iLLiCiTiT Mar 27, 2023
cde736d
'list_looks' expects project name
iLLiCiTiT Mar 27, 2023
06bbff1
remove 'get_context_title'
iLLiCiTiT Mar 27, 2023
0410a51
don't pass AvalonMongoDB to prelaunch hooks
iLLiCiTiT Mar 27, 2023
a1c985b
change how context is calculated in hiero
iLLiCiTiT Mar 27, 2023
8289730
implemented function 'get_fps_for_current_context' for maya
iLLiCiTiT Mar 27, 2023
19cdffc
initialize '_image_dir' and '_image_prefixes' in init
iLLiCiTiT Mar 27, 2023
6681e78
legacy creator is using 'get_current_project_name'
iLLiCiTiT Mar 27, 2023
8079fd0
fill docstrings
iLLiCiTiT Mar 27, 2023
16e1f12
use context functions in workfile builders
iLLiCiTiT Mar 27, 2023
b028cd4
hound fixes
iLLiCiTiT Mar 27, 2023
3759412
'create_workspace_mel' can expect project settings
iLLiCiTiT Mar 28, 2023
8b9fa2c
swapped order of arguments
iLLiCiTiT Mar 28, 2023
057db1b
use information from instance/context data
iLLiCiTiT Mar 28, 2023
8a56fb1
Use self.project_name in workfiles tool
iLLiCiTiT Mar 28, 2023
17ea073
Remove outdated todo
iLLiCiTiT Mar 28, 2023
4ff2b71
don't query project document in nuke lib
iLLiCiTiT Mar 28, 2023
c036d76
Fix access to context data
iLLiCiTiT Mar 28, 2023
a0c409b
Use right function to get project name
iLLiCiTiT Mar 28, 2023
bc18caf
fix submit max deadline and swap order of arguments
iLLiCiTiT Mar 28, 2023
61a26d9
added 'get_context_label' to nuke
iLLiCiTiT Mar 28, 2023
8fa2bb7
fix import
iLLiCiTiT Mar 28, 2023
63bdf7b
fix typo 'curent_context' -> 'current_context'
iLLiCiTiT Mar 28, 2023
7b4113a
fix project_setting variable
iLLiCiTiT Mar 28, 2023
fc49d4a
fix submit publish job environments
iLLiCiTiT Mar 28, 2023
4fd2727
use task from context
iLLiCiTiT Mar 28, 2023
ae2c058
Removed unused import
iLLiCiTiT Mar 28, 2023
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
10 changes: 1 addition & 9 deletions openpype/hooks/pre_global_host_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
prepare_app_environments,
prepare_context_environments
)
from openpype.pipeline import AvalonMongoDB, Anatomy
from openpype.pipeline import Anatomy


class GlobalHostDataHook(PreLaunchHook):
Expand All @@ -26,7 +26,6 @@ def execute(self):

"app": app,

"dbcon": self.data["dbcon"],
"project_doc": self.data["project_doc"],
"asset_doc": self.data["asset_doc"],

Expand Down Expand Up @@ -62,13 +61,6 @@ def prepare_global_data(self):
# Anatomy
self.data["anatomy"] = Anatomy(project_name)

# Mongo connection
dbcon = AvalonMongoDB()
dbcon.Session["AVALON_PROJECT"] = project_name
dbcon.install()

self.data["dbcon"] = dbcon

# Project document
project_doc = get_project(project_name)
self.data["project_doc"] = project_doc
Expand Down
2 changes: 1 addition & 1 deletion openpype/host/dirmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ def _get_local_sync_dirmap(self):
Returns:
dict : { "source-path": [XXX], "destination-path": [YYYY]}
"""
project_name = os.getenv("AVALON_PROJECT")
project_name = self.project_name

mapping = {}
if (not self.sync_module.enabled or
Expand Down
3 changes: 0 additions & 3 deletions openpype/hosts/aftereffects/api/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@
from openpype.pipeline import (
register_loader_plugin_path,
register_creator_plugin_path,
deregister_loader_plugin_path,
deregister_creator_plugin_path,
AVALON_CONTAINER_ID,
legacy_io,
)
from openpype.pipeline.load import any_outdated_containers
import openpype.hosts.aftereffects
Expand Down
10 changes: 6 additions & 4 deletions openpype/hosts/aftereffects/plugins/publish/collect_render.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ def get_instances(self, context):
version = context.data["version"]

project_entity = context.data["projectEntity"]
project_settings = context.data["project_settings"]

compositions = CollectAERender.get_stub().get_items(True)
compositions_by_id = {item.id: item for item in compositions}
Expand Down Expand Up @@ -131,7 +132,9 @@ def get_instances(self, context):
is_local = not inst.data["creator_attributes"].get("farm")
if is_local:
# for local renders
instance = self._update_for_local(instance, project_entity)
instance = self._update_for_local(
instance, project_entity, project_settings
)
else:
fam = "render.farm"
if fam not in instance.families:
Expand Down Expand Up @@ -210,16 +213,15 @@ def _get_output_dir(self, render_instance):
# for submit_publish_job
return base_dir

def _update_for_local(self, instance, project_entity):
def _update_for_local(self, instance, project_entity, project_settings):
"""Update old saved instances to current publishing format"""
instance.stagingDir = tempfile.mkdtemp()
instance.projectEntity = project_entity
fam = "render.local"
if fam not in instance.families:
instance.families.append(fam)

settings = get_project_settings(os.getenv("AVALON_PROJECT"))
reviewable_subset_filter = (settings["deadline"]
reviewable_subset_filter = (project_settings["deadline"]
["publish"]
["ProcessSubmittedJobOnFarm"]
["aov_filter"].get(self.hosts[0]))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import os

import pyblish.api
from openpype.pipeline import legacy_io
from openpype.pipeline.create import get_subset_name


Expand Down Expand Up @@ -44,7 +43,7 @@ def process(self, context):
instance.data["publish"] = instance.data["active"] # for DL

def _get_new_instance(self, context, scene_file):
task = legacy_io.Session["AVALON_TASK"]
task = context.data["task"]
version = context.data["version"]
asset_entity = context.data["assetEntity"]
project_entity = context.data["projectEntity"]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import pyblish.api

from openpype.pipeline import legacy_io
from openpype.pipeline import get_current_asset_name
from openpype.pipeline.publish import (
ValidateContentsOrder,
PublishXmlValidationError,
Expand Down Expand Up @@ -30,7 +30,7 @@ def process(self, context, plugin):
for instance in instances:
data = stub.read(instance[0])

data["asset"] = legacy_io.Session["AVALON_ASSET"]
data["asset"] = get_current_asset_name()
stub.imprint(instance[0].instance_id, data)


Expand All @@ -54,7 +54,7 @@ class ValidateInstanceAsset(pyblish.api.InstancePlugin):

def process(self, instance):
instance_asset = instance.data["asset"]
current_asset = legacy_io.Session["AVALON_ASSET"]
current_asset = get_current_asset_name()
msg = (
f"Instance asset {instance_asset} is not the same "
f"as current context {current_asset}."
Expand Down
12 changes: 6 additions & 6 deletions openpype/hosts/blender/api/ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import bpy.utils.previews

from openpype import style
from openpype.pipeline import legacy_io
from openpype.pipeline import get_current_asset_name, get_current_task_name
from openpype.tools.utils import host_tools

from .workio import OpenFileCacher
Expand Down Expand Up @@ -283,7 +283,7 @@ class LaunchLoader(LaunchQtApp):

def before_window_show(self):
self._window.set_context(
{"asset": legacy_io.Session["AVALON_ASSET"]},
{"asset": get_current_asset_name()},
refresh=True
)

Expand Down Expand Up @@ -331,8 +331,8 @@ class LaunchWorkFiles(LaunchQtApp):
def execute(self, context):
result = super().execute(context)
self._window.set_context({
"asset": legacy_io.Session["AVALON_ASSET"],
"task": legacy_io.Session["AVALON_TASK"]
"asset": get_current_asset_name(),
"task": get_current_task_name()
})
return result

Expand Down Expand Up @@ -362,8 +362,8 @@ def draw(self, context):
else:
pyblish_menu_icon_id = 0

asset = legacy_io.Session['AVALON_ASSET']
task = legacy_io.Session['AVALON_TASK']
asset = get_current_asset_name()
task = get_current_task_name()
context_label = f"{asset}, {task}"
context_label_item = layout.row()
context_label_item.operator(
Expand Down
6 changes: 4 additions & 2 deletions openpype/hosts/blender/api/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
from openpype.pipeline import (
schema,
legacy_io,
get_current_project_name,
get_current_asset_name,
register_loader_plugin_path,
register_creator_plugin_path,
deregister_loader_plugin_path,
Expand Down Expand Up @@ -84,8 +86,8 @@ def uninstall():


def set_start_end_frames():
project_name = legacy_io.active_project()
asset_name = legacy_io.Session["AVALON_ASSET"]
project_name = get_current_project_name()
asset_name = get_current_asset_name()
asset_doc = get_asset_by_name(project_name, asset_name)

scene = bpy.context.scene
Expand Down
4 changes: 2 additions & 2 deletions openpype/hosts/blender/plugins/create/create_action.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import bpy

from openpype.pipeline import legacy_io
from openpype.pipeline import get_current_task_name
import openpype.hosts.blender.api.plugin
from openpype.hosts.blender.api import lib

Expand All @@ -22,7 +22,7 @@ def process(self):
name = openpype.hosts.blender.api.plugin.asset_name(asset, subset)
collection = bpy.data.collections.new(name=name)
bpy.context.scene.collection.children.link(collection)
self.data['task'] = legacy_io.Session.get('AVALON_TASK')
self.data['task'] = get_current_task_name()
lib.imprint(collection, self.data)

if (self.options or {}).get("useSelection"):
Expand Down
4 changes: 2 additions & 2 deletions openpype/hosts/blender/plugins/create/create_animation.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import bpy

from openpype.pipeline import legacy_io
from openpype.pipeline import get_current_task_name
from openpype.hosts.blender.api import plugin, lib, ops
from openpype.hosts.blender.api.pipeline import AVALON_INSTANCES

Expand Down Expand Up @@ -37,7 +37,7 @@ def _process(self):
# asset_group.empty_display_type = 'SINGLE_ARROW'
asset_group = bpy.data.collections.new(name=name)
instances.children.link(asset_group)
self.data['task'] = legacy_io.Session.get('AVALON_TASK')
self.data['task'] = get_current_task_name()
lib.imprint(asset_group, self.data)

if (self.options or {}).get("useSelection"):
Expand Down
4 changes: 2 additions & 2 deletions openpype/hosts/blender/plugins/create/create_camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import bpy

from openpype.pipeline import legacy_io
from openpype.pipeline import get_current_task_name
from openpype.hosts.blender.api import plugin, lib, ops
from openpype.hosts.blender.api.pipeline import AVALON_INSTANCES

Expand Down Expand Up @@ -35,7 +35,7 @@ def _process(self):
asset_group = bpy.data.objects.new(name=name, object_data=None)
asset_group.empty_display_type = 'SINGLE_ARROW'
instances.objects.link(asset_group)
self.data['task'] = legacy_io.Session.get('AVALON_TASK')
self.data['task'] = get_current_task_name()
print(f"self.data: {self.data}")
lib.imprint(asset_group, self.data)

Expand Down
4 changes: 2 additions & 2 deletions openpype/hosts/blender/plugins/create/create_layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import bpy

from openpype.pipeline import legacy_io
from openpype.pipeline import get_current_task_name
from openpype.hosts.blender.api import plugin, lib, ops
from openpype.hosts.blender.api.pipeline import AVALON_INSTANCES

Expand Down Expand Up @@ -34,7 +34,7 @@ def _process(self):
asset_group = bpy.data.objects.new(name=name, object_data=None)
asset_group.empty_display_type = 'SINGLE_ARROW'
instances.objects.link(asset_group)
self.data['task'] = legacy_io.Session.get('AVALON_TASK')
self.data['task'] = get_current_task_name()
lib.imprint(asset_group, self.data)

# Add selected objects to instance
Expand Down
4 changes: 2 additions & 2 deletions openpype/hosts/blender/plugins/create/create_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import bpy

from openpype.pipeline import legacy_io
from openpype.pipeline import get_current_task_name
from openpype.hosts.blender.api import plugin, lib, ops
from openpype.hosts.blender.api.pipeline import AVALON_INSTANCES

Expand Down Expand Up @@ -34,7 +34,7 @@ def _process(self):
asset_group = bpy.data.objects.new(name=name, object_data=None)
asset_group.empty_display_type = 'SINGLE_ARROW'
instances.objects.link(asset_group)
self.data['task'] = legacy_io.Session.get('AVALON_TASK')
self.data['task'] = get_current_task_name()
lib.imprint(asset_group, self.data)

# Add selected objects to instance
Expand Down
4 changes: 2 additions & 2 deletions openpype/hosts/blender/plugins/create/create_pointcache.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import bpy

from openpype.pipeline import legacy_io
from openpype.pipeline import get_current_task_name
import openpype.hosts.blender.api.plugin
from openpype.hosts.blender.api import lib

Expand All @@ -22,7 +22,7 @@ def process(self):
name = openpype.hosts.blender.api.plugin.asset_name(asset, subset)
collection = bpy.data.collections.new(name=name)
bpy.context.scene.collection.children.link(collection)
self.data['task'] = legacy_io.Session.get('AVALON_TASK')
self.data['task'] = get_current_task_name()
lib.imprint(collection, self.data)

if (self.options or {}).get("useSelection"):
Expand Down
4 changes: 2 additions & 2 deletions openpype/hosts/blender/plugins/create/create_review.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import bpy

from openpype.pipeline import legacy_io
from openpype.pipeline import get_current_task_name
from openpype.hosts.blender.api import plugin, lib, ops
from openpype.hosts.blender.api.pipeline import AVALON_INSTANCES

Expand Down Expand Up @@ -33,7 +33,7 @@ def _process(self):
name = plugin.asset_name(asset, subset)
asset_group = bpy.data.collections.new(name=name)
instances.children.link(asset_group)
self.data['task'] = legacy_io.Session.get('AVALON_TASK')
self.data['task'] = get_current_task_name()
lib.imprint(asset_group, self.data)

if (self.options or {}).get("useSelection"):
Expand Down
4 changes: 2 additions & 2 deletions openpype/hosts/blender/plugins/create/create_rig.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import bpy

from openpype.pipeline import legacy_io
from openpype.pipeline import get_current_task_name
from openpype.hosts.blender.api import plugin, lib, ops
from openpype.hosts.blender.api.pipeline import AVALON_INSTANCES

Expand Down Expand Up @@ -34,7 +34,7 @@ def _process(self):
asset_group = bpy.data.objects.new(name=name, object_data=None)
asset_group.empty_display_type = 'SINGLE_ARROW'
instances.objects.link(asset_group)
self.data['task'] = legacy_io.Session.get('AVALON_TASK')
self.data['task'] = get_current_task_name()
lib.imprint(asset_group, self.data)

# Add selected objects to instance
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import bpy

import pyblish.api
from openpype.pipeline import legacy_io
from openpype.pipeline import get_current_task_name, get_current_asset_name
from openpype.hosts.blender.api import workio


Expand Down Expand Up @@ -37,7 +37,7 @@ def process(self, context):
folder, file = os.path.split(current_file)
filename, ext = os.path.splitext(file)

task = legacy_io.Session["AVALON_TASK"]
task = get_current_task_name()

data = {}

Expand All @@ -47,7 +47,7 @@ def process(self, context):

data.update({
"subset": subset,
"asset": os.getenv("AVALON_ASSET", None),
"asset": get_current_asset_name(),
"label": subset,
"publish": True,
"family": "workfile",
Expand Down
3 changes: 1 addition & 2 deletions openpype/hosts/blender/plugins/publish/collect_review.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import bpy

import pyblish.api
from openpype.pipeline import legacy_io


class CollectReview(pyblish.api.InstancePlugin):
Expand Down Expand Up @@ -39,7 +38,7 @@ def process(self, instance):

if not instance.data.get("remove"):

task = legacy_io.Session.get("AVALON_TASK")
task = instance.context.data["task"]

instance.data.update({
"subset": f"{task}Review",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import os
import pyblish.api
from openpype.pipeline import legacy_io


class CollectCelactionInstances(pyblish.api.ContextPlugin):
Expand All @@ -10,7 +9,7 @@ class CollectCelactionInstances(pyblish.api.ContextPlugin):
order = pyblish.api.CollectorOrder + 0.1

def process(self, context):
task = legacy_io.Session["AVALON_TASK"]
task = context.data["task"]
current_file = context.data["currentFile"]
staging_dir = os.path.dirname(current_file)
scene_file = os.path.basename(current_file)
Expand Down
Loading