Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

removed normal usd publishes from having to publish pinning files #76

Draft
wants to merge 1 commit into
base: develop
Choose a base branch
from
Draft
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
10 changes: 5 additions & 5 deletions client/ayon_usd/hooks/usd_pinning_root.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Pre-launch hook to set USD pinning related environment variable."""

from ayon_applications import LaunchTypes, PreLaunchHook


Expand All @@ -21,8 +22,7 @@ def execute(self) -> None:
self.launch_context.env.get("PINNING_FILE_PATH"),
)

roots = anatomy.roots()
self.launch_context.env[
"PROJECT_ROOTS"
] = ",".join(f"{key}={value}"
for key, value in roots.items())
roots = anatomy.roots
self.launch_context.env["PROJECT_ROOTS"] = ",".join(
f"{key}={value}" for key, value in roots.items()
)
11 changes: 6 additions & 5 deletions client/ayon_usd/plugins/publish/extract_skeleton_pinning_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
to check if the processed data is up-to-date.

"""

import json
from datetime import datetime
from pathlib import Path
Expand All @@ -23,8 +24,9 @@
from ayon_core.pipeline import OptionalPyblishPluginMixin, KnownPublishError


class ExtractSkeletonPinningJSON(pyblish.api.InstancePlugin,
OptionalPyblishPluginMixin):
class ExtractSkeletonPinningJSON(
pyblish.api.InstancePlugin, OptionalPyblishPluginMixin
):
"""Extract Skeleton Pinning JSON file.

Extracted JSON file doesn't contain any data, it's just a placeholder
Expand All @@ -33,13 +35,12 @@ class ExtractSkeletonPinningJSON(pyblish.api.InstancePlugin,

label = "Extract Skeleton Pinning JSON"
order = pyblish.api.ExtractorOrder + 0.49
families: ClassVar = ["usd", "usdrender"]
families: ClassVar = ["usdrender"]

@staticmethod
def _has_usd_representation(representations: list) -> bool:
return any(
representation.get("name") == "usd"
for representation in representations
representation.get("name") == "usd" for representation in representations
)

def process(self, instance: pyblish.api.Instance) -> None:
Expand Down
24 changes: 11 additions & 13 deletions client/ayon_usd/plugins/publish/integrate_pinning_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

This is WIP and will be refactored in the future.
"""

from __future__ import annotations

from pathlib import Path
Expand All @@ -18,7 +19,7 @@ class IntegrateUsdPinningFile(pyblish.api.InstancePlugin):

order = pyblish.api.IntegratorOrder + 0.01
label = "Integrate data into USD pinning file"
families = ["usd", "usdrender"]
families = ["usdrender"]

def process(self, instance: pyblish.api.Instance) -> None:
"""Process the plugin."""
Expand All @@ -28,8 +29,7 @@ def process(self, instance: pyblish.api.Instance) -> None:

# get pinning json file
if "usdrender" in instance.data.get("families", []):
self.log.debug(
"Extracting USD pinning file for usdrender family.")
self.log.debug("Extracting USD pinning file for usdrender family.")
usd_file_path = self.save_usd(instance)
for rep in instance.data["representations"]:
if rep["name"] == "usd_pinning":
Expand All @@ -43,7 +43,8 @@ def process(self, instance: pyblish.api.Instance) -> None:
ayon_api.get_representation_by_name(
get_current_project_name(),
representation_name="usd_pinning",
version_id=instance.data["versionEntity"]["id"])
version_id=instance.data["versionEntity"]["id"],
)

published_repres = instance.data.get("published_representations")
usd_file_rootless_path = None
Expand All @@ -67,10 +68,8 @@ def process(self, instance: pyblish.api.Instance) -> None:
return

# get the full path of the usd file
usd_file_path = Path(
anatomy.fill_root(usd_file_rootless_path))
usd_pinning_path = Path(
anatomy.fill_root(usd_pinning_rootless_file_path))
usd_file_path = Path(anatomy.fill_root(usd_file_rootless_path))
usd_pinning_path = Path(anatomy.fill_root(usd_pinning_rootless_file_path))

if not usd_pinning_path:
self.log.error("No USD pinning file found.")
Expand All @@ -79,7 +78,8 @@ def process(self, instance: pyblish.api.Instance) -> None:
generate_pinning_file(
usd_file_path.as_posix(),
ayon_api.get_project_roots_by_site_id(get_current_project_name()),
usd_pinning_path.as_posix())
usd_pinning_path.as_posix(),
)

# clean temporary usd file
if "usdrender" in instance.data.get("families", []):
Expand All @@ -98,8 +98,7 @@ def save_usd(self, instance: pyblish.api.Instance) -> Path:
"""
if get_current_host_name() == "houdini":
return self._save_usd_from_houdini(instance)
raise NotImplementedError(
f"Unsupported host {get_current_host_name()}")
raise NotImplementedError(f"Unsupported host {get_current_host_name()}")

def _save_usd_from_houdini(self, instance: pyblish.api.Instance) -> Path:
"""Save USD file from Houdini.
Expand All @@ -125,8 +124,7 @@ def _save_usd_from_houdini(self, instance: pyblish.api.Instance) -> Path:
# create temp usdrop node
with maintained_selection():
temp_usd_node = hou.node("/out").createNode("usd")
temp_usd_node.parm("lopoutput").set(
filepath.as_posix())
temp_usd_node.parm("lopoutput").set(filepath.as_posix())
temp_usd_node.parm("loppath").set(ropnode.parm("loppath").eval())
temp_usd_node.render()
temp_usd_node.destroy()
Expand Down