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

TVPaint: Use client query functions #3340

Merged
merged 2 commits into from
Jun 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions openpype/hosts/tvpaint/api/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import pyblish.api

from openpype.client import get_project, get_asset_by_name
from openpype.hosts import tvpaint
from openpype.api import get_current_project_settings
from openpype.lib import register_event_callback
Expand Down Expand Up @@ -442,14 +443,14 @@ def set_context_settings(asset_doc=None):

Change fps, resolution and frame start/end.
"""

project_name = legacy_io.active_project()
if asset_doc is None:
asset_name = legacy_io.Session["AVALON_ASSET"]
# Use current session asset if not passed
asset_doc = legacy_io.find_one({
"type": "asset",
"name": legacy_io.Session["AVALON_ASSET"]
})
asset_doc = get_asset_by_name(project_name, asset_name)

project_doc = legacy_io.find_one({"type": "project"})
project_doc = get_project(project_name)

framerate = asset_doc["data"].get("fps")
if framerate is None:
Expand Down
13 changes: 5 additions & 8 deletions openpype/hosts/tvpaint/plugins/load/load_workfile.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import os

from openpype.client import get_project, get_asset_by_name
from openpype.lib import (
StringTemplate,
get_workfile_template_key_from_context,
Expand Down Expand Up @@ -44,21 +45,17 @@ def load(self, context, name, namespace, options):

# Save workfile.
host_name = "tvpaint"
project_name = context.get("project")
asset_name = context.get("asset")
task_name = context.get("task")
# Far cases when there is workfile without 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"]

project_doc = legacy_io.find_one({
"type": "project"
})
asset_doc = legacy_io.find_one({
"type": "asset",
"name": asset_name
})
project_name = project_doc["name"]
project_doc = get_project(project_name)
asset_doc = get_asset_by_name(project_name, asset_name)

template_key = get_workfile_template_key_from_context(
asset_name,
Expand Down
11 changes: 5 additions & 6 deletions openpype/hosts/tvpaint/plugins/publish/collect_instances.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import copy
import pyblish.api

from openpype.client import get_asset_by_name
from openpype.lib import get_subset_name_with_asset_doc
from openpype.pipeline import legacy_io

Expand Down Expand Up @@ -92,17 +93,15 @@ def process(self, context):
if family == "review":
# Change subset name of review instance

# Project name from workfile context
project_name = context.data["workfile_context"]["project"]

# Collect asset doc to get asset id
# - not sure if it's good idea to require asset id in
# get_subset_name?
asset_name = context.data["workfile_context"]["asset"]
asset_doc = legacy_io.find_one({
"type": "asset",
"name": asset_name
})
asset_doc = get_asset_by_name(project_name, asset_name)

# Project name from workfile context
project_name = context.data["workfile_context"]["project"]
# Host name from environment variable
host_name = context.data["hostName"]
# Use empty variant value
Expand Down
11 changes: 4 additions & 7 deletions openpype/hosts/tvpaint/plugins/publish/collect_scene_render.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
import copy
import pyblish.api

from openpype.client import get_asset_by_name
from openpype.lib import get_subset_name_with_asset_doc
from openpype.pipeline import legacy_io


class CollectRenderScene(pyblish.api.ContextPlugin):
Expand Down Expand Up @@ -56,14 +56,11 @@ def process(self, context):
# - not sure if it's good idea to require asset id in
# get_subset_name?
workfile_context = context.data["workfile_context"]
asset_name = workfile_context["asset"]
asset_doc = legacy_io.find_one({
"type": "asset",
"name": asset_name
})

# Project name from workfile context
project_name = context.data["workfile_context"]["project"]
asset_name = workfile_context["asset"]
asset_doc = get_asset_by_name(project_name, asset_name)

# Host name from environment variable
host_name = context.data["hostName"]
# Variant is using render pass name
Expand Down
11 changes: 5 additions & 6 deletions openpype/hosts/tvpaint/plugins/publish/collect_workfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import json
import pyblish.api

from openpype.client import get_asset_by_name
from openpype.lib import get_subset_name_with_asset_doc
from openpype.pipeline import legacy_io

Expand All @@ -22,19 +23,17 @@ def process(self, context):
basename, ext = os.path.splitext(filename)
instance = context.create_instance(name=basename)

# Project name from workfile context
project_name = context.data["workfile_context"]["project"]

# Get subset name of workfile instance
# Collect asset doc to get asset id
# - not sure if it's good idea to require asset id in
# get_subset_name?
family = "workfile"
asset_name = context.data["workfile_context"]["asset"]
asset_doc = legacy_io.find_one({
"type": "asset",
"name": asset_name
})
asset_doc = get_asset_by_name(project_name, asset_name)

# Project name from workfile context
project_name = context.data["workfile_context"]["project"]
# Host name from environment variable
host_name = os.environ["AVALON_APP"]
# Use empty variant value
Expand Down