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

Commit

Permalink
Merge pull request #1059 from pypeclub/hotfix/explicit_subset_filter_…
Browse files Browse the repository at this point in the history
…anatomy_instance_data

Explicit subset filter in anatomy instance data
  • Loading branch information
mkolar authored Feb 26, 2021
2 parents a9c7663 + 744d32a commit 22fa134
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions pype/plugins/global/publish/collect_anatomy_instance_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,7 @@ def fill_latest_versions(self, context):
self.log.debug("Qeurying latest versions for instances.")

hierarchy = {}
subset_names = set()
asset_ids = set()
subset_filters = []
for instance in context:
# Make sure `"latestVersion"` key is set
latest_version = instance.data.get("latestVersion")
Expand All @@ -138,20 +137,21 @@ def fill_latest_versions(self, context):
# Store asset ids and subset names for queries
asset_id = asset_doc["_id"]
subset_name = instance.data["subset"]
asset_ids.add(asset_id)
subset_names.add(subset_name)

# Prepare instance hiearchy for faster filling latest versions
if asset_id not in hierarchy:
hierarchy[asset_id] = {}
if subset_name not in hierarchy[asset_id]:
hierarchy[asset_id][subset_name] = []
hierarchy[asset_id][subset_name].append(instance)
subset_filters.append({
"parent": asset_id,
"name": subset_name
})

subset_docs = list(io.find({
"type": "subset",
"parent": {"$in": list(asset_ids)},
"name": {"$in": list(subset_names)}
"$or": subset_filters
}))

subset_ids = [
Expand Down

0 comments on commit 22fa134

Please sign in to comment.