mirror of
https://github.com/ynput/ayon-core.git
synced 2026-01-01 16:34:53 +01:00
use query functions in publish plugins
This commit is contained in:
parent
2ce3200fa5
commit
796f32bccd
2 changed files with 25 additions and 13 deletions
|
|
@ -3,6 +3,7 @@ import re
|
||||||
import nuke
|
import nuke
|
||||||
import pyblish.api
|
import pyblish.api
|
||||||
|
|
||||||
|
from openpype.client import get_asset_by_name
|
||||||
from openpype.pipeline import legacy_io
|
from openpype.pipeline import legacy_io
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -16,12 +17,11 @@ class CollectNukeReads(pyblish.api.InstancePlugin):
|
||||||
families = ["source"]
|
families = ["source"]
|
||||||
|
|
||||||
def process(self, instance):
|
def process(self, instance):
|
||||||
asset_data = legacy_io.find_one({
|
project_name = legacy_io.active_project()
|
||||||
"type": "asset",
|
asset_name = legacy_io.Session["AVALON_ASSET"]
|
||||||
"name": legacy_io.Session["AVALON_ASSET"]
|
asset_doc = get_asset_by_name(project_name, asset_name)
|
||||||
})
|
|
||||||
|
|
||||||
self.log.debug("asset_data: {}".format(asset_data["data"]))
|
self.log.debug("asset_doc: {}".format(asset_doc["data"]))
|
||||||
|
|
||||||
self.log.debug("checking instance: {}".format(instance))
|
self.log.debug("checking instance: {}".format(instance))
|
||||||
|
|
||||||
|
|
@ -127,7 +127,7 @@ class CollectNukeReads(pyblish.api.InstancePlugin):
|
||||||
"frameStart": first_frame,
|
"frameStart": first_frame,
|
||||||
"frameEnd": last_frame,
|
"frameEnd": last_frame,
|
||||||
"colorspace": colorspace,
|
"colorspace": colorspace,
|
||||||
"handles": int(asset_data["data"].get("handles", 0)),
|
"handles": int(asset_doc["data"].get("handles", 0)),
|
||||||
"step": 1,
|
"step": 1,
|
||||||
"fps": int(nuke.root()['fps'].value())
|
"fps": int(nuke.root()['fps'].value())
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,10 @@ from pprint import pformat
|
||||||
import nuke
|
import nuke
|
||||||
import pyblish.api
|
import pyblish.api
|
||||||
|
|
||||||
import openpype.api as pype
|
from openpype.client import (
|
||||||
|
get_last_version_by_subset_name,
|
||||||
|
get_representations,
|
||||||
|
)
|
||||||
from openpype.pipeline import (
|
from openpype.pipeline import (
|
||||||
legacy_io,
|
legacy_io,
|
||||||
get_representation_path,
|
get_representation_path,
|
||||||
|
|
@ -180,17 +183,26 @@ class CollectNukeWrites(pyblish.api.InstancePlugin):
|
||||||
if not instance.data["review"]:
|
if not instance.data["review"]:
|
||||||
instance.data["useSequenceForReview"] = False
|
instance.data["useSequenceForReview"] = False
|
||||||
|
|
||||||
|
project_name = legacy_io.active_project()
|
||||||
|
asset_name = instance.data["asset"]
|
||||||
# * Add audio to instance if exists.
|
# * Add audio to instance if exists.
|
||||||
# Find latest versions document
|
# Find latest versions document
|
||||||
version_doc = pype.get_latest_version(
|
last_version_doc = get_last_version_by_subset_name(
|
||||||
instance.data["asset"], "audioMain"
|
project_name, "audioMain", asset_name=asset_name, fields=["_id"]
|
||||||
)
|
)
|
||||||
|
|
||||||
repre_doc = None
|
repre_doc = None
|
||||||
if version_doc:
|
if last_version_doc:
|
||||||
# Try to find it's representation (Expected there is only one)
|
# Try to find it's representation (Expected there is only one)
|
||||||
repre_doc = legacy_io.find_one(
|
repre_docs = list(get_representations(
|
||||||
{"type": "representation", "parent": version_doc["_id"]}
|
project_name, version_ids=[last_version_doc["_id"]]
|
||||||
|
))
|
||||||
|
if not repre_docs:
|
||||||
|
self.log.warning(
|
||||||
|
"Version document does not contain any representations"
|
||||||
)
|
)
|
||||||
|
else:
|
||||||
|
repre_doc = repre_docs[0]
|
||||||
|
|
||||||
# Add audio to instance if representation was found
|
# Add audio to instance if representation was found
|
||||||
if repre_doc:
|
if repre_doc:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue