Merge pull request #2322 from pypeclub/bugfix/input_links_cleanup

Input links: Cleanup and unification of differences
This commit is contained in:
Jakub Trllo 2021-11-26 19:41:22 +01:00 committed by GitHub
commit f03472c017
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 20 additions and 6 deletions

View file

@ -273,7 +273,15 @@ def get_linked_asset_ids(asset_doc):
input_links = asset_doc["data"].get("inputLinks") 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

View file

@ -113,7 +113,7 @@ class SyncLinksToAvalon(BaseEvent):
continue
links.append({
"_id": ObjectId(link_mongo_id),
"id": ObjectId(link_mongo_id),
"linkedBy": "ftrack",
"type": "breakdown"
})

View file

@ -1479,7 +1479,7 @@ class SyncEntitiesFactory:
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"
})

View file

@ -81,7 +81,8 @@ class IntegrateInputLinks(pyblish.api.ContextPlugin):
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):
@ -103,7 +104,7 @@ class IntegrateInputLinks(pyblish.api.ContextPlugin):
# 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"]:

View file

@ -37,8 +37,13 @@ class SimpleLinkView(QtWidgets.QWidget):
# 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: