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

Don't use legacy io #8

Merged
merged 11 commits into from
Feb 12, 2024
3 changes: 0 additions & 3 deletions client/ayon_core/host/host.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ class HostBase(object):
Todo:
- move content of 'install_host' as method of this class
- register host object
- install legacy_io
- install global plugin paths
- store registered plugin paths to this object
- handle current context (project, asset, task)
Expand Down Expand Up @@ -133,8 +132,6 @@ def get_current_context(self):
can be opened multiple workfiles at one moment and change of context
can't be caught properly.

Default implementation returns values from 'legacy_io.Session'.

Returns:
Dict[str, Union[str, None]]: Context with 3 keys 'project_name',
'asset_name' and 'task_name'. All of them can be 'None'.
Expand Down
5 changes: 1 addition & 4 deletions client/ayon_core/hosts/aftereffects/api/launch_logic.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

from ayon_core.lib import Logger
from ayon_core.tests.lib import is_in_tests
from ayon_core.pipeline import install_host, legacy_io
from ayon_core.pipeline import install_host
from ayon_core.addon import AddonsManager
from ayon_core.tools.utils import host_tools, get_ayon_qt_app
from ayon_core.tools.adobe_webserver.app import WebServerTool
Expand Down Expand Up @@ -298,13 +298,10 @@ async def set_context(self, project, asset, task):
log.info("Setting context change")
log.info("project {} asset {} ".format(project, asset))
if project:
legacy_io.Session["AVALON_PROJECT"] = project
os.environ["AVALON_PROJECT"] = project
if asset:
legacy_io.Session["AVALON_ASSET"] = asset
os.environ["AVALON_ASSET"] = asset
if task:
legacy_io.Session["AVALON_TASK"] = task
os.environ["AVALON_TASK"] = task

async def read(self):
Expand Down
3 changes: 1 addition & 2 deletions client/ayon_core/hosts/blender/api/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
from ayon_core.client import get_asset_by_name
from ayon_core.pipeline import (
schema,
legacy_io,
get_current_project_name,
get_current_asset_name,
register_loader_plugin_path,
Expand Down Expand Up @@ -380,7 +379,7 @@ def _on_task_changed():
# `directory` attribute, so it opens in that directory (does it?).
# https://docs.blender.org/api/blender2.8/bpy.types.Operator.html#calling-a-file-selector
# https://docs.blender.org/api/blender2.8/bpy.types.WindowManager.html#bpy.types.WindowManager.fileselect_add
workdir = legacy_io.Session["AVALON_WORKDIR"]
workdir = os.getenv("AVALON_WORKDIR")
log.debug("New working directory: %s", workdir)


Expand Down
3 changes: 1 addition & 2 deletions client/ayon_core/hosts/fusion/api/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
EnumDef,
)
from ayon_core.pipeline import (
legacy_io,
Creator,
CreatedInstance
)
Expand Down Expand Up @@ -136,7 +135,7 @@ def _configure_saver_tool(self, data, tool, subset):
ext = data["creator_attributes"]["image_format"]

# Subset change detected
workdir = os.path.normpath(legacy_io.Session["AVALON_WORKDIR"])
workdir = os.path.normpath(os.getenv("AVALON_WORKDIR"))
formatting_data.update({
"workdir": workdir,
"frame": "0" * frame_padding,
Expand Down
5 changes: 3 additions & 2 deletions client/ayon_core/hosts/houdini/api/usd.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

from ayon_core import style
from ayon_core.client import get_asset_by_name
from ayon_core.pipeline import legacy_io, get_current_project_name
from ayon_core.pipeline import get_current_project_name
from ayon_core.tools.utils.assets_widget import SingleSelectAssetsWidget

from pxr import Sdf
Expand All @@ -27,7 +27,8 @@ def __init__(self, parm):
self.setWindowTitle("Pick Asset")
self.setWindowFlags(QtCore.Qt.FramelessWindowHint | QtCore.Qt.Popup)

assets_widget = SingleSelectAssetsWidget(legacy_io, parent=self)
assets_widget = SingleSelectAssetsWidget(self)
assets_widget.set_project_name(get_current_project_name(), False)

layout = QtWidgets.QHBoxLayout(self)
layout.addWidget(assets_widget)
Expand Down
7 changes: 3 additions & 4 deletions client/ayon_core/hosts/maya/api/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
emit_event
)
from ayon_core.pipeline import (
legacy_io,
get_current_project_name,
register_loader_plugin_path,
register_inventory_action_path,
Expand Down Expand Up @@ -247,7 +246,7 @@ def _set_project():
None

"""
workdir = legacy_io.Session["AVALON_WORKDIR"]
workdir = os.getenv("AVALON_WORKDIR")

try:
os.makedirs(workdir)
Expand Down Expand Up @@ -629,7 +628,7 @@ def on_task_changed():
# Run
menu.update_menu_task_label()

workdir = legacy_io.Session["AVALON_WORKDIR"]
workdir = os.getenv("AVALON_WORKDIR")
if os.path.exists(workdir):
log.info("Updating Maya workspace for task change to %s", workdir)
_set_project()
Expand Down Expand Up @@ -678,7 +677,7 @@ def workfile_save_before_xgen(event):

import xgenm

current_work_dir = legacy_io.Session["AVALON_WORKDIR"].replace("\\", "/")
current_work_dir = os.getenv("AVALON_WORKDIR").replace("\\", "/")
expected_work_dir = event.data["workdir_path"].replace("\\", "/")
if current_work_dir == expected_work_dir:
return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
from ayon_core.settings import get_project_settings
from ayon_core.pipeline import (
load,
legacy_io,
get_representation_path
)
from ayon_core.hosts.maya.api.lib import (
Expand All @@ -26,11 +25,6 @@ def is_sequence(files):
return sequence


def get_current_session_fps():
session_fps = float(legacy_io.Session.get('AVALON_FPS', 25))
return convert_to_maya_fps(session_fps)


class ArnoldStandinLoader(load.LoaderPlugin):
"""Load as Arnold standin"""

Expand Down Expand Up @@ -99,7 +93,7 @@ def load(self, context, name, namespace, options):
sequence = is_sequence(os.listdir(os.path.dirname(repre_path)))
cmds.setAttr(standin_shape + ".useFrameExtension", sequence)

fps = float(version["data"].get("fps"))or get_current_session_fps()
fps = float(version["data"].get("fps")) or 25
cmds.setAttr(standin_shape + ".abcFPS", fps)

nodes = [root, standin, standin_shape]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
# -*- coding: utf-8 -*-
"""Collect Vray Scene and prepare it for extraction and publishing."""
import re

import maya.app.renderSetup.model.renderSetup as renderSetup
from maya import cmds

import pyblish.api

from ayon_core.pipeline import legacy_io
from ayon_core.lib import get_formatted_current_time
from ayon_core.hosts.maya.api import lib

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
from ayon_core.client.mongo import OpenPypeMongoConnection
from ayon_core.hosts.maya.api.shader_definition_editor import (
DEFINITION_FILENAME)
from ayon_core.pipeline import legacy_io
from ayon_core.pipeline.publish import (
OptionalPyblishPluginMixin, PublishValidationError, ValidateContentsOrder)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import ayon_core.hosts.maya.api.action
from ayon_core.client import get_assets
from ayon_core.hosts.maya.api import lib
from ayon_core.pipeline import legacy_io
from ayon_core.pipeline.publish import (
PublishValidationError, ValidatePipelineOrder)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import ayon_core.hosts.maya.api.action
from ayon_core.client import get_subset_by_name
from ayon_core.pipeline import legacy_io
from ayon_core.pipeline.publish import PublishValidationError


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
import pyblish.api

import ayon_core.hosts.maya.api.action
from ayon_core.pipeline import legacy_io
from ayon_core.settings import get_project_settings
from ayon_core.pipeline.publish import (
ValidateContentsOrder,
OptionalPyblishPluginMixin,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

import pyblish.api

from ayon_core.pipeline import legacy_io
from openpype_modules.webpublisher.lib import (
get_batch_asset_task_info,
parse_json
Expand Down Expand Up @@ -71,8 +70,6 @@ def process(self, context):

os.environ["AVALON_ASSET"] = asset_name
os.environ["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
Expand Down
4 changes: 0 additions & 4 deletions client/ayon_core/hosts/traypublisher/api/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

from ayon_core.pipeline import (
register_creator_plugin_path,
legacy_io,
)
from ayon_core.host import HostBase, IPublishHost

Expand All @@ -24,7 +23,6 @@ class TrayPublisherHost(HostBase, IPublishHost):

def install(self):
os.environ["AVALON_APP"] = self.name
legacy_io.Session["AVALON_APP"] = self.name

pyblish.api.register_host("traypublisher")
pyblish.api.register_plugin_path(PUBLISH_PATH)
Expand All @@ -43,8 +41,6 @@ def set_project_name(self, project_name):
# TODO Deregister project specific plugins and register new project
# plugins
os.environ["AVALON_PROJECT"] = project_name
legacy_io.Session["AVALON_PROJECT"] = project_name
legacy_io.install()
HostContext.set_project_name(project_name)


Expand Down
6 changes: 2 additions & 4 deletions client/ayon_core/hosts/tvpaint/api/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
from ayon_core.settings import get_current_project_settings
from ayon_core.lib import register_event_callback
from ayon_core.pipeline import (
legacy_io,
register_loader_plugin_path,
register_creator_plugin_path,
AVALON_CONTAINER_ID,
Expand Down Expand Up @@ -66,11 +65,10 @@ class TVPaintHost(HostBase, IWorkfileHost, ILoadHost, IPublishHost):
def install(self):
"""Install TVPaint-specific functionality."""

log.info("OpenPype - Installing TVPaint integration")
legacy_io.install()
log.info("AYON - Installing TVPaint integration")

# Create workdir folder if does not exist yet
workdir = legacy_io.Session["AVALON_WORKDIR"]
workdir = os.getenv("AVALON_WORKDIR")
if not os.path.exists(workdir):
os.makedirs(workdir)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

import pyblish.api

from ayon_core.pipeline import legacy_io
from ayon_core.hosts.tvpaint.api.lib import (
execute_george,
execute_george_through_file,
Expand Down Expand Up @@ -90,7 +89,6 @@ def process(self, context):
("AVALON_TASK", "task_name")
)
for env_key, key in key_map:
legacy_io.Session[env_key] = workfile_context[key]
os.environ[env_key] = workfile_context[key]
self.log.info("Context changed to: {}".format(workfile_context))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
env_value_to_bool,
collect_frames,
)
from ayon_core.pipeline import legacy_io
from openpype_modules.deadline import abstract_submit_deadline
from openpype_modules.deadline.abstract_submit_deadline import DeadlineJobInfo
from ayon_core.tests.lib import is_in_tests
Expand Down Expand Up @@ -84,13 +83,17 @@ def get_job_info(self):
"AVALON_PROJECT",
"AVALON_ASSET",
"AVALON_TASK",
"AVALON_WORKDIR",
"AVALON_APP_NAME",
"AYON_LOG_NO_COLORS",
"IS_TEST"
]

environment = dict({key: os.environ[key] for key in keys
if key in os.environ}, **legacy_io.Session)
environment = {
key: os.environ[key]
for key in keys
if key in os.environ
}
for key in keys:
value = environment.get(key)
if value:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
NumberDef,
TextDef,
)
from ayon_core.pipeline import legacy_io
from ayon_core.pipeline.publish import AYONPyblishPluginMixin
from ayon_core.pipeline.farm.tools import iter_expected_files
from ayon_core.tests.lib import is_in_tests
Expand Down Expand Up @@ -106,12 +105,16 @@ def get_job_info(self):
"AVALON_PROJECT",
"AVALON_ASSET",
"AVALON_TASK",
"AVALON_WORKDIR",
"AVALON_APP_NAME",
"IS_TEST"
]

environment = dict({key: os.environ[key] for key in keys
if key in os.environ}, **legacy_io.Session)
environment = {
key: os.environ[key]
for key in keys
if key in os.environ
}

for key in keys:
value = environment.get(key)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

import pyblish.api

from ayon_core.pipeline import legacy_io
from ayon_core.pipeline.publish import (
AYONPyblishPluginMixin
)
Expand Down Expand Up @@ -224,14 +223,18 @@ def process(self, instance):
"AVALON_PROJECT",
"AVALON_ASSET",
"AVALON_TASK",
"AVALON_WORKDIR",
"AVALON_APP_NAME",
"AYON_LOG_NO_COLORS",
"IS_TEST",
"AYON_BUNDLE_NAME",
]

environment = dict({key: os.environ[key] for key in keys
if key in os.environ}, **legacy_io.Session)
environment = {
key: os.environ[key]
for key in keys
if key in os.environ
}

# to recognize render jobs
environment["AYON_RENDER_JOB"] = "1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import attr
import pyblish.api

from ayon_core.pipeline import legacy_io
from openpype_modules.deadline import abstract_submit_deadline
from openpype_modules.deadline.abstract_submit_deadline import DeadlineJobInfo
from ayon_core.tests.lib import is_in_tests
Expand Down Expand Up @@ -277,13 +276,17 @@ def get_job_info(self):
"AVALON_PROJECT",
"AVALON_ASSET",
"AVALON_TASK",
"AVALON_WORKDIR",
"AVALON_APP_NAME",
"AYON_LOG_NO_COLORS"
"IS_TEST"
]

environment = dict({key: os.environ[key] for key in keys
if key in os.environ}, **legacy_io.Session)
environment = {
key: os.environ[key]
for key in keys
if key in os.environ
}
for key in keys:
value = environment.get(key)
if value:
Expand Down
Loading