Skip to content

Commit

Permalink
Merge pull request #913 from ynput/bugfix/AY-2275_sync-dependent-repr…
Browse files Browse the repository at this point in the history
…esentations-when-loading-maya-file

Fix: download referenced representations when synchronizing workfile via SiteSync addon
  • Loading branch information
kalisp authored Sep 25, 2024
2 parents af0159a + efb69dd commit 3685a5e
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 12 deletions.
25 changes: 23 additions & 2 deletions client/ayon_core/plugins/publish/integrate_inputlinks.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,14 @@


class IntegrateInputLinksAYON(pyblish.api.ContextPlugin):
"""Connecting version level dependency links"""
"""Connecting version level dependency links
Handles links:
- generative - what gets produced from workfile
- reference - what was loaded into workfile
It expects workfile instance is being published.
"""

order = pyblish.api.IntegratorOrder + 0.2
label = "Connect Dependency InputLinks AYON"
Expand Down Expand Up @@ -47,6 +54,11 @@ def process(self, context):
self.create_links_on_server(context, new_links_by_type)

def split_instances(self, context):
"""Separates published instances into workfile and other
Returns:
(tuple(pyblish.plugin.Instance), list(pyblish.plugin.Instance))
"""
workfile_instance = None
other_instances = []

Expand Down Expand Up @@ -83,6 +95,15 @@ def add_link(self, new_links_by_type, link_type, input_id, output_id):
def create_workfile_links(
self, workfile_instance, other_instances, new_links_by_type
):
"""Adds links (generative and reference) for workfile.
Args:
workfile_instance (pyblish.plugin.Instance): published workfile
other_instances (list[pyblish.plugin.Instance]): other published
instances
new_links_by_type (dict[str, list[str]]): dictionary collecting new
created links by its type
"""
if workfile_instance is None:
self.log.warn("No workfile in this publish session.")
return
Expand All @@ -97,7 +118,7 @@ def create_workfile_links(
instance.data["versionEntity"]["id"],
)

loaded_versions = workfile_instance.context.get("loadedVersions")
loaded_versions = workfile_instance.context.data.get("loadedVersions")
if not loaded_versions:
return

Expand Down
21 changes: 11 additions & 10 deletions client/ayon_core/tools/loader/models/sitesync.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import collections

from ayon_api import get_representations, get_versions_links
from ayon_api import (
get_representations,
get_versions_links,
)

from ayon_core.lib import Logger, NestedCacheItem
from ayon_core.addon import AddonsManager
Expand Down Expand Up @@ -509,18 +512,19 @@ def _add_site(self, project_name, repre_entity, site_name, product_type):
"reference"
)
for link_repre_id in links:
try:
if not self._sitesync_addon.is_representation_on_site(
project_name,
link_repre_id,
site_name
):
print("Adding {} to linked representation: {}".format(
site_name, link_repre_id))
self._sitesync_addon.add_site(
project_name,
link_repre_id,
site_name,
force=False
force=True
)
except Exception:
# do not add/reset working site for references
log.debug("Site present", exc_info=True)

def _get_linked_representation_id(
self,
Expand Down Expand Up @@ -575,7 +579,7 @@ def _get_linked_representation_id(
project_name,
versions_to_check,
link_types=link_types,
link_direction="out")
link_direction="in") # looking for 'in'puts for version

versions_to_check = set()
for links in versions_links.values():
Expand All @@ -584,9 +588,6 @@ def _get_linked_representation_id(
if link["entityType"] != "version":
continue
entity_id = link["entityId"]
# Skip already found linked version ids
if entity_id in linked_version_ids:
continue
linked_version_ids.add(entity_id)
versions_to_check.add(entity_id)

Expand Down

0 comments on commit 3685a5e

Please sign in to comment.