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

Input links: Cleanup and unification of differences #2322

Merged
merged 6 commits into from
Nov 26, 2021
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
10 changes: 9 additions & 1 deletion openpype/lib/avalon_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
})
Expand Down
2 changes: 1 addition & 1 deletion openpype/modules/default_modules/ftrack/lib/avalon_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
})
Expand Down
5 changes: 3 additions & 2 deletions openpype/plugins/publish/integrate_inputlinks.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,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):
Expand All @@ -103,7 +104,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"]:
Expand Down
7 changes: 6 additions & 1 deletion openpype/tools/assetlinks/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down