General: Reduce usage of legacy io (#4723)

* General: Connect to AYON server (base) (#3924)

* implemented 'get_workfile_info' in entities

* removed 'prepare_asset_update_data' which is not used

* disable settings and project manager if in v4 mode

* prepared conversion helper functions for v4 entities

* prepared conversion functions for hero versions

* fix hero versions

* implemented get_archived_representations

* fix get latest versions

* return prepared changes

* handle archived representation

* raise exception on failed json conversion

* map archived to active properly

* make sure default fields are added

* fix conversion of hero version entity

* fix conversion of archived representations

* fix some conversions of representations and versions

* changed active behavior in queries

* fixed hero versions

* implemented basic thumbnail caching

* added raw variants of crud methods

* implemented methods to get and create thumbnail

* fix from flat dict

* implemented some basic folder conversion for updates

* fix thumbnail updates for version

* implemented v4 thumbnail integrator

* simplified data mapping

* 'get_thumbnail' function also expect entity type and entity id for which is the thumbnail received

* implemented 'get_thumbnail' for server

* fix how thumbnail id is received from entity

* removed unnecessary method 'get_thumbnail_id_from_source'

* implemented thumbnail resolver for v4

* removed unnecessary print

* move create and delete project directly to server api

* disable local settings action too on v4

* OP-3521 - added method to check and download updated addons from v4 server

* OP-3521 - added more descriptive error message for missing source

* OP-3521 - added default implementation of addon downloader to import

* OP-3521 - added check for dependency package zips

WIP - server doesn't contain required endpoint. Testing only with mockup data for now.

* OP-3521 - fixed parsing of DependencyItem

Added Server Url type and ServerAddonDownloader - v4 server doesn't know its own DNS for static files so it is sending unique name and url must be created during runtime.

* OP-3521 - fixed creation of targed directories

* change nev keys to look for and don't set them automatically

* fix task type conversion

* implemented base of loading v4 addons in v3

* Refactored argument name in Downloaders

* Updated parsing to DependencyItem according to current schema

* Implemented downloading of package from server

* Updated resolving of failures

Uses Enum items.

* Introduced passing of authorization token

Better to inject it than to have it from env var.

* Remove weird parsing of server_url

Not necessary, endpoints have same prefix.

* Fix doubling asset version name in addons folder

Zip file should already contain `addonName_addonVersion` as first subfolder

* Fix doubling asset version name in addons folder

Zip file should already contain `addonName_addonVersion` as first subfolder

* Made server_endpoint optional

Argument should be better for testing, but for calling from separate methods it would be better to encapsulate it.

Removed unwanted temporary productionPackage value

* Use existing method to pull addon info from Server to load v4 version of addon

* Raise exception when server doesn't have any production dependency package

* added ability to specify v3 alias of addon name

* expect v3_alias as uppered constant

* Re-implemented method to get addon info

Previous implementation wouldn't work in Python2 hosts.
Will be refactored in the future.

* fix '__getattr__'

* added ayon api to pyproject.toml and lock file

* use ayon api in common connection

* added mapping for label

* use ayon_api in client codebase

* separated clearing cache of url and username

* bump ayon api version

* rename env 'OP4_TEST' to 'USE_AYON_SERVER'

* Move and renamend get_addons_info to get_addons_info_as_dict in addon_distribution

Should be moved to ayon_api later

* Replaced requests calls with ayon_api

* Replaced OP4_TEST_ENABLED with AYON_SERVER_ENABLED

fixed endpoints

* Hound

* Hound

* OP-3521 - fix wrong key in get_representation_parents

parents overloads parents

* OP-3521 - changes for v4 of SiteSync addon

* OP-3521 - fix names

* OP-3521 - remove storing project_name

It should be safer to go thorug self.dbcon apparently

* OP-3521 - remove unwanted

"context["folder"]" can be only in dummy test data

* OP-3521 - move site sync loaders to addon

* Use only project instead of self.project

* OP-3521 - added missed get_progress_for_repre

* base of settings conversion script

* simplified ayon functions in start.py

* added loading of settings from ayon server

* added a note about colors

* fix global and local settings functions

* AvalonMongoDB is not using mongo connection on ayon server enabled

* 'get_dynamic_modules_dirs' is not checking system settings for paths in setting

* log viewer is disabled when ayon server is enabled

* basic logic of enabling/disabled addons

* don't use mongo logging if ayon server is enabled

* update ayon api

* bump ayon api again

* use ayon_api to get addons info in modules/base

* update ayon api

* moved helper functions to get addons and dependencies dir to common functions

* Initialization of AddonInfo is not crashing on unkonwn sources

* renamed 'DependencyDownloader' to 'AyonServerDownloader'

* renamed function 'default_addon_downloader' to 'get_default_addon_downloader'

* Added ability to convert 'WebAddonSource' to 'ServerResourceSorce'

* missing dependency package on server won't cause crash

* data sent to downloaders don't contain ayon specific headers

* modified addon distribution to not duplicate 'ayon_api' functionality

* fix doubled function defintioin

* unzip client file to addon destination

* formatting - unify quotes

* disable usage of mongo connection if in ayon mode

* renamed window.py to login_window.py

* added webpublisher settings conversion

* added maya conversion function

* reuse variable

* reuse variable (similar to previous commit)

* fix ayon addons loading

* fix typo 'AyonSettingsCahe' -> 'AyonSettingsCache'

* fix enabled state changes

* fix rr_path in royal render conversion

* avoid mongo calls in AYON state

* implemented custom AYON start script

* fix formatting (after black)

* ayon_start cleanup

* 'get_addons_dir' and 'get_dependencies_dir' store value to environment variable

* add docstrings to local dir functions

* addon info has full name

* fix modules enabled states

* removed unused 'run_disk_mapping_commands'

* removed ayon logic from 'start.py'

* fix warning message

* renamed 'openpype_common' to 'ayon_common'

* removed unused import

* don't import igniter

* removed startup validations of third parties

* change what's shown in version info

* fix which keys are applied from ayon values

* fix method name

* get applications from attribs

* Implemented UI basics to be able change user or logout

* merged server.py and credentials.py

* add more metadata to urls

* implemented change token

* implemented change user ui functionality

* implemented change user ui

* modify window to handle username and token value

* pass username to add server

* fix show UI cases

* added loggin action to tray

* update ayon api

* added missing dependency

* convert applications to config in a right way

* initial implementation of 'nuke' settings conversion

* removed few nuke comments

* implemented hiero conversion

* added imageio conversion

* added run ayon tray script

* fix few settings conversions

* Renamed class of source classes as they are not just for addons

* implemented objec to track source transfer progress

* Implemented distribution item with multiple sources

* Implemented ayon distribution wrapper to care about multiple things during distribution

* added 'cleanup' method for downlaoders

* download gets tranfer progress object

* Change UploadState enum

* added missing imports

* use AyonDistribution in ayon_start.py

* removed unused functions

* removed implemented TODOs

* fix import

* fix key used for Web source

* removed temp development fix

* formatting fix

* keep information if source require distribution

* handle 'require_distribution' attribute in distribution process

* added path attribute to server source

* added option to pass addons infor to ayon distribution

* fix tests

* fix formatting

* Fix typo

* Fix typo

* remove '_try_convert_to_server_source'

* renamed attributes and methods to match their content

* it is possible to pass dependency package info to AyonDistribution

* fix called methods in tests

* added public properties for error message and error detail

* Added filename to WebSourceInfo

Useful for GDrive sharable links where target file name is unknown/unparsable, it should be provided explicitly.

* unify source conversion by adding 'convert_source' function

* Fix error message

Co-authored-by: Roy Nieterau <roy_nieterau@hotmail.com>

* added docstring for 'transfer_progress'

* don't create metadata file on read

* added few docstrings

* add default folder fields to folder/task queries

* fix generators

* add dependencies when runnign from code

* add sys paths from distribution to pythonpath env

* fix missing applications

* added missing conversions for maya renderers

* fix formatting

* update ayon api

* fix hashes in lock file

* Use better exception

Co-authored-by: Ondřej Samohel <33513211+antirotor@users.noreply.github.com>

* Use Python 3 syntax

Co-authored-by: Ondřej Samohel <33513211+antirotor@users.noreply.github.com>

* apply some of sugested changes in ayon_start

* added some docstrings and suggested modifications

* copy create env from develop

* fix rendersettings conversion

* change code by suggestions

* added missing args to docstring

* added missing docstrings

* separated downloader and download factory

* fix ayon settings

* added some basic file docstring to ayon_settings

* join else conditions

* fix project settings conversion

* fix created at conversion

* fix workfile info query

* fix publisher UI

* added utils function 'get_ayon_appdirs'

* fix 'get_all_current_info'

* fix server url assignment when url is set

* updated ayon api

* added utils functions to create local site id for ayon

* added helper functions to create global connection

* create global connection in ayon start to start use site id

* use ayon site id in ayon mode

* formatting cleanup

* added header docstring

* fixes after ayon_api update

* load addons from ynput appdirs

* fix function call

* added docstring

* update ayon pyton api

* fix settings access

* use ayon_api to get root overrides in Anatomy

* bumbayon version to 0.1.13

* nuke: fixing settings keys from settings

* fix burnins definitions

* change v4 to AYON in thumbnail integrate

* fix one more v4 information

* Fixes after rebase

* fix extract burnin conversion

* additional fix of extract burnin

* SiteSync:added missed loaders or v3 compatibility (#4587)

* Added site sync loaders for v3 compatibility

* Fix get_progress_for_repre

* use 'files.name' instead of 'files.baseName'

* update ayon api to 0.1.14

* add common to include files

* change arguments for hero version creation

* skip shotgrid settings conversion if different ayon addon is used

* added ayon icons

* fix labels of application variants

* added option to show login window always on top

* login window on invalid credentials is always on top

* update ayon api

* update ayon api

* add entityType to project and folders

* AYON: Editorial hierarchy creation (#4699)

* disable extract hierarchy avalon when ayon mode is enabled

* implemented extract hierarchy to AYON

---------

Co-authored-by: Petr Kalis <petr.kalis@gmail.com>
Co-authored-by: Roy Nieterau <roy_nieterau@hotmail.com>
Co-authored-by: Ondřej Samohel <33513211+antirotor@users.noreply.github.com>
Co-authored-by: Jakub Jezek <jakubjezek001@gmail.com>

* replace 'legacy_io' with context functions in load plugins

* added 'get_global_context' to pipeline init

* use context getters instead of legacy_io in publish plugins

* use data on context instead of  'legacy_io' in submit publish job

* skip query of asset docs in collect nuke reads

* use context functions on other places

* 'list_looks' expects project name

* remove 'get_context_title'

* don't pass AvalonMongoDB to prelaunch hooks

* change how context is calculated in hiero

* implemented function 'get_fps_for_current_context' for maya

* initialize '_image_dir' and '_image_prefixes' in init

* legacy creator is using 'get_current_project_name'

* fill docstrings

* use context functions in workfile builders

* hound fixes

* 'create_workspace_mel' can expect project settings

* swapped order of arguments

* use information from instance/context data

* Use self.project_name in workfiles tool

Co-authored-by: Roy Nieterau <roy_nieterau@hotmail.com>

* Remove outdated todo

Co-authored-by: Roy Nieterau <roy_nieterau@hotmail.com>

* don't query project document in nuke lib

* Fix access to context data

* Use right function to get project name

Co-authored-by: Roy Nieterau <roy_nieterau@hotmail.com>

* fix submit max deadline and swap order of arguments

* added 'get_context_label' to nuke

* fix import

* fix typo 'curent_context' -> 'current_context'

* fix project_setting variable

* fix submit publish job environments

* use task from context

* Removed unused import

---------

Co-authored-by: Petr Kalis <petr.kalis@gmail.com>
Co-authored-by: Roy Nieterau <roy_nieterau@hotmail.com>
Co-authored-by: Ondřej Samohel <33513211+antirotor@users.noreply.github.com>
Co-authored-by: Jakub Jezek <jakubjezek001@gmail.com>
This commit is contained in:
Jakub Trllo 2023-04-04 10:29:39 +02:00 committed by Jakub Trllo
parent 4015d39c15
commit c10781a662
129 changed files with 598 additions and 508 deletions

View file

@ -5,7 +5,7 @@ from openpype.lib import (
prepare_app_environments,
prepare_context_environments
)
from openpype.pipeline import AvalonMongoDB, Anatomy
from openpype.pipeline import Anatomy
class GlobalHostDataHook(PreLaunchHook):
@ -26,7 +26,6 @@ class GlobalHostDataHook(PreLaunchHook):
"app": app,
"dbcon": self.data["dbcon"],
"project_doc": self.data["project_doc"],
"asset_doc": self.data["asset_doc"],
@ -62,13 +61,6 @@ class GlobalHostDataHook(PreLaunchHook):
# 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

View file

@ -149,7 +149,7 @@ class HostDirmap(object):
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

View file

@ -1,7 +1,6 @@
import os
import pyblish.api
from openpype.pipeline import legacy_io
from openpype.pipeline.create import get_subset_name
@ -44,7 +43,7 @@ class CollectWorkfile(pyblish.api.ContextPlugin):
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"]

View file

@ -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,
@ -30,7 +30,7 @@ class ValidateInstanceAssetRepair(pyblish.api.Action):
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)
@ -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}."

View file

@ -16,7 +16,7 @@ import bpy
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
@ -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
)
@ -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
@ -362,8 +362,8 @@ class TOPBAR_MT_avalon(bpy.types.Menu):
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(

View file

@ -14,6 +14,8 @@ from openpype.client import get_asset_by_name
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,
@ -112,8 +114,8 @@ def message_window(title, message):
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

View file

@ -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
@ -22,7 +22,7 @@ class CreateAction(openpype.hosts.blender.api.plugin.Creator):
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"):

View file

@ -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
@ -37,7 +37,7 @@ class CreateAnimation(plugin.Creator):
# 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"):

View file

@ -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
@ -35,7 +35,7 @@ class CreateCamera(plugin.Creator):
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)

View file

@ -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
@ -34,7 +34,7 @@ class CreateLayout(plugin.Creator):
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

View file

@ -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
@ -34,7 +34,7 @@ class CreateModel(plugin.Creator):
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

View file

@ -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
@ -22,7 +22,7 @@ class CreatePointcache(openpype.hosts.blender.api.plugin.Creator):
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"):

View file

@ -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
@ -33,7 +33,7 @@ class CreateReview(plugin.Creator):
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"):

View file

@ -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
@ -34,7 +34,7 @@ class CreateRig(plugin.Creator):
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

View file

@ -2,7 +2,7 @@ import os
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
@ -37,7 +37,7 @@ class CollectBlenderCurrentFile(pyblish.api.ContextPlugin):
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 = {}
@ -47,7 +47,7 @@ class CollectBlenderCurrentFile(pyblish.api.ContextPlugin):
data.update({
"subset": subset,
"asset": os.getenv("AVALON_ASSET", None),
"asset": get_current_asset_name(),
"label": subset,
"publish": True,
"family": "workfile",

View file

@ -1,7 +1,6 @@
import bpy
import pyblish.api
from openpype.pipeline import legacy_io
class CollectReview(pyblish.api.InstancePlugin):
@ -39,7 +38,7 @@ class CollectReview(pyblish.api.InstancePlugin):
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",

View file

@ -1,6 +1,5 @@
import os
import pyblish.api
from openpype.pipeline import legacy_io
class CollectCelactionInstances(pyblish.api.ContextPlugin):
@ -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)

View file

@ -1,7 +1,9 @@
import os
from qtpy import QtWidgets
from copy import deepcopy
from pprint import pformat
from qtpy import QtWidgets
from openpype.pipeline import get_current_project_name
from openpype.tools.utils.host_tools import HostToolsHelper
menu_group_name = 'OpenPype'
@ -61,10 +63,10 @@ class _FlameMenuApp(object):
self.framework.prefs_global, self.name)
self.mbox = QtWidgets.QMessageBox()
project_name = get_current_project_name()
self.menu = {
"actions": [{
'name': os.getenv("AVALON_PROJECT", "project"),
'name': project_name or "project",
'isEnabled': False
}],
"name": self.menu_group_name

View file

@ -2,7 +2,6 @@ import pyblish.api
import openpype.hosts.flame.api as opfapi
from openpype.hosts.flame.otio import flame_export
from openpype.pipeline import legacy_io
from openpype.pipeline.create import get_subset_name
@ -19,7 +18,7 @@ class CollecTimelineOTIO(pyblish.api.ContextPlugin):
# main
asset_doc = context.data["assetEntity"]
task_name = legacy_io.Session["AVALON_TASK"]
task_name = context.data["task"]
project = opfapi.get_current_project()
sequence = opfapi.get_current_sequence(opfapi.CTX.selection)

View file

@ -14,7 +14,7 @@ from openpype.client import (
)
from openpype.pipeline import (
switch_container,
legacy_io,
get_current_project_name,
)
from openpype.pipeline.context_tools import get_current_project_asset
@ -206,7 +206,7 @@ def switch_item(container,
# Collect any of current asset, subset and representation if not provided
# so we can use the original name from those.
project_name = legacy_io.active_project()
project_name = get_current_project_name()
if any(not x for x in [asset_name, subset_name, representation_name]):
repre_id = container["representation"]
representation = get_representation_by_id(project_name, repre_id)

View file

@ -12,7 +12,7 @@ from openpype.hosts.fusion.api.lib import (
set_asset_framerange,
set_asset_resolution,
)
from openpype.pipeline import legacy_io
from openpype.pipeline import get_current_asset_name
from openpype.resources import get_openpype_icon_filepath
from .pipeline import FusionEventHandler
@ -125,7 +125,7 @@ class OpenPypeMenu(QtWidgets.QWidget):
def on_task_changed(self):
# Update current context label
label = legacy_io.Session["AVALON_ASSET"]
label = get_current_asset_name()
self.asset_label.setText(label)
def register_callback(self, name, fn):

View file

@ -11,7 +11,7 @@ from openpype.client import get_assets
from openpype import style
from openpype.pipeline import (
install_host,
legacy_io,
get_current_project_name,
)
from openpype.hosts.fusion import api
from openpype.pipeline.context_tools import get_workdir_from_session
@ -167,7 +167,7 @@ class App(QtWidgets.QWidget):
return items
def collect_asset_names(self):
project_name = legacy_io.active_project()
project_name = get_current_project_name()
asset_docs = get_assets(project_name, fields=["name"])
asset_names = {
asset_doc["name"]

View file

@ -5,7 +5,6 @@ from openpype.client import get_asset_by_name
from openpype.pipeline import (
AutoCreator,
CreatedInstance,
legacy_io,
)
@ -64,10 +63,10 @@ class FusionWorkfileCreator(AutoCreator):
existing_instance = instance
break
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"]
project_name = self.create_context.get_current_project_name()
asset_name = self.create_context.get_current_asset_name()
task_name = self.create_context.get_current_task_name()
host_name = self.create_context.host_name
if existing_instance is None:
asset_doc = get_asset_by_name(project_name, asset_name)

View file

@ -610,7 +610,7 @@ class ImageSequenceLoader(load.LoaderPlugin):
def update(self, container, representation):
node = container.pop("node")
project_name = legacy_io.active_project()
project_name = get_current_project_name()
version = get_version_by_id(project_name, representation["parent"])
files = []
for f in version["data"]["files"]:

View file

@ -5,7 +5,6 @@ from pathlib import Path
import attr
from openpype.lib import get_formatted_current_time
from openpype.pipeline import legacy_io
from openpype.pipeline import publish
from openpype.pipeline.publish import RenderInstance
import openpype.hosts.harmony.api as harmony
@ -99,6 +98,8 @@ class CollectFarmRender(publish.AbstractCollectRender):
self_name = self.__class__.__name__
asset_name = context.data["asset"]
for node in context.data["allNodes"]:
data = harmony.read(node)
@ -141,7 +142,7 @@ class CollectFarmRender(publish.AbstractCollectRender):
source=context.data["currentFile"],
label=node.split("/")[1],
subset=subset_name,
asset=legacy_io.Session["AVALON_ASSET"],
asset=asset_name,
task=task_name,
attachTo=False,
setMembers=[node],

View file

@ -1,6 +1,5 @@
# -*- coding: utf-8 -*-
"""Collect palettes from Harmony."""
import os
import json
import re
@ -32,6 +31,7 @@ class CollectPalettes(pyblish.api.ContextPlugin):
if (not any([re.search(pattern, task_name)
for pattern in self.allowed_tasks])):
return
asset_name = context.data["asset"]
for name, id in palettes.items():
instance = context.create_instance(name)
@ -39,7 +39,7 @@ class CollectPalettes(pyblish.api.ContextPlugin):
"id": id,
"family": "harmony.palette",
'families': [],
"asset": os.environ["AVALON_ASSET"],
"asset": asset_name,
"subset": "{}{}".format("palette", name)
})
self.log.info(

View file

@ -36,5 +36,5 @@ class CollectWorkfile(pyblish.api.ContextPlugin):
"family": family,
"families": [family],
"representations": [],
"asset": os.environ["AVALON_ASSET"]
"asset": context.data["asset"]
})

View file

@ -75,7 +75,7 @@ class ExtractTemplate(publish.Extractor):
instance.data["representations"] = [representation]
instance.data["version_name"] = "{}_{}".format(
instance.data["subset"], os.environ["AVALON_TASK"])
instance.data["subset"], instance.context.data["task"])
def get_backdrops(self, node: str) -> list:
"""Get backdrops for the node.

View file

@ -1,8 +1,7 @@
import os
import pyblish.api
import openpype.hosts.harmony.api as harmony
from openpype.pipeline import get_current_asset_name
from openpype.pipeline.publish import (
ValidateContentsOrder,
PublishXmlValidationError,
@ -30,7 +29,7 @@ class ValidateInstanceRepair(pyblish.api.Action):
for instance in instances:
data = harmony.read(instance.data["setMembers"][0])
data["asset"] = os.environ["AVALON_ASSET"]
data["asset"] = get_current_asset_name()
harmony.imprint(instance.data["setMembers"][0], data)
@ -44,7 +43,7 @@ class ValidateInstance(pyblish.api.InstancePlugin):
def process(self, instance):
instance_asset = instance.data["asset"]
current_asset = os.environ["AVALON_ASSET"]
current_asset = get_current_asset_name()
msg = (
"Instance asset is not the same as current asset:"
f"\nInstance: {instance_asset}\nCurrent: {current_asset}"

View file

@ -67,7 +67,9 @@ class ValidateSceneSettings(pyblish.api.InstancePlugin):
expected_settings["frameEndHandle"] = expected_settings["frameEnd"] +\
expected_settings["handleEnd"]
if (any(re.search(pattern, os.getenv('AVALON_TASK'))
task_name = instance.context.data["task"]
if (any(re.search(pattern, task_name)
for pattern in self.skip_resolution_check)):
self.log.info("Skipping resolution check because of "
"task name and pattern {}".format(

View file

@ -22,9 +22,7 @@ except ImportError:
from openpype.client import get_project
from openpype.settings import get_project_settings
from openpype.pipeline import (
get_current_project_name, legacy_io, Anatomy
)
from openpype.pipeline import Anatomy, get_current_project_name
from openpype.pipeline.load import filter_containers
from openpype.lib import Logger
from . import tags
@ -626,7 +624,7 @@ def get_publish_attribute(tag):
def sync_avalon_data_to_workfile():
# import session to get project dir
project_name = legacy_io.Session["AVALON_PROJECT"]
project_name = get_current_project_name()
anatomy = Anatomy(project_name)
work_template = anatomy.templates["work"]["path"]
@ -821,7 +819,7 @@ class PublishAction(QtWidgets.QAction):
# # create root node and save all metadata
# root_node = hiero.core.nuke.RootNode()
#
# anatomy = Anatomy(os.environ["AVALON_PROJECT"])
# anatomy = Anatomy(get_current_project_name())
# work_template = anatomy.templates["work"]["path"]
# root_path = anatomy.root_value_for_template(work_template)
#
@ -1041,7 +1039,7 @@ def _set_hrox_project_knobs(doc, **knobs):
def apply_colorspace_project():
project_name = os.getenv("AVALON_PROJECT")
project_name = get_current_project_name()
# get path the the active projects
project = get_current_project(remove_untitled=True)
current_file = project.path()
@ -1110,7 +1108,7 @@ def apply_colorspace_project():
def apply_colorspace_clips():
project_name = os.getenv("AVALON_PROJECT")
project_name = get_current_project_name()
project = get_current_project(remove_untitled=True)
clips = project.clips()
@ -1264,7 +1262,7 @@ def check_inventory_versions(track_items=None):
if not containers:
return
project_name = legacy_io.active_project()
project_name = get_current_project_name()
filter_result = filter_containers(containers, project_name)
for container in filter_result.latest:
set_track_color(container["_item"], clip_color_last)

View file

@ -4,12 +4,18 @@ import sys
import hiero.core
from hiero.ui import findMenuAction
from qtpy import QtGui
from openpype.lib import Logger
from openpype.pipeline import legacy_io
from openpype.tools.utils import host_tools
from openpype.settings import get_project_settings
from openpype.pipeline import (
get_current_project_name,
get_current_asset_name,
get_current_task_name
)
from . import tags
from openpype.settings import get_project_settings
log = Logger.get_logger(__name__)
@ -17,6 +23,13 @@ self = sys.modules[__name__]
self._change_context_menu = None
def get_context_label():
return "{}, {}".format(
get_current_asset_name(),
get_current_task_name()
)
def update_menu_task_label():
"""Update the task label in Avalon menu to current session"""
@ -27,10 +40,7 @@ def update_menu_task_label():
log.warning("Can't find menuItem: {}".format(object_name))
return
label = "{}, {}".format(
legacy_io.Session["AVALON_ASSET"],
legacy_io.Session["AVALON_TASK"]
)
label = get_context_label()
menu = found_menu.menu()
self._change_context_menu = label
@ -43,7 +53,6 @@ def menu_install():
"""
from qtpy import QtGui
from . import (
publish, launch_workfiles_app, reload_config,
apply_colorspace_project, apply_colorspace_clips
@ -56,10 +65,7 @@ def menu_install():
menu_name = os.environ['AVALON_LABEL']
context_label = "{0}, {1}".format(
legacy_io.Session["AVALON_ASSET"],
legacy_io.Session["AVALON_TASK"]
)
context_label = get_context_label()
self._change_context_menu = context_label
@ -154,7 +160,7 @@ def add_scripts_menu():
return
# load configuration of custom menu
project_settings = get_project_settings(os.getenv("AVALON_PROJECT"))
project_settings = get_project_settings(get_current_project_name())
config = project_settings["hiero"]["scriptsmenu"]["definition"]
_menu = project_settings["hiero"]["scriptsmenu"]["name"]

View file

@ -5,7 +5,7 @@ import hiero
from openpype.client import get_project, get_assets
from openpype.lib import Logger
from openpype.pipeline import legacy_io
from openpype.pipeline import get_current_project_name
log = Logger.get_logger(__name__)
@ -142,7 +142,7 @@ def add_tags_to_workfile():
nks_pres_tags = tag_data()
# Get project task types.
project_name = legacy_io.active_project()
project_name = get_current_project_name()
project_doc = get_project(project_name)
tasks = project_doc["config"]["tasks"]
nks_pres_tags["[Tasks]"] = {}

View file

@ -3,8 +3,8 @@ from openpype.client import (
get_last_version_by_subset_id
)
from openpype.pipeline import (
legacy_io,
get_representation_path,
get_current_project_name,
)
from openpype.lib.transcoding import (
VIDEO_EXTENSIONS,
@ -148,7 +148,7 @@ class LoadClip(phiero.SequenceLoader):
track_item = phiero.get_track_items(
track_item_name=namespace).pop()
project_name = legacy_io.active_project()
project_name = get_current_project_name()
version_doc = get_version_by_id(project_name, representation["parent"])
version_data = version_doc.get("data", {})
@ -211,7 +211,7 @@ class LoadClip(phiero.SequenceLoader):
@classmethod
def set_item_color(cls, track_item, version_doc):
project_name = legacy_io.active_project()
project_name = get_current_project_name()
last_version_doc = get_last_version_by_subset_id(
project_name, version_doc["parent"], fields=["_id"]
)

View file

@ -9,8 +9,8 @@ from openpype.client import (
from openpype.pipeline import (
AVALON_CONTAINER_ID,
load,
legacy_io,
get_representation_path
get_representation_path,
get_current_project_name
)
from openpype.hosts.hiero import api as phiero
from openpype.lib import Logger
@ -168,7 +168,7 @@ class LoadEffects(load.LoaderPlugin):
namespace = container['namespace']
# get timeline in out data
project_name = legacy_io.active_project()
project_name = get_current_project_name()
version_doc = get_version_by_id(project_name, representation["parent"])
version_data = version_doc["data"]
clip_in = version_data["clipIn"]

View file

@ -7,7 +7,6 @@ from qtpy.QtGui import QPixmap
import hiero.ui
from openpype.pipeline import legacy_io
from openpype.hosts.hiero.api.otio import hiero_export
@ -19,7 +18,7 @@ class PrecollectWorkfile(pyblish.api.ContextPlugin):
def process(self, context):
asset = legacy_io.Session["AVALON_ASSET"]
asset = context.data["asset"]
subset = "workfile"
active_timeline = hiero.ui.activeSequence()
project = active_timeline.project()

View file

@ -1,6 +1,5 @@
from pyblish import api
from openpype.client import get_assets
from openpype.pipeline import legacy_io
class CollectAssetBuilds(api.ContextPlugin):
@ -18,7 +17,7 @@ class CollectAssetBuilds(api.ContextPlugin):
hosts = ["hiero"]
def process(self, context):
project_name = legacy_io.active_project()
project_name = context.data["projectName"]
asset_builds = {}
for asset in get_assets(project_name):
if asset["data"]["entityType"] == "AssetBuild":

View file

@ -10,7 +10,7 @@ import json
import six
from openpype.client import get_asset_by_name
from openpype.pipeline import legacy_io
from openpype.pipeline import get_current_project_name, get_current_asset_name
from openpype.pipeline.context_tools import get_current_project_asset
import hou
@ -78,8 +78,8 @@ def generate_ids(nodes, asset_id=None):
"""
if asset_id is None:
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()
# Get the asset ID from the database for the asset of current context
asset_doc = get_asset_by_name(project_name, asset_name, fields=["_id"])
@ -474,8 +474,8 @@ def maintained_selection():
def reset_framerange():
"""Set frame range to current asset"""
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()
# Get the asset ID from the database for the asset of current context
asset_doc = get_asset_by_name(project_name, asset_name)
asset_data = asset_doc["data"]

View file

@ -4,6 +4,7 @@ import logging
import platform
from openpype.settings import get_project_settings
from openpype.pipeline import get_current_project_name
import hou
@ -17,7 +18,8 @@ def generate_shelves():
current_os = platform.system().lower()
# load configuration of houdini shelves
project_settings = get_project_settings(os.getenv("AVALON_PROJECT"))
project_name = get_current_project_name()
project_settings = get_project_settings(project_name)
shelves_set_config = project_settings["houdini"]["shelves"]
if not shelves_set_config:

View file

@ -4,7 +4,6 @@ from openpype.client import (
get_asset_by_name,
get_subsets,
)
from openpype.pipeline import legacy_io
from openpype.hosts.houdini.api import plugin
@ -21,7 +20,7 @@ class CreateHDA(plugin.HoudiniCreator):
# type: (str) -> bool
"""Check if existing subset name versions already exists."""
# Get all subsets of the current asset
project_name = legacy_io.active_project()
project_name = self.project_name
asset_doc = get_asset_by_name(
project_name, self.data["asset"], fields=["_id"]
)

View file

@ -4,7 +4,6 @@ from openpype.hosts.houdini.api import plugin
from openpype.hosts.houdini.api.lib import read, imprint
from openpype.hosts.houdini.api.pipeline import CONTEXT_CONTAINER
from openpype.pipeline import CreatedInstance, AutoCreator
from openpype.pipeline import legacy_io
from openpype.client import get_asset_by_name
import hou
@ -27,9 +26,9 @@ class CreateWorkfile(plugin.HoudiniCreatorBase, AutoCreator):
), None)
project_name = self.project_name
asset_name = legacy_io.Session["AVALON_ASSET"]
task_name = legacy_io.Session["AVALON_TASK"]
host_name = legacy_io.Session["AVALON_APP"]
asset_name = self.create_context.get_current_asset_name()
task_name = self.create_context.get_current_task_name()
host_name = self.host_name
if current_instance is None:
asset_doc = get_asset_by_name(project_name, asset_name)

View file

@ -1,7 +1,6 @@
import pyblish.api
from openpype.client import get_subset_by_name, get_asset_by_name
from openpype.pipeline import legacy_io
import openpype.lib.usdlib as usdlib
@ -51,7 +50,7 @@ class CollectUsdBootstrap(pyblish.api.InstancePlugin):
self.log.debug("Add bootstrap for: %s" % bootstrap)
project_name = legacy_io.active_project()
project_name = instance.context.data["projectName"]
asset = get_asset_by_name(project_name, instance.data["asset"])
assert asset, "Asset must exist: %s" % asset

View file

@ -14,7 +14,6 @@ from openpype.client import (
)
from openpype.pipeline import (
get_representation_path,
legacy_io,
publish,
)
import openpype.hosts.houdini.api.usd as hou_usdlib
@ -250,7 +249,7 @@ class ExtractUSDLayered(publish.Extractor):
# Set up the dependency for publish if they have new content
# compared to previous publishes
project_name = legacy_io.active_project()
project_name = instance.context.data["projectName"]
for dependency in active_dependencies:
dependency_fname = dependency.data["usdFilename"]

View file

@ -4,7 +4,6 @@ import re
import pyblish.api
from openpype.client import get_subset_by_name
from openpype.pipeline import legacy_io
from openpype.pipeline.publish import ValidateContentsOrder
from openpype.pipeline import PublishValidationError
@ -18,7 +17,7 @@ class ValidateUSDShadeModelExists(pyblish.api.InstancePlugin):
label = "USD Shade model exists"
def process(self, instance):
project_name = legacy_io.active_project()
project_name = instance.context.data["projectName"]
asset_name = instance.data["asset"]
subset = instance.data["subset"]

View file

@ -5,7 +5,7 @@ import husdoutputprocessors.base as base
import colorbleed.usdlib as usdlib
from openpype.client import get_asset_by_name
from openpype.pipeline import legacy_io, Anatomy
from openpype.pipeline import Anatomy, get_current_project_name
class AvalonURIOutputProcessor(base.OutputProcessorBase):
@ -122,7 +122,7 @@ class AvalonURIOutputProcessor(base.OutputProcessorBase):
"""
PROJECT = legacy_io.Session["AVALON_PROJECT"]
PROJECT = get_current_project_name()
anatomy = Anatomy(PROJECT)
asset_doc = get_asset_by_name(PROJECT, asset)
if not asset_doc:

View file

@ -7,15 +7,18 @@ import os
from pymxs import runtime as rt
from openpype.hosts.max.api.lib import get_current_renderer
from openpype.pipeline import legacy_io
from openpype.pipeline import get_current_project_name
from openpype.settings import get_project_settings
class RenderProducts(object):
def __init__(self, project_settings=None):
self._project_settings = project_settings or get_project_settings(
legacy_io.Session["AVALON_PROJECT"])
self._project_settings = project_settings
if not self._project_settings:
self._project_settings = get_project_settings(
get_current_project_name()
)
def get_beauty(self, container):
render_dir = os.path.dirname(rt.rendOutputFilename)

View file

@ -2,7 +2,7 @@ import os
from pymxs import runtime as rt
from openpype.lib import Logger
from openpype.settings import get_project_settings
from openpype.pipeline import legacy_io
from openpype.pipeline import get_current_project_name
from openpype.pipeline.context_tools import get_current_project_asset
from openpype.hosts.max.api.lib import (
@ -31,7 +31,7 @@ class RenderSettings(object):
self._project_settings = project_settings
if not self._project_settings:
self._project_settings = get_project_settings(
legacy_io.Session["AVALON_PROJECT"]
get_current_project_name()
)
def set_render_camera(self, selection):

View file

@ -4,7 +4,6 @@ import os
import pyblish.api
from pymxs import runtime as rt
from openpype.pipeline import legacy_io
class CollectWorkfile(pyblish.api.ContextPlugin):
@ -26,7 +25,7 @@ class CollectWorkfile(pyblish.api.ContextPlugin):
filename, ext = os.path.splitext(file)
task = legacy_io.Session["AVALON_TASK"]
task = context.data["task"]
data = {}
@ -36,7 +35,7 @@ class CollectWorkfile(pyblish.api.ContextPlugin):
data.update({
"subset": subset,
"asset": os.getenv("AVALON_ASSET", None),
"asset": context.data["asset"],
"label": subset,
"publish": True,
"family": 'workfile',

View file

@ -1,15 +1,6 @@
import pyblish.api
from openpype.pipeline import PublishValidationError
from pymxs import runtime as rt
from openpype.settings import get_project_settings
from openpype.pipeline import legacy_io
def get_setting(project_setting=None):
project_setting = get_project_settings(
legacy_io.Session["AVALON_PROJECT"]
)
return project_setting["max"]["PointCloud"]
class ValidatePointCloud(pyblish.api.InstancePlugin):
@ -108,6 +99,9 @@ class ValidatePointCloud(pyblish.api.InstancePlugin):
f"Validating tyFlow custom attributes for {container}")
selection_list = instance.data["members"]
project_setting = instance.data["project_setting"]
attr_settings = project_setting["max"]["PointCloud"]["attribute"]
for sel in selection_list:
obj = sel.baseobject
anim_names = rt.GetSubAnimNames(obj)
@ -118,8 +112,7 @@ class ValidatePointCloud(pyblish.api.InstancePlugin):
event_name = sub_anim.name
opt = "${0}.{1}.export_particles".format(sel.name,
event_name)
attributes = get_setting()["attribute"]
for key, value in attributes.items():
for key, value in attr_settings.items():
custom_attr = "{0}.PRTChannels_{1}".format(opt,
value)
try:

View file

@ -4,7 +4,6 @@ from __future__ import absolute_import
import pyblish.api
from openpype.client import get_asset_by_name
from openpype.pipeline import legacy_io
from openpype.pipeline.publish import get_errored_instances_from_context
@ -80,7 +79,7 @@ class GenerateUUIDsOnInvalidAction(pyblish.api.Action):
asset_doc = instance.data.get("assetEntity")
if not asset_doc:
asset_name = instance.data["asset"]
project_name = legacy_io.active_project()
project_name = instance.context.data["projectName"]
self.log.info((
"Asset is not stored on instance."
" Querying by name \"{}\" from project \"{}\""

View file

@ -3,7 +3,7 @@
from maya import cmds
from openpype.client import get_asset_by_name, get_project
from openpype.pipeline import legacy_io
from openpype.pipeline import get_current_project_name, get_current_asset_name
class ToolWindows:
@ -85,8 +85,8 @@ def reset_resolution():
resolution_height = 1080
# Get resolution from asset
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)
resolution = _resolution_from_document(asset_doc)
# Try get resolution from project

View file

@ -25,7 +25,8 @@ from openpype.client import (
)
from openpype.settings import get_project_settings
from openpype.pipeline import (
legacy_io,
get_current_project_name,
get_current_asset_name,
discover_loader_plugins,
loaders_from_representation,
get_representation_path,
@ -1413,8 +1414,8 @@ def generate_ids(nodes, asset_id=None):
if asset_id is None:
# Get the asset ID from the database for the asset of current context
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, fields=["_id"])
assert asset_doc, "No current asset found in Session"
asset_id = asset_doc['_id']
@ -1614,17 +1615,15 @@ def get_container_members(container):
# region LOOKDEV
def list_looks(asset_id):
def list_looks(project_name, asset_id):
"""Return all look subsets for the given asset
This assumes all look subsets start with "look*" in their names.
"""
# # get all subsets with look leading in
# the name associated with the asset
# TODO this should probably look for family 'look' instead of checking
# subset name that can not start with family
project_name = legacy_io.active_project()
subset_docs = get_subsets(project_name, asset_ids=[asset_id])
return [
subset_doc
@ -1646,7 +1645,7 @@ def assign_look_by_version(nodes, version_id):
None
"""
project_name = legacy_io.active_project()
project_name = get_current_project_name()
# Get representations of shader file and relationships
look_representation = get_representation_by_name(
@ -1712,7 +1711,7 @@ def assign_look(nodes, subset="lookDefault"):
parts = pype_id.split(":", 1)
grouped[parts[0]].append(node)
project_name = legacy_io.active_project()
project_name = get_current_project_name()
subset_docs = get_subsets(
project_name, subset_names=[subset], asset_ids=grouped.keys()
)
@ -2226,6 +2225,35 @@ def set_scene_resolution(width, height, pixelAspect):
cmds.setAttr("%s.pixelAspect" % control_node, pixelAspect)
def get_fps_for_current_context():
"""Get fps that should be set for current context.
Todos:
- Skip project value.
- Merge logic with 'get_frame_range' and 'reset_scene_resolution' ->
all the values in the functions can be collected at one place as
they have same requirements.
Returns:
Union[int, float]: FPS value.
"""
project_name = get_current_project_name()
asset_name = get_current_asset_name()
asset_doc = get_asset_by_name(
project_name, asset_name, fields=["data.fps"]
) or {}
fps = asset_doc.get("data", {}).get("fps")
if not fps:
project_doc = get_project(project_name, fields=["data.fps"]) or {}
fps = project_doc.get("data", {}).get("fps")
if not fps:
fps = 25
return convert_to_maya_fps(fps)
def get_frame_range(include_animation_range=False):
"""Get the current assets frame range and handles.
@ -2300,10 +2328,7 @@ def reset_frame_range(playback=True, render=True, fps=True):
fps (bool, Optional): Whether to set scene FPS. Defaults to True.
"""
if fps:
fps = convert_to_maya_fps(
float(legacy_io.Session.get("AVALON_FPS", 25))
)
set_scene_fps(fps)
set_scene_fps(get_fps_for_current_context())
frame_range = get_frame_range(include_animation_range=True)
if not frame_range:
@ -2339,7 +2364,7 @@ def reset_scene_resolution():
None
"""
project_name = legacy_io.active_project()
project_name = get_current_project_name()
project_doc = get_project(project_name)
project_data = project_doc["data"]
asset_data = get_current_project_asset()["data"]
@ -2372,19 +2397,9 @@ def set_context_settings():
None
"""
# Todo (Wijnand): apply renderer and resolution of project
project_name = legacy_io.active_project()
project_doc = get_project(project_name)
project_data = project_doc["data"]
asset_doc = get_current_project_asset(fields=["data.fps"])
asset_data = asset_doc.get("data", {})
# Set project fps
fps = convert_to_maya_fps(
asset_data.get("fps", project_data.get("fps", 25))
)
legacy_io.Session["AVALON_FPS"] = str(fps)
set_scene_fps(fps)
set_scene_fps(get_fps_for_current_context())
reset_scene_resolution()
@ -2404,9 +2419,7 @@ def validate_fps():
"""
expected_fps = convert_to_maya_fps(
get_current_project_asset(fields=["data.fps"])["data"]["fps"]
)
expected_fps = get_fps_for_current_context()
current_fps = mel.eval('currentTimeUnitToFPS()')
fps_match = current_fps == expected_fps

View file

@ -6,13 +6,9 @@ import six
import sys
from openpype.lib import Logger
from openpype.settings import (
get_project_settings,
get_current_project_settings
)
from openpype.settings import get_project_settings
from openpype.pipeline import legacy_io
from openpype.pipeline import CreatorError
from openpype.pipeline import CreatorError, get_current_project_name
from openpype.pipeline.context_tools import get_current_project_asset
from openpype.hosts.maya.api.lib import reset_frame_range
@ -27,21 +23,6 @@ class RenderSettings(object):
'mayahardware2': 'defaultRenderGlobals.imageFilePrefix'
}
_image_prefixes = {
'vray': get_current_project_settings()["maya"]["RenderSettings"]["vray_renderer"]["image_prefix"], # noqa
'arnold': get_current_project_settings()["maya"]["RenderSettings"]["arnold_renderer"]["image_prefix"], # noqa
'renderman': get_current_project_settings()["maya"]["RenderSettings"]["renderman_renderer"]["image_prefix"], # noqa
'redshift': get_current_project_settings()["maya"]["RenderSettings"]["redshift_renderer"]["image_prefix"] # noqa
}
# Renderman only
_image_dir = {
'renderman': get_current_project_settings()["maya"]["RenderSettings"]["renderman_renderer"]["image_dir"], # noqa
'cryptomatte': get_current_project_settings()["maya"]["RenderSettings"]["renderman_renderer"]["cryptomatte_dir"], # noqa
'imageDisplay': get_current_project_settings()["maya"]["RenderSettings"]["renderman_renderer"]["imageDisplay_dir"], # noqa
"watermark": get_current_project_settings()["maya"]["RenderSettings"]["renderman_renderer"]["watermark_dir"] # noqa
}
_aov_chars = {
"dot": ".",
"dash": "-",
@ -55,11 +36,30 @@ class RenderSettings(object):
return cls._image_prefix_nodes[renderer]
def __init__(self, project_settings=None):
self._project_settings = project_settings
if not self._project_settings:
self._project_settings = get_project_settings(
legacy_io.Session["AVALON_PROJECT"]
if not project_settings:
project_settings = get_project_settings(
get_current_project_name()
)
render_settings = project_settings["maya"]["RenderSettings"]
image_prefixes = {
"vray": render_settings["vray_renderer"]["image_prefix"],
"arnold": render_settings["arnold_renderer"]["image_prefix"],
"renderman": render_settings["renderman_renderer"]["image_prefix"],
"redshift": render_settings["redshift_renderer"]["image_prefix"]
}
# TODO probably should be stored to more explicit attribute
# Renderman only
renderman_settings = render_settings["renderman_renderer"]
_image_dir = {
"renderman": renderman_settings["image_dir"],
"cryptomatte": renderman_settings["cryptomatte_dir"],
"imageDisplay": renderman_settings["imageDisplay_dir"],
"watermark": renderman_settings["watermark_dir"]
}
self._image_prefixes = image_prefixes
self._image_dir = _image_dir
self._project_settings = project_settings
def set_default_renderer_settings(self, renderer=None):
"""Set basic settings based on renderer."""

View file

@ -7,7 +7,11 @@ import maya.utils
import maya.cmds as cmds
from openpype.settings import get_project_settings
from openpype.pipeline import legacy_io
from openpype.pipeline import (
get_current_project_name,
get_current_asset_name,
get_current_task_name
)
from openpype.pipeline.workfile import BuildWorkfile
from openpype.tools.utils import host_tools
from openpype.hosts.maya.api import lib, lib_rendersettings
@ -35,6 +39,13 @@ def _get_menu(menu_name=None):
return widgets.get(menu_name)
def get_context_label():
return "{}, {}".format(
get_current_asset_name(),
get_current_task_name()
)
def install():
if cmds.about(batch=True):
log.info("Skipping openpype.menu initialization in batch mode..")
@ -45,19 +56,15 @@ def install():
parent_widget = get_main_window()
cmds.menu(
MENU_NAME,
label=legacy_io.Session["AVALON_LABEL"],
label=os.environ.get("AVALON_LABEL") or "OpenPype",
tearOff=True,
parent="MayaWindow"
)
# Create context menu
context_label = "{}, {}".format(
legacy_io.Session["AVALON_ASSET"],
legacy_io.Session["AVALON_TASK"]
)
cmds.menuItem(
"currentContext",
label=context_label,
label=get_context_label(),
parent=MENU_NAME,
enable=False
)
@ -195,7 +202,8 @@ def install():
return
# load configuration of custom menu
project_settings = get_project_settings(os.getenv("AVALON_PROJECT"))
project_name = get_current_project_name()
project_settings = get_project_settings(project_name)
config = project_settings["maya"]["scriptsmenu"]["definition"]
_menu = project_settings["maya"]["scriptsmenu"]["name"]
@ -252,8 +260,5 @@ def update_menu_task_label():
log.warning("Can't find menuItem: {}".format(object_name))
return
label = "{}, {}".format(
legacy_io.Session["AVALON_ASSET"],
legacy_io.Session["AVALON_TASK"]
)
label = get_context_label()
cmds.menuItem(object_name, edit=True, label=label)

View file

@ -27,6 +27,9 @@ from openpype.lib import (
)
from openpype.pipeline import (
legacy_io,
get_current_project_name,
get_current_asset_name,
get_current_task_name,
register_loader_plugin_path,
register_inventory_action_path,
register_creator_plugin_path,
@ -75,7 +78,7 @@ class MayaHost(HostBase, IWorkfileHost, ILoadHost, IPublishHost):
self._op_events = {}
def install(self):
project_name = legacy_io.active_project()
project_name = get_current_project_name()
project_settings = get_project_settings(project_name)
# process path mapping
dirmap_processor = MayaDirmap("maya", project_name, project_settings)
@ -320,7 +323,7 @@ def _remove_workfile_lock():
def handle_workfile_locks():
if lib.IS_HEADLESS:
return False
project_name = legacy_io.active_project()
project_name = get_current_project_name()
return is_workfile_lock_enabled(MayaHost.name, project_name)
@ -657,9 +660,9 @@ def on_task_changed():
lib.update_content_on_context_change()
msg = " project: {}\n asset: {}\n task:{}".format(
legacy_io.active_project(),
legacy_io.Session["AVALON_ASSET"],
legacy_io.Session["AVALON_TASK"]
get_current_project_name(),
get_current_asset_name(),
get_current_task_name()
)
lib.show_message(
@ -674,7 +677,7 @@ def before_workfile_open():
def before_workfile_save(event):
project_name = legacy_io.active_project()
project_name = get_current_project_name()
if handle_workfile_locks():
_remove_workfile_lock()
workdir_path = event["workdir_path"]

View file

@ -18,13 +18,13 @@ from openpype.client import (
)
from openpype.pipeline import (
schema,
legacy_io,
discover_loader_plugins,
loaders_from_representation,
load_container,
update_container,
remove_container,
get_representation_path,
get_current_project_name,
)
from openpype.hosts.maya.api.lib import (
matrix_equals,
@ -289,7 +289,7 @@ def update_package_version(container, version):
"""
# Versioning (from `core.maya.pipeline`)
project_name = legacy_io.active_project()
project_name = get_current_project_name()
current_representation = get_representation_by_id(
project_name, container["representation"]
)
@ -332,7 +332,7 @@ def update_package(set_container, representation):
"""
# Load the original package data
project_name = legacy_io.active_project()
project_name = get_current_project_name()
current_representation = get_representation_by_id(
project_name, set_container["representation"]
)
@ -380,7 +380,7 @@ def update_scene(set_container, containers, current_data, new_data, new_file):
"""
set_namespace = set_container['namespace']
project_name = legacy_io.active_project()
project_name = get_current_project_name()
# Update the setdress hierarchy alembic
set_root = get_container_transforms(set_container, root=True)

View file

@ -10,10 +10,11 @@ class PreCopyMel(PreLaunchHook):
app_groups = ["maya"]
def execute(self):
project_name = self.launch_context.env.get("AVALON_PROJECT")
project_doc = self.data["project_doc"]
workdir = self.launch_context.env.get("AVALON_WORKDIR")
if not workdir:
self.log.warning("BUG: Workdir is not filled.")
return
create_workspace_mel(workdir, project_name)
project_settings = self.data["project_settings"]
create_workspace_mel(workdir, project_doc["name"], project_settings)

View file

@ -3,7 +3,7 @@ from openpype.settings import get_project_settings
from openpype.lib import Logger
def create_workspace_mel(workdir, project_name):
def create_workspace_mel(workdir, project_name, project_settings=None):
dst_filepath = os.path.join(workdir, "workspace.mel")
if os.path.exists(dst_filepath):
return
@ -11,8 +11,9 @@ def create_workspace_mel(workdir, project_name):
if not os.path.exists(workdir):
os.makedirs(workdir)
project_setting = get_project_settings(project_name)
mel_script = project_setting["maya"].get("mel_workspace")
if not project_settings:
project_settings = get_project_settings(project_name)
mel_script = project_settings["maya"].get("mel_workspace")
# Skip if mel script in settings is empty
if not mel_script:

View file

@ -8,7 +8,7 @@ from openpype.client import (
from openpype.pipeline import (
InventoryAction,
get_representation_context,
legacy_io,
get_current_project_name,
)
from openpype.hosts.maya.api.lib import (
maintained_selection,
@ -35,7 +35,7 @@ class ImportModelRender(InventoryAction):
def process(self, containers):
from maya import cmds
project_name = legacy_io.active_project()
project_name = get_current_project_name()
for container in containers:
con_name = container["objectName"]
nodes = []
@ -68,7 +68,7 @@ class ImportModelRender(InventoryAction):
from maya import cmds
project_name = legacy_io.active_project()
project_name = get_current_project_name()
repre_docs = get_representations(
project_name, version_ids=[version_id], fields=["_id", "name"]
)

View file

@ -6,7 +6,7 @@ from openpype.client import (
get_version_by_id,
)
from openpype.pipeline import (
legacy_io,
get_current_project_name,
load,
get_representation_path,
)
@ -68,7 +68,7 @@ class AudioLoader(load.LoaderPlugin):
)
# Set frame range.
project_name = legacy_io.active_project()
project_name = get_current_project_name()
version = get_version_by_id(
project_name, representation["parent"], fields=["parent"]
)

View file

@ -37,7 +37,8 @@ class GpuCacheLoader(load.LoaderPlugin):
label = "{}:{}".format(namespace, name)
root = cmds.group(name=label, empty=True)
settings = get_project_settings(os.environ['AVALON_PROJECT'])
project_name = context["project"]["name"]
settings = get_project_settings(project_name)
colors = settings['maya']['load']['colors']
c = colors.get('model')
if c is not None:

View file

@ -4,7 +4,8 @@ import copy
from openpype.lib import EnumDef
from openpype.pipeline import (
load,
get_representation_context
get_representation_context,
get_current_host_name,
)
from openpype.pipeline.load.utils import get_representation_path_from_context
from openpype.pipeline.colorspace import (
@ -266,7 +267,7 @@ class FileNodeLoader(load.LoaderPlugin):
# Assume colorspace from filepath based on project settings
project_name = context["project"]["name"]
host_name = os.environ.get("AVALON_APP")
host_name = get_current_host_name()
project_settings = get_project_settings(project_name)
config_data = get_imageio_config(

View file

@ -6,9 +6,9 @@ from openpype.client import (
get_version_by_id,
)
from openpype.pipeline import (
legacy_io,
load,
get_representation_path
get_representation_path,
get_current_project_name,
)
from openpype.hosts.maya.api.pipeline import containerise
from openpype.hosts.maya.api.lib import (
@ -221,7 +221,7 @@ class ImagePlaneLoader(load.LoaderPlugin):
type="string")
# Set frame range.
project_name = legacy_io.active_project()
project_name = get_current_project_name()
version = get_version_by_id(
project_name, representation["parent"], fields=["parent"]
)

View file

@ -7,7 +7,7 @@ from qtpy import QtWidgets
from openpype.client import get_representation_by_name
from openpype.pipeline import (
legacy_io,
get_current_project_name,
get_representation_path,
)
import openpype.hosts.maya.api.plugin
@ -78,7 +78,7 @@ class LookLoader(openpype.hosts.maya.api.plugin.ReferenceLoader):
shader_nodes = cmds.ls(members, type='shadingEngine')
nodes = set(self._get_nodes_with_shader(shader_nodes))
project_name = legacy_io.active_project()
project_name = get_current_project_name()
json_representation = get_representation_by_name(
project_name, "json", representation["parent"]
)

View file

@ -57,7 +57,8 @@ class RedshiftProxyLoader(load.LoaderPlugin):
return
# colour the group node
settings = get_project_settings(os.environ['AVALON_PROJECT'])
project_name = context["project"]["name"]
settings = get_project_settings(project_name)
colors = settings['maya']['load']['colors']
c = colors.get(family)
if c is not None:

View file

@ -118,6 +118,7 @@ class ReferenceLoader(openpype.hosts.maya.api.plugin.ReferenceLoader):
except ValueError:
family = "model"
project_name = context["project"]["name"]
# True by default to keep legacy behaviours
attach_to_root = options.get("attach_to_root", True)
group_name = options["group_name"]
@ -125,9 +126,8 @@ class ReferenceLoader(openpype.hosts.maya.api.plugin.ReferenceLoader):
path = self.filepath_from_context(context)
with maintained_selection():
cmds.loadPlugin("AbcImport.mll", quiet=True)
file_url = self.prepare_root_value(path,
context["project"]["name"])
file_url = self.prepare_root_value(path, project_name)
nodes = cmds.file(file_url,
namespace=namespace,
sharedReferenceFile=False,
@ -163,7 +163,7 @@ class ReferenceLoader(openpype.hosts.maya.api.plugin.ReferenceLoader):
with parent_nodes(roots, parent=None):
cmds.xform(group_name, zeroTransformPivots=True)
settings = get_project_settings(os.environ['AVALON_PROJECT'])
settings = get_project_settings(project_name)
display_handle = settings['maya']['load'].get(
'reference_loader', {}

View file

@ -48,7 +48,8 @@ class LoadVDBtoArnold(load.LoaderPlugin):
label = "{}:{}".format(namespace, name)
root = cmds.group(name=label, empty=True)
settings = get_project_settings(os.environ['AVALON_PROJECT'])
project_name = context["project"]["name"]
settings = get_project_settings(project_name)
colors = settings['maya']['load']['colors']
c = colors.get(family)

View file

@ -67,7 +67,8 @@ class LoadVDBtoRedShift(load.LoaderPlugin):
label = "{}:{}".format(namespace, name)
root = cmds.createNode("transform", name=label)
settings = get_project_settings(os.environ['AVALON_PROJECT'])
project_name = context["project"]["name"]
settings = get_project_settings(project_name)
colors = settings['maya']['load']['colors']
c = colors.get(family)

View file

@ -127,7 +127,8 @@ class LoadVDBtoVRay(load.LoaderPlugin):
label = "{}:{}_VDB".format(namespace, name)
root = cmds.group(name=label, empty=True)
settings = get_project_settings(os.environ['AVALON_PROJECT'])
project_name = context["project"]["name"]
settings = get_project_settings(project_name)
colors = settings['maya']['load']['colors']
c = colors.get(family)

View file

@ -12,9 +12,9 @@ import maya.cmds as cmds
from openpype.client import get_representation_by_name
from openpype.settings import get_project_settings
from openpype.pipeline import (
legacy_io,
load,
get_representation_path
get_current_project_name,
get_representation_path,
)
from openpype.hosts.maya.api.lib import (
maintained_selection,
@ -78,7 +78,8 @@ class VRayProxyLoader(load.LoaderPlugin):
return
# colour the group node
settings = get_project_settings(os.environ['AVALON_PROJECT'])
project_name = context["project"]["name"]
settings = get_project_settings(project_name)
colors = settings['maya']['load']['colors']
c = colors.get(family)
if c is not None:
@ -187,7 +188,7 @@ class VRayProxyLoader(load.LoaderPlugin):
"""
self.log.debug(
"Looking for abc in published representations of this version.")
project_name = legacy_io.active_project()
project_name = get_current_project_name()
abc_rep = get_representation_by_name(project_name, "abc", version_id)
if abc_rep:
self.log.debug("Found, we'll link alembic to vray proxy.")

View file

@ -56,7 +56,8 @@ class VRaySceneLoader(load.LoaderPlugin):
return
# colour the group node
settings = get_project_settings(os.environ['AVALON_PROJECT'])
project_name = context["project"]["name"]
settings = get_project_settings(project_name)
colors = settings['maya']['load']['colors']
c = colors.get(family)
if c is not None:

View file

@ -68,8 +68,9 @@ class YetiCacheLoader(load.LoaderPlugin):
group_name = "{}:{}".format(namespace, name)
group_node = cmds.group(nodes, name=group_name)
project_name = context["project"]["name"]
settings = get_project_settings(os.environ['AVALON_PROJECT'])
settings = get_project_settings(project_name)
colors = settings['maya']['load']['colors']
c = colors.get(family)

View file

@ -6,7 +6,7 @@ from maya import cmds
from maya.api import OpenMaya as om
from openpype.client import get_representation_by_id
from openpype.pipeline import legacy_io, publish
from openpype.pipeline import publish
class ExtractLayout(publish.Extractor):
@ -30,7 +30,7 @@ class ExtractLayout(publish.Extractor):
json_data = []
# TODO representation queries can be refactored to be faster
project_name = legacy_io.active_project()
project_name = instance.context.data["projectName"]
for asset in cmds.sets(str(instance), query=True):
# Find the container

View file

@ -265,6 +265,8 @@ class MayaSubmitMuster(pyblish.api.InstancePlugin):
context = instance.context
workspace = context.data["workspaceDir"]
project_name = context.data["projectName"]
asset_name = context.data["asset"]
filepath = None
@ -371,8 +373,8 @@ class MayaSubmitMuster(pyblish.api.InstancePlugin):
"jobId": -1,
"startOn": 0,
"parentId": -1,
"project": os.environ.get('AVALON_PROJECT') or scene,
"shot": os.environ.get('AVALON_ASSET') or scene,
"project": project_name or scene,
"shot": asset_name or scene,
"camera": instance.data.get("cameras")[0],
"dependMode": 0,
"packetSize": 4,

View file

@ -1,7 +1,7 @@
import os
from openpype.settings import get_project_settings
from openpype.pipeline import install_host
from openpype.pipeline import install_host, get_current_project_name
from openpype.hosts.maya.api import MayaHost
from maya import cmds
@ -12,7 +12,8 @@ install_host(host)
print("Starting OpenPype usersetup...")
project_settings = get_project_settings(os.environ['AVALON_PROJECT'])
project_name = get_current_project_name()
settings = get_project_settings(project_name)
# Loading plugins explicitly.
explicit_plugins_loading = project_settings["maya"]["explicit_plugins_loading"]
@ -46,17 +47,16 @@ if bool(int(os.environ.get(key, "0"))):
)
# Build a shelf.
shelf_preset = project_settings['maya'].get('project_shelf')
shelf_preset = settings['maya'].get('project_shelf')
if shelf_preset:
project = os.environ["AVALON_PROJECT"]
icon_path = os.path.join(os.environ['OPENPYPE_PROJECT_SCRIPTS'],
project, "icons")
icon_path = os.path.join(
os.environ['OPENPYPE_PROJECT_SCRIPTS'],
project_name,
"icons")
icon_path = os.path.abspath(icon_path)
for i in shelf_preset['imports']:
import_string = "from {} import {}".format(project, i)
import_string = "from {} import {}".format(project_name, i)
print(import_string)
exec(import_string)

View file

@ -4,9 +4,9 @@ import logging
from qtpy import QtWidgets, QtCore
from openpype.client import get_last_version_by_subset_id
from openpype import style
from openpype.pipeline import legacy_io
from openpype.client import get_last_version_by_subset_id
from openpype.pipeline import get_current_project_name
from openpype.tools.utils.lib import qt_app_context
from openpype.hosts.maya.api.lib import (
assign_look_by_version,
@ -216,7 +216,7 @@ class MayaLookAssignerWindow(QtWidgets.QWidget):
selection = self.assign_selected.isChecked()
asset_nodes = self.asset_outliner.get_nodes(selection=selection)
project_name = legacy_io.active_project()
project_name = get_current_project_name()
start = time.time()
for i, (asset, item) in enumerate(asset_nodes.items()):

View file

@ -1,14 +1,14 @@
from collections import defaultdict
import logging
import os
import logging
from collections import defaultdict
import maya.cmds as cmds
from openpype.client import get_asset_by_id
from openpype.client import get_assets
from openpype.pipeline import (
legacy_io,
remove_container,
registered_host,
get_current_project_name,
)
from openpype.hosts.maya.api import lib
@ -126,18 +126,24 @@ def create_items_from_nodes(nodes):
log.warning("No id hashes")
return asset_view_items
project_name = legacy_io.active_project()
for _id, id_nodes in id_hashes.items():
asset = get_asset_by_id(project_name, _id, fields=["name"])
project_name = get_current_project_name()
asset_ids = set(id_hashes.keys())
asset_docs = get_assets(project_name, asset_ids, fields=["name"])
asset_docs_by_id = {
str(asset_doc["_id"]): asset_doc
for asset_doc in asset_docs
}
for asset_id, id_nodes in id_hashes.items():
asset_doc = asset_docs_by_id.get(asset_id)
# Skip if asset id is not found
if not asset:
if not asset_doc:
log.warning("Id not found in the database, skipping '%s'." % _id)
log.warning("Nodes: %s" % id_nodes)
continue
# Collect available look subsets for this asset
looks = lib.list_looks(asset["_id"])
looks = lib.list_looks(project_name, asset_doc["_id"])
# Collect namespaces the asset is found in
namespaces = set()
@ -146,8 +152,8 @@ def create_items_from_nodes(nodes):
namespaces.add(namespace)
asset_view_items.append({
"label": asset["name"],
"asset": asset,
"label": asset_doc["name"],
"asset": asset_doc,
"looks": looks,
"namespaces": namespaces
})

View file

@ -6,7 +6,7 @@ import logging
from maya import cmds
from openpype.client import get_last_version_by_subset_name
from openpype.pipeline import legacy_io
from openpype.pipeline import get_current_project_name
import openpype.hosts.maya.lib as maya_lib
from . import lib
from .alembic import get_alembic_ids_cache
@ -76,7 +76,7 @@ def vrayproxy_assign_look(vrayproxy, subset="lookDefault"):
asset_id = node_id.split(":", 1)[0]
node_ids_by_asset_id[asset_id].add(node_id)
project_name = legacy_io.active_project()
project_name = get_current_project_name()
for asset_id, node_ids in node_ids_by_asset_id.items():
# Get latest look version

View file

@ -42,8 +42,10 @@ from openpype.pipeline.template_data import get_template_data_with_names
from openpype.pipeline import (
get_current_project_name,
discover_legacy_creator_plugins,
legacy_io,
Anatomy,
get_current_host_name,
get_current_project_name,
get_current_asset_name,
)
from openpype.pipeline.context_tools import (
get_current_project_asset,
@ -970,7 +972,7 @@ def check_inventory_versions():
if not repre_ids:
return
project_name = legacy_io.active_project()
project_name = get_current_project_name()
# Find representations based on found containers
repre_docs = get_representations(
project_name,
@ -1146,7 +1148,7 @@ def format_anatomy(data):
project_name = anatomy.project_name
asset_name = data["asset"]
task_name = data["task"]
host_name = os.environ["AVALON_APP"]
host_name = get_current_host_name()
context_data = get_template_data_with_names(
project_name, asset_name, task_name, host_name
)
@ -1474,7 +1476,7 @@ def create_write_node_legacy(
if knob["name"] == "file_type":
representation = knob["value"]
host_name = os.environ.get("AVALON_APP")
host_name = get_current_host_name()
try:
data.update({
"app": host_name,
@ -1933,15 +1935,18 @@ class WorkfileSettings(object):
def __init__(self, root_node=None, nodes=None, **kwargs):
project_doc = kwargs.get("project")
if project_doc is None:
project_name = legacy_io.active_project()
project_name = get_current_project_name()
project_doc = get_project(project_name)
else:
project_name = project_doc["name"]
Context._project_doc = project_doc
self._project_name = project_name
self._asset = (
kwargs.get("asset_name")
or legacy_io.Session["AVALON_ASSET"]
or get_current_asset_name()
)
self._asset_entity = get_current_project_asset(self._asset)
self._asset_entity = get_asset_by_name(project_name, self._asset)
self._root_node = root_node or nuke.root()
self._nodes = self.get_nodes(nodes=nodes)
@ -2334,7 +2339,7 @@ Reopening Nuke should synchronize these paths and resolve any discrepancies.
def reset_resolution(self):
"""Set resolution to project resolution."""
log.info("Resetting resolution")
project_name = legacy_io.active_project()
project_name = get_current_project_name()
asset_data = self._asset_entity["data"]
format_data = {
@ -2413,7 +2418,7 @@ Reopening Nuke should synchronize these paths and resolve any discrepancies.
from .utils import set_context_favorites
work_dir = os.getenv("AVALON_WORKDIR")
asset = os.getenv("AVALON_ASSET")
asset = get_current_asset_name()
favorite_items = OrderedDict()
# project
@ -2836,7 +2841,8 @@ def add_scripts_menu():
return
# load configuration of custom menu
project_settings = get_project_settings(os.getenv("AVALON_PROJECT"))
project_name = get_current_project_name()
project_settings = get_project_settings(project_name)
config = project_settings["nuke"]["scriptsmenu"]["definition"]
_menu = project_settings["nuke"]["scriptsmenu"]["name"]
@ -2854,7 +2860,8 @@ def add_scripts_menu():
def add_scripts_gizmo():
# load configuration of custom menu
project_settings = get_project_settings(os.getenv("AVALON_PROJECT"))
project_name = get_current_project_name()
project_settings = get_project_settings(project_name)
platform_name = platform.system().lower()
for gizmo_settings in project_settings["nuke"]["gizmo"]:

View file

@ -20,6 +20,8 @@ from openpype.pipeline import (
register_creator_plugin_path,
register_inventory_action_path,
AVALON_CONTAINER_ID,
get_current_asset_name,
get_current_task_name,
)
from openpype.pipeline.workfile import BuildWorkfile
from openpype.tools.utils import host_tools
@ -211,6 +213,13 @@ def _show_workfiles():
host_tools.show_workfiles(parent=None, on_top=False)
def get_context_label():
return "{0}, {1}".format(
get_current_asset_name(),
get_current_task_name()
)
def _install_menu():
"""Install Avalon menu into Nuke's main menu bar."""
@ -220,9 +229,7 @@ def _install_menu():
menu = menubar.addMenu(MENU_LABEL)
if not ASSIST:
label = "{0}, {1}".format(
os.environ["AVALON_ASSET"], os.environ["AVALON_TASK"]
)
label = get_context_label()
Context.context_label = label
context_action = menu.addCommand(label)
context_action.setEnabled(False)
@ -338,9 +345,7 @@ def change_context_label():
menubar = nuke.menu("Nuke")
menu = menubar.findItem(MENU_LABEL)
label = "{0}, {1}".format(
os.environ["AVALON_ASSET"], os.environ["AVALON_TASK"]
)
label = get_context_label()
rm_item = [
(i, item) for i, item in enumerate(menu.items())

View file

@ -19,7 +19,7 @@ from openpype.pipeline import (
CreatorError,
Creator as NewCreator,
CreatedInstance,
legacy_io
get_current_task_name
)
from .lib import (
INSTANCE_DATA_KNOB,
@ -1173,7 +1173,7 @@ def convert_to_valid_instaces():
from openpype.hosts.nuke.api import workio
task_name = legacy_io.Session["AVALON_TASK"]
task_name = get_current_task_name()
# save into new workfile
current_file = workio.current_file()

View file

@ -3,7 +3,6 @@ from openpype.client import get_asset_by_name
from openpype.pipeline import (
AutoCreator,
CreatedInstance,
legacy_io,
)
from openpype.hosts.nuke.api import (
INSTANCE_DATA_KNOB,
@ -27,10 +26,10 @@ class WorkfileCreator(AutoCreator):
root_node, api.INSTANCE_DATA_KNOB
)
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"]
project_name = self.create_context.get_current_project_name()
asset_name = self.create_context.get_current_asset_name()
task_name = self.create_context.get_current_task_name()
host_name = self.create_context.host_name
asset_doc = get_asset_by_name(project_name, asset_name)
subset_name = self.get_subset_name(

View file

@ -6,8 +6,8 @@ from openpype.client import (
get_last_version_by_subset_id,
)
from openpype.pipeline import (
legacy_io,
load,
get_current_project_name,
get_representation_path,
)
from openpype.hosts.nuke.api.lib import (
@ -190,7 +190,7 @@ class LoadBackdropNodes(load.LoaderPlugin):
# get main variables
# Get version from io
project_name = legacy_io.active_project()
project_name = get_current_project_name()
version_doc = get_version_by_id(project_name, representation["parent"])
# get corresponding node

View file

@ -5,8 +5,8 @@ from openpype.client import (
get_last_version_by_subset_id
)
from openpype.pipeline import (
legacy_io,
load,
get_current_project_name,
get_representation_path,
)
from openpype.hosts.nuke.api import (
@ -108,7 +108,7 @@ class AlembicCameraLoader(load.LoaderPlugin):
None
"""
# Get version from io
project_name = legacy_io.active_project()
project_name = get_current_project_name()
version_doc = get_version_by_id(project_name, representation["parent"])
object_name = container['objectName']
@ -180,7 +180,7 @@ class AlembicCameraLoader(load.LoaderPlugin):
""" Coloring a node by correct color by actual version
"""
# get all versions in list
project_name = legacy_io.active_project()
project_name = get_current_project_name()
last_version_doc = get_last_version_by_subset_id(
project_name, version_doc["parent"], fields=["_id"]
)

View file

@ -8,7 +8,7 @@ from openpype.client import (
get_last_version_by_subset_id,
)
from openpype.pipeline import (
legacy_io,
get_current_project_name,
get_representation_path,
)
from openpype.hosts.nuke.api.lib import (
@ -270,7 +270,7 @@ class LoadClip(plugin.NukeLoader):
if "addRetime" in key
]
project_name = legacy_io.active_project()
project_name = get_current_project_name()
version_doc = get_version_by_id(project_name, representation["parent"])
version_data = version_doc.get("data", {})

View file

@ -8,8 +8,8 @@ from openpype.client import (
get_last_version_by_subset_id,
)
from openpype.pipeline import (
legacy_io,
load,
get_current_project_name,
get_representation_path,
)
from openpype.hosts.nuke.api import (
@ -155,7 +155,7 @@ class LoadEffects(load.LoaderPlugin):
"""
# get main variables
# Get version from io
project_name = legacy_io.active_project()
project_name = get_current_project_name()
version_doc = get_version_by_id(project_name, representation["parent"])
# get corresponding node

View file

@ -8,8 +8,8 @@ from openpype.client import (
get_last_version_by_subset_id,
)
from openpype.pipeline import (
legacy_io,
load,
get_current_project_name,
get_representation_path,
)
from openpype.hosts.nuke.api import lib
@ -160,7 +160,7 @@ class LoadEffectsInputProcess(load.LoaderPlugin):
# get main variables
# Get version from io
project_name = legacy_io.active_project()
project_name = get_current_project_name()
version_doc = get_version_by_id(project_name, representation["parent"])
# get corresponding node

View file

@ -5,8 +5,8 @@ from openpype.client import (
get_last_version_by_subset_id,
)
from openpype.pipeline import (
legacy_io,
load,
get_current_project_name,
get_representation_path,
)
from openpype.hosts.nuke.api.lib import (
@ -106,7 +106,7 @@ class LoadGizmo(load.LoaderPlugin):
# get main variables
# Get version from io
project_name = legacy_io.active_project()
project_name = get_current_project_name()
version_doc = get_version_by_id(project_name, representation["parent"])
# get corresponding node

View file

@ -6,8 +6,8 @@ from openpype.client import (
get_last_version_by_subset_id,
)
from openpype.pipeline import (
legacy_io,
load,
get_current_project_name,
get_representation_path,
)
from openpype.hosts.nuke.api.lib import (
@ -113,7 +113,7 @@ class LoadGizmoInputProcess(load.LoaderPlugin):
# get main variables
# Get version from io
project_name = legacy_io.active_project()
project_name = get_current_project_name()
version_doc = get_version_by_id(project_name, representation["parent"])
# get corresponding node

View file

@ -7,8 +7,8 @@ from openpype.client import (
get_last_version_by_subset_id,
)
from openpype.pipeline import (
legacy_io,
load,
get_current_project_name,
get_representation_path,
)
from openpype.hosts.nuke.api.lib import (
@ -201,7 +201,7 @@ class LoadImage(load.LoaderPlugin):
format(frame_number, "0{}".format(padding)))
# Get start frame from version data
project_name = legacy_io.active_project()
project_name = get_current_project_name()
version_doc = get_version_by_id(project_name, representation["parent"])
last_version_doc = get_last_version_by_subset_id(
project_name, version_doc["parent"], fields=["_id"]

View file

@ -5,8 +5,8 @@ from openpype.client import (
get_last_version_by_subset_id,
)
from openpype.pipeline import (
legacy_io,
load,
get_current_project_name,
get_representation_path,
)
from openpype.hosts.nuke.api.lib import maintained_selection
@ -112,7 +112,7 @@ class AlembicModelLoader(load.LoaderPlugin):
None
"""
# Get version from io
project_name = legacy_io.active_project()
project_name = get_current_project_name()
version_doc = get_version_by_id(project_name, representation["parent"])
object_name = container['objectName']
# get corresponding node
@ -187,7 +187,7 @@ class AlembicModelLoader(load.LoaderPlugin):
def node_version_color(self, version, node):
""" Coloring a node by correct color by actual version"""
project_name = legacy_io.active_project()
project_name = get_current_project_name()
last_version_doc = get_last_version_by_subset_id(
project_name, version["parent"], fields=["_id"]
)

View file

@ -5,7 +5,7 @@ from openpype.client import (
get_last_version_by_subset_id,
)
from openpype.pipeline import (
legacy_io,
get_current_project_name,
load,
get_representation_path,
)
@ -123,7 +123,7 @@ class LinkAsGroup(load.LoaderPlugin):
root = get_representation_path(representation).replace("\\", "/")
# Get start frame from version data
project_name = legacy_io.active_project()
project_name = get_current_project_name()
version_doc = get_version_by_id(project_name, representation["parent"])
last_version_doc = get_last_version_by_subset_id(
project_name, version_doc["parent"], fields=["_id"]

View file

@ -2,8 +2,6 @@ import os
import re
import nuke
import pyblish.api
from openpype.client import get_asset_by_name
from openpype.pipeline import legacy_io
class CollectNukeReads(pyblish.api.InstancePlugin):
@ -15,16 +13,9 @@ class CollectNukeReads(pyblish.api.InstancePlugin):
families = ["source"]
def process(self, instance):
node = instance.data["transientData"]["node"]
project_name = legacy_io.active_project()
asset_name = legacy_io.Session["AVALON_ASSET"]
asset_doc = get_asset_by_name(project_name, asset_name)
self.log.debug("asset_doc: {}".format(asset_doc["data"]))
self.log.debug("checking instance: {}".format(instance))
node = instance.data["transientData"]["node"]
if node.Class() != "Read":
return

View file

@ -6,11 +6,8 @@ import pyblish.api
from openpype.lib import register_event_callback, Logger
from openpype.pipeline import (
legacy_io,
register_loader_plugin_path,
register_creator_plugin_path,
deregister_loader_plugin_path,
deregister_creator_plugin_path,
AVALON_CONTAINER_ID,
)
@ -111,14 +108,6 @@ class PhotoshopHost(HostBase, IWorkfileHost, ILoadHost, IPublishHost):
item["id"] = "publish_context"
_get_stub().imprint(item["id"], item)
def get_context_title(self):
"""Returns title for Creator window"""
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)
def list_instances(self):
"""List all created instances to publish from current workfile.

View file

@ -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,
@ -28,10 +28,10 @@ class ValidateInstanceAssetRepair(pyblish.api.Action):
# Apply pyblish.logic to get the instances for the plug-in
instances = pyblish.api.instances_by_plugin(failed, plugin)
stub = photoshop.stub()
current_asset_name = get_current_asset_name()
for instance in instances:
data = stub.read(instance[0])
data["asset"] = legacy_io.Session["AVALON_ASSET"]
data["asset"] = current_asset_name
stub.imprint(instance[0], data)
@ -55,7 +55,7 @@ class ValidateInstanceAsset(OptionalPyblishPluginMixin,
def process(self, instance):
instance_asset = instance.data["asset"]
current_asset = legacy_io.Session["AVALON_ASSET"]
current_asset = get_current_asset_name()
if instance_asset != current_asset:
msg = (

View file

@ -7,7 +7,7 @@ from openpype.client import (
# from openpype.hosts import resolve
from openpype.pipeline import (
get_representation_path,
legacy_io,
get_current_project_name,
)
from openpype.hosts.resolve.api import lib, plugin
from openpype.hosts.resolve.api.pipeline import (
@ -110,7 +110,7 @@ class LoadClip(plugin.TimelineItemLoader):
namespace = container['namespace']
timeline_item_data = lib.get_pype_timeline_item_by_name(namespace)
timeline_item = timeline_item_data["clip"]["item"]
project_name = legacy_io.active_project()
project_name = get_current_project_name()
version = get_version_by_id(project_name, representation["parent"])
version_data = version.get("data", {})
version_name = version.get("name", None)
@ -153,7 +153,7 @@ class LoadClip(plugin.TimelineItemLoader):
# define version name
version_name = version.get("name", None)
# get all versions in list
project_name = legacy_io.active_project()
project_name = get_current_project_name()
last_version_doc = get_last_version_by_subset_id(
project_name,
version["parent"],

View file

@ -1,8 +1,8 @@
import pyblish.api
from pprint import pformat
from openpype.pipeline import get_current_asset_name
from openpype.hosts.resolve import api as rapi
from openpype.pipeline import legacy_io
from openpype.hosts.resolve.otio import davinci_export
@ -14,7 +14,7 @@ class PrecollectWorkfile(pyblish.api.ContextPlugin):
def process(self, context):
asset = legacy_io.Session["AVALON_ASSET"]
asset = get_current_asset_name()
subset = "workfile"
project = rapi.get_current_project()
fps = project.GetSetting("timelineFrameRate")

View file

@ -1,7 +1,5 @@
import os
import pyblish.api
from openpype.settings import get_project_settings
from openpype.pipeline.publish import (
ValidateContentsOrder,
PublishXmlValidationError,
@ -21,27 +19,30 @@ class ValidateTextureBatchWorkfiles(pyblish.api.InstancePlugin):
optional = True
def process(self, instance):
if instance.data["family"] == "workfile":
ext = instance.data["representations"][0]["ext"]
main_workfile_extensions = self.get_main_workfile_extensions()
if ext not in main_workfile_extensions:
self.log.warning("Only secondary workfile present!")
return
if instance.data["family"] != "workfile":
return
if not instance.data.get("resources"):
msg = "No secondary workfile present for workfile '{}'". \
format(instance.data["name"])
ext = main_workfile_extensions[0]
formatting_data = {"file_name": instance.data["name"],
"extension": ext}
ext = instance.data["representations"][0]["ext"]
main_workfile_extensions = self.get_main_workfile_extensions(
instance
)
if ext not in main_workfile_extensions:
self.log.warning("Only secondary workfile present!")
return
raise PublishXmlValidationError(self, msg,
formatting_data=formatting_data
)
if not instance.data.get("resources"):
msg = "No secondary workfile present for workfile '{}'". \
format(instance.data["name"])
ext = main_workfile_extensions[0]
formatting_data = {"file_name": instance.data["name"],
"extension": ext}
raise PublishXmlValidationError(
self, msg, formatting_data=formatting_data)
@staticmethod
def get_main_workfile_extensions():
project_settings = get_project_settings(os.environ["AVALON_PROJECT"])
def get_main_workfile_extensions(instance):
project_settings = instance.context.data["project_settings"]
try:
extensions = (project_settings["standalonepublisher"]

View file

@ -3,7 +3,7 @@ import os
from openpype.lib import StringTemplate
from openpype.pipeline import (
registered_host,
legacy_io,
get_current_context,
Anatomy,
)
from openpype.pipeline.workfile import (
@ -55,9 +55,10 @@ class LoadWorkfile(plugin.Loader):
task_name = work_context.get("task")
# Far cases when there is workfile without work_context
if not asset_name:
project_name = legacy_io.active_project()
asset_name = legacy_io.Session["AVALON_ASSET"]
task_name = legacy_io.Session["AVALON_TASK"]
context = get_current_context()
project_name = context["project_name"]
asset_name = context["asset_name"]
task_name = context["task_name"]
template_key = get_workfile_template_key_from_context(
asset_name,

View file

@ -12,7 +12,7 @@ from unreal import (
from openpype.client import get_asset_by_name
from openpype.pipeline import (
AYON_CONTAINER_ID,
legacy_io,
get_current_project_name,
)
from openpype.hosts.unreal.api import plugin
from openpype.hosts.unreal.api.pipeline import (
@ -184,7 +184,7 @@ class CameraLoader(plugin.Loader):
frame_ranges[i + 1][0], frame_ranges[i + 1][1],
[level])
project_name = legacy_io.active_project()
project_name = get_current_project_name()
data = get_asset_by_name(project_name, asset)["data"]
cam_seq.set_display_rate(
unreal.FrameRate(data.get("fps"), 1.0))
@ -390,7 +390,7 @@ class CameraLoader(plugin.Loader):
# Set range of all sections
# Changing the range of the section is not enough. We need to change
# the frame of all the keys in the section.
project_name = legacy_io.active_project()
project_name = get_current_project_name()
asset = container.get('asset')
data = get_asset_by_name(project_name, asset)["data"]

Some files were not shown because too many files have changed in this diff Show more