From cd5303ef7b09014115f56432337a4b461617d2df Mon Sep 17 00:00:00 2001 From: Roy Nieterau Date: Mon, 23 Sep 2024 14:42:01 +0200 Subject: [PATCH 01/11] Remove legacy code --- client/ayon_core/plugins/load/delivery.py | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/client/ayon_core/plugins/load/delivery.py b/client/ayon_core/plugins/load/delivery.py index c7954a18b2..60d4c01258 100644 --- a/client/ayon_core/plugins/load/delivery.py +++ b/client/ayon_core/plugins/load/delivery.py @@ -267,17 +267,11 @@ class DeliveryOptionsDialog(QtWidgets.QDialog): new_report_items, uploaded = deliver_single_file(*args) report_items.update(new_report_items) self._update_progress(uploaded) - else: # fallback for Pype2 and representations without files - frame = repre["context"].get("frame") - if frame: - repre["context"]["frame"] = len(str(frame)) * "#" - - if not frame: - new_report_items, uploaded = deliver_single_file(*args) - else: - new_report_items, uploaded = deliver_sequence(*args) - report_items.update(new_report_items) - self._update_progress(uploaded) + else: + raise ValueError( + "Representation entity is lacking `files`." + f" Unable to process entity: {repre}" + ) self.text_area.setText(self._format_report(report_items)) self.text_area.setVisible(True) From b85289080e4289810bdebbca9b87f490ddac19fa Mon Sep 17 00:00:00 2001 From: Roy Nieterau Date: Mon, 23 Sep 2024 15:02:12 +0200 Subject: [PATCH 02/11] Remove unused import --- client/ayon_core/plugins/load/delivery.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/client/ayon_core/plugins/load/delivery.py b/client/ayon_core/plugins/load/delivery.py index 60d4c01258..09c396ff6f 100644 --- a/client/ayon_core/plugins/load/delivery.py +++ b/client/ayon_core/plugins/load/delivery.py @@ -17,8 +17,7 @@ from ayon_core.pipeline.load import get_representation_path_with_anatomy from ayon_core.pipeline.delivery import ( get_format_dict, check_destination_path, - deliver_single_file, - deliver_sequence, + deliver_single_file ) From ffd548201849c20436f147d109998e8cd1a98dbd Mon Sep 17 00:00:00 2001 From: Petr Kalis Date: Mon, 23 Sep 2024 15:17:47 +0200 Subject: [PATCH 03/11] Fix not removing absolute path in Maya DL submission This occured only in Maya (or DCC with AOV), caused pasting whole absolute path to metadata.json which could caused `Given file names contain full paths` (if ValidateExpectedFiles was disabled). 'files' is expecting only file names, not full path. --- client/ayon_core/pipeline/farm/pyblish_functions.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/client/ayon_core/pipeline/farm/pyblish_functions.py b/client/ayon_core/pipeline/farm/pyblish_functions.py index b218dc78e5..af90903bd8 100644 --- a/client/ayon_core/pipeline/farm/pyblish_functions.py +++ b/client/ayon_core/pipeline/farm/pyblish_functions.py @@ -788,6 +788,11 @@ def _create_instances_for_aov(instance, skeleton, aov_filter, additional_data, colorspace = product.colorspace break + if isinstance(files, (list, tuple)): + files = [os.path.basename(f) for f in files] + else: + files = os.path.basename(files) + rep = { "name": ext, "ext": ext, From e9b67edc0f16f972c6d0d53f056ff69c03f49653 Mon Sep 17 00:00:00 2001 From: Roy Nieterau Date: Mon, 23 Sep 2024 15:37:58 +0200 Subject: [PATCH 04/11] Remove legacy condition completely --- client/ayon_core/plugins/load/delivery.py | 70 +++++++++++------------ 1 file changed, 32 insertions(+), 38 deletions(-) diff --git a/client/ayon_core/plugins/load/delivery.py b/client/ayon_core/plugins/load/delivery.py index 09c396ff6f..6a0947cc42 100644 --- a/client/ayon_core/plugins/load/delivery.py +++ b/client/ayon_core/plugins/load/delivery.py @@ -230,47 +230,41 @@ class DeliveryOptionsDialog(QtWidgets.QDialog): self.log ] - if repre.get("files"): - src_paths = [] - for repre_file in repre["files"]: - src_path = self.anatomy.fill_root(repre_file["path"]) - src_paths.append(src_path) - sources_and_frames = collect_frames(src_paths) + src_paths = [] + for repre_file in repre["files"]: + src_path = self.anatomy.fill_root(repre_file["path"]) + src_paths.append(src_path) + sources_and_frames = collect_frames(src_paths) - frames = set(sources_and_frames.values()) - frames.discard(None) - first_frame = None - if frames: - first_frame = min(frames) + frames = set(sources_and_frames.values()) + frames.discard(None) + first_frame = None + if frames: + first_frame = min(frames) - for src_path, frame in sources_and_frames.items(): - args[0] = src_path - # Renumber frames - if renumber_frame and frame is not None: - # Calculate offset between - # first frame and current frame - # - '0' for first frame - offset = frame_offset - int(first_frame) - # Add offset to new frame start - dst_frame = int(frame) + offset - if dst_frame < 0: - msg = "Renumber frame has a smaller number than original frame" # noqa - report_items[msg].append(src_path) - self.log.warning("{} <{}>".format( - msg, dst_frame)) - continue - frame = dst_frame + for src_path, frame in sources_and_frames.items(): + args[0] = src_path + # Renumber frames + if renumber_frame and frame is not None: + # Calculate offset between + # first frame and current frame + # - '0' for first frame + offset = frame_offset - int(first_frame) + # Add offset to new frame start + dst_frame = int(frame) + offset + if dst_frame < 0: + msg = "Renumber frame has a smaller number than original frame" # noqa + report_items[msg].append(src_path) + self.log.warning("{} <{}>".format( + msg, dst_frame)) + continue + frame = dst_frame - if frame is not None: - anatomy_data["frame"] = frame - new_report_items, uploaded = deliver_single_file(*args) - report_items.update(new_report_items) - self._update_progress(uploaded) - else: - raise ValueError( - "Representation entity is lacking `files`." - f" Unable to process entity: {repre}" - ) + if frame is not None: + anatomy_data["frame"] = frame + new_report_items, uploaded = deliver_single_file(*args) + report_items.update(new_report_items) + self._update_progress(uploaded) self.text_area.setText(self._format_report(report_items)) self.text_area.setVisible(True) From d93c114d14bab45a0406588414999844c5a6c62a Mon Sep 17 00:00:00 2001 From: Petr Kalis Date: Tue, 24 Sep 2024 12:45:18 +0200 Subject: [PATCH 05/11] Fix querying of loadedVersions It si only in context.data, without it 'reference' links (of loaded containers) won't be created. --- client/ayon_core/plugins/publish/integrate_inputlinks.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/ayon_core/plugins/publish/integrate_inputlinks.py b/client/ayon_core/plugins/publish/integrate_inputlinks.py index 16aef09a39..113d6144ce 100644 --- a/client/ayon_core/plugins/publish/integrate_inputlinks.py +++ b/client/ayon_core/plugins/publish/integrate_inputlinks.py @@ -97,7 +97,7 @@ class IntegrateInputLinksAYON(pyblish.api.ContextPlugin): instance.data["versionEntity"]["id"], ) - loaded_versions = workfile_instance.context.get("loadedVersions") + loaded_versions = workfile_instance.context.data.get("loadedVersions") if not loaded_versions: return From 5189ee77243c7e6f4633f3b7a0e2251b0d88252f Mon Sep 17 00:00:00 2001 From: Petr Kalis Date: Tue, 24 Sep 2024 12:45:37 +0200 Subject: [PATCH 06/11] Added docstrings --- .../plugins/publish/integrate_inputlinks.py | 23 ++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/client/ayon_core/plugins/publish/integrate_inputlinks.py b/client/ayon_core/plugins/publish/integrate_inputlinks.py index 113d6144ce..912420e7b3 100644 --- a/client/ayon_core/plugins/publish/integrate_inputlinks.py +++ b/client/ayon_core/plugins/publish/integrate_inputlinks.py @@ -9,7 +9,14 @@ from ayon_api import ( 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" @@ -47,6 +54,11 @@ class IntegrateInputLinksAYON(pyblish.api.ContextPlugin): 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 = [] @@ -83,6 +95,15 @@ class IntegrateInputLinksAYON(pyblish.api.ContextPlugin): 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 From ebbd65cc6902bde884c120f3219467ad1ff6a24a Mon Sep 17 00:00:00 2001 From: Petr Kalis Date: Tue, 24 Sep 2024 12:45:54 +0200 Subject: [PATCH 07/11] Refactor imports --- client/ayon_core/tools/loader/models/sitesync.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/client/ayon_core/tools/loader/models/sitesync.py b/client/ayon_core/tools/loader/models/sitesync.py index 02504c2ad3..753a2e4d5c 100644 --- a/client/ayon_core/tools/loader/models/sitesync.py +++ b/client/ayon_core/tools/loader/models/sitesync.py @@ -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 From 2bd7f814bfbedd8fa300d1f9c2f929a662ba6377 Mon Sep 17 00:00:00 2001 From: Petr Kalis Date: Tue, 24 Sep 2024 12:47:12 +0200 Subject: [PATCH 08/11] Fix directions of links Currently workfile instance is on 'outside' side of reference link, we must look for 'input' reference links for it --- client/ayon_core/tools/loader/models/sitesync.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/ayon_core/tools/loader/models/sitesync.py b/client/ayon_core/tools/loader/models/sitesync.py index 753a2e4d5c..8d29845f5d 100644 --- a/client/ayon_core/tools/loader/models/sitesync.py +++ b/client/ayon_core/tools/loader/models/sitesync.py @@ -578,7 +578,7 @@ class SiteSyncModel: 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(): From 2c673ea4c4563822292e77c4414750e141e5b249 Mon Sep 17 00:00:00 2001 From: Petr Kalis Date: Tue, 24 Sep 2024 12:48:34 +0200 Subject: [PATCH 09/11] Refactor adding site to linked representations Previously it was handled by ugly exception, not it actually checks if representation files are present and if not it forces redownload immediately. --- client/ayon_core/tools/loader/models/sitesync.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/client/ayon_core/tools/loader/models/sitesync.py b/client/ayon_core/tools/loader/models/sitesync.py index 8d29845f5d..375ef9aa26 100644 --- a/client/ayon_core/tools/loader/models/sitesync.py +++ b/client/ayon_core/tools/loader/models/sitesync.py @@ -512,18 +512,19 @@ class SiteSyncModel: "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, From 7106ff04416c11de216943ba330e45c92c3fe919 Mon Sep 17 00:00:00 2001 From: Petr Kalis Date: Tue, 24 Sep 2024 12:49:19 +0200 Subject: [PATCH 10/11] Refactor remove unneeded check for adding to set --- client/ayon_core/tools/loader/models/sitesync.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/client/ayon_core/tools/loader/models/sitesync.py b/client/ayon_core/tools/loader/models/sitesync.py index 375ef9aa26..c7f0038df4 100644 --- a/client/ayon_core/tools/loader/models/sitesync.py +++ b/client/ayon_core/tools/loader/models/sitesync.py @@ -588,9 +588,6 @@ class SiteSyncModel: 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) From 7c1602340949fa3576eec1eec49720d5a3e7fcb6 Mon Sep 17 00:00:00 2001 From: Petr Kalis Date: Tue, 24 Sep 2024 14:49:20 +0200 Subject: [PATCH 11/11] Fix docstring type definition Co-authored-by: Roy Nieterau --- client/ayon_core/plugins/publish/integrate_inputlinks.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/ayon_core/plugins/publish/integrate_inputlinks.py b/client/ayon_core/plugins/publish/integrate_inputlinks.py index 912420e7b3..a3b6a228d6 100644 --- a/client/ayon_core/plugins/publish/integrate_inputlinks.py +++ b/client/ayon_core/plugins/publish/integrate_inputlinks.py @@ -101,7 +101,7 @@ class IntegrateInputLinksAYON(pyblish.api.ContextPlugin): 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 + new_links_by_type (dict[str, list[str]]): dictionary collecting new created links by its type """ if workfile_instance is None: