From c728eec8ab22e3e260bdf2b9cc0fcad9e3b52c18 Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Fri, 26 Nov 2021 12:55:26 +0100 Subject: [PATCH 1/6] use "id" key where id of input is stored instead of "input" --- openpype/plugins/publish/integrate_inputlinks.py | 2 +- openpype/tools/assetlinks/widgets.py | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/openpype/plugins/publish/integrate_inputlinks.py b/openpype/plugins/publish/integrate_inputlinks.py index e8a8b2296c1..3b134345e43 100644 --- a/openpype/plugins/publish/integrate_inputlinks.py +++ b/openpype/plugins/publish/integrate_inputlinks.py @@ -103,7 +103,7 @@ def add_link(self, link_type, input_id, version_doc): # future. link = OrderedDict() link["type"] = link_type - link["input"] = io.ObjectId(input_id) + link["id"] = io.ObjectId(input_id) link["linkedBy"] = "publish" if "inputLinks" not in version_doc["data"]: diff --git a/openpype/tools/assetlinks/widgets.py b/openpype/tools/assetlinks/widgets.py index 9a136462b08..22e8848a609 100644 --- a/openpype/tools/assetlinks/widgets.py +++ b/openpype/tools/assetlinks/widgets.py @@ -37,8 +37,13 @@ def set_version(self, version_doc): # inputs # for link in version_doc["data"].get("inputLinks", []): + # Backwards compatibility for "input" key used as "id" + if "id" not in link: + link_id = link["input"] + else: + link_id = link["id"] version = self.dbcon.find_one( - {"_id": link["input"], "type": "version"}, + {"_id": link_id, "type": "version"}, projection={"name": 1, "parent": 1} ) if not version: From 46cb7d7a71bebd51f794c4d3a893dc2b780e3bff Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Fri, 26 Nov 2021 12:56:20 +0100 Subject: [PATCH 2/6] skip processing if workfile instance is not available --- openpype/plugins/publish/integrate_inputlinks.py | 1 + 1 file changed, 1 insertion(+) diff --git a/openpype/plugins/publish/integrate_inputlinks.py b/openpype/plugins/publish/integrate_inputlinks.py index 3b134345e43..539ad984b1d 100644 --- a/openpype/plugins/publish/integrate_inputlinks.py +++ b/openpype/plugins/publish/integrate_inputlinks.py @@ -55,6 +55,7 @@ def process(self, context): if workfile is None: self.log.warn("No workfile in this publish session.") + return else: workfile_version_doc = workfile.data["versionEntity"] # link all loaded versions in scene into workfile From a732ce3ee95306a55ab87bc987cb8e4f75e716e1 Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Fri, 26 Nov 2021 12:56:37 +0100 Subject: [PATCH 3/6] skip else statement --- .../plugins/publish/integrate_inputlinks.py | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/openpype/plugins/publish/integrate_inputlinks.py b/openpype/plugins/publish/integrate_inputlinks.py index 539ad984b1d..beefd8c05ac 100644 --- a/openpype/plugins/publish/integrate_inputlinks.py +++ b/openpype/plugins/publish/integrate_inputlinks.py @@ -56,22 +56,22 @@ def process(self, context): if workfile is None: self.log.warn("No workfile in this publish session.") return - else: - workfile_version_doc = workfile.data["versionEntity"] - # link all loaded versions in scene into workfile - for version in context.data.get("loadedVersions", []): - self.add_link( - link_type="reference", - input_id=version["version"], - version_doc=workfile_version_doc, - ) - # link workfile to all publishing versions - for instance in publishing: - self.add_link( - link_type="generative", - input_id=workfile_version_doc["_id"], - version_doc=instance.data["versionEntity"], - ) + + workfile_version_doc = workfile.data["versionEntity"] + # link all loaded versions in scene into workfile + for version in context.data.get("loadedVersions", []): + self.add_link( + link_type="reference", + input_id=version["version"], + version_doc=workfile_version_doc, + ) + # link workfile to all publishing versions + for instance in publishing: + self.add_link( + link_type="generative", + input_id=workfile_version_doc["_id"], + version_doc=instance.data["versionEntity"], + ) # link versions as dependencies to the instance for instance in publishing: From 8a71f5ecacaf93ba2e1c0ec8b0b785d52519b896 Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Fri, 26 Nov 2021 13:35:14 +0100 Subject: [PATCH 4/6] changed "_id" key to "id" in ftrack sync --- .../ftrack/event_handlers_server/event_sync_links.py | 2 +- openpype/modules/default_modules/ftrack/lib/avalon_sync.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/openpype/modules/default_modules/ftrack/event_handlers_server/event_sync_links.py b/openpype/modules/default_modules/ftrack/event_handlers_server/event_sync_links.py index 8c3d858a969..83132acd85b 100644 --- a/openpype/modules/default_modules/ftrack/event_handlers_server/event_sync_links.py +++ b/openpype/modules/default_modules/ftrack/event_handlers_server/event_sync_links.py @@ -113,7 +113,7 @@ def _update_in_links(self, session, ftrack_ids, project_id): continue links.append({ - "_id": ObjectId(link_mongo_id), + "id": ObjectId(link_mongo_id), "linkedBy": "ftrack", "type": "breakdown" }) diff --git a/openpype/modules/default_modules/ftrack/lib/avalon_sync.py b/openpype/modules/default_modules/ftrack/lib/avalon_sync.py index 9e22f80b1c7..3ba874281ac 100644 --- a/openpype/modules/default_modules/ftrack/lib/avalon_sync.py +++ b/openpype/modules/default_modules/ftrack/lib/avalon_sync.py @@ -1479,7 +1479,7 @@ def set_input_links(self): mongo_id = self.ftrack_avalon_mapper.get(ftrack_link_id) if mongo_id is not None: input_links.append({ - "_id": ObjectId(mongo_id), + "id": ObjectId(mongo_id), "linkedBy": "ftrack", "type": "breakdown" }) From 9772282a5c4a6319f470d68896a5ba7e5968a26f Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Fri, 26 Nov 2021 13:35:34 +0100 Subject: [PATCH 5/6] check for "id" key instead of "_id" in get_linked_asset_ids --- openpype/lib/avalon_context.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/openpype/lib/avalon_context.py b/openpype/lib/avalon_context.py index 3e0e0c6ea62..c8e88610a52 100644 --- a/openpype/lib/avalon_context.py +++ b/openpype/lib/avalon_context.py @@ -273,7 +273,15 @@ def get_linked_asset_ids(asset_doc): input_links = asset_doc["data"].get("inputsLinks") or [] if input_links: - output = [item["_id"] for item in input_links] + for item in input_links: + # Backwards compatibility for "_id" key which was replaced with + # "id" + if "_id" in item: + link_id = item["_id"] + else: + link_id = item["id"] + output.append(link_id) + return output From b306dfd8e947533b64a8cea54d6763981fafdba8 Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Fri, 26 Nov 2021 19:35:22 +0100 Subject: [PATCH 6/6] skip workfile instance linking if workfile instance is not available --- .../plugins/publish/integrate_inputlinks.py | 36 +++++++++---------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/openpype/plugins/publish/integrate_inputlinks.py b/openpype/plugins/publish/integrate_inputlinks.py index beefd8c05ac..f973dfc963b 100644 --- a/openpype/plugins/publish/integrate_inputlinks.py +++ b/openpype/plugins/publish/integrate_inputlinks.py @@ -55,23 +55,22 @@ def process(self, context): if workfile is None: self.log.warn("No workfile in this publish session.") - return - - workfile_version_doc = workfile.data["versionEntity"] - # link all loaded versions in scene into workfile - for version in context.data.get("loadedVersions", []): - self.add_link( - link_type="reference", - input_id=version["version"], - version_doc=workfile_version_doc, - ) - # link workfile to all publishing versions - for instance in publishing: - self.add_link( - link_type="generative", - input_id=workfile_version_doc["_id"], - version_doc=instance.data["versionEntity"], - ) + else: + workfile_version_doc = workfile.data["versionEntity"] + # link all loaded versions in scene into workfile + for version in context.data.get("loadedVersions", []): + self.add_link( + link_type="reference", + input_id=version["version"], + version_doc=workfile_version_doc, + ) + # link workfile to all publishing versions + for instance in publishing: + self.add_link( + link_type="generative", + input_id=workfile_version_doc["_id"], + version_doc=instance.data["versionEntity"], + ) # link versions as dependencies to the instance for instance in publishing: @@ -82,7 +81,8 @@ def process(self, context): version_doc=instance.data["versionEntity"], ) - publishing.append(workfile) + if workfile is not None: + publishing.append(workfile) self.write_links_to_database(publishing) def add_link(self, link_type, input_id, version_doc):