Merge pull request #677 from tokejepsen/2.x/feature/ordered_workfile_build

Order workfile build as presets.
This commit is contained in:
Milan Kolar 2020-11-03 15:49:35 +01:00 committed by GitHub
commit d5336b2e89
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -864,10 +864,10 @@ class BuildWorkfile:
current_task_name = io.Session["AVALON_TASK"]
# Load workfile presets for task
build_presets = self.get_build_presets(current_task_name)
self.build_presets = self.get_build_presets(current_task_name)
# Skip if there are any presets for task
if not build_presets:
if not self.build_presets:
log.warning(
"Current task `{}` does not have any loading preset.".format(
current_task_name
@ -876,9 +876,9 @@ class BuildWorkfile:
return
# Get presets for loading current asset
current_context_profiles = build_presets.get("current_context")
current_context_profiles = self.build_presets.get("current_context")
# Get presets for loading linked assets
link_context_profiles = build_presets.get("linked_assets")
link_context_profiles = self.build_presets.get("linked_assets")
# Skip if both are missing
if not current_context_profiles and not link_context_profiles:
log.warning("Current task `{}` has empty loading preset.".format(
@ -1231,7 +1231,36 @@ class BuildWorkfile:
:rtype: list
"""
loaded_containers = []
for subset_id, repres in repres_by_subset_id.items():
# Get subset id order from build presets.
build_presets = self.build_presets.get("current_context", [])
build_presets += self.build_presets.get("linked_assets", [])
subset_ids_ordered = []
for preset in build_presets:
for preset_family in preset["families"]:
for id, subset in subsets_by_id.items():
if preset_family not in subset["data"].get("families", []):
continue
subset_ids_ordered.append(id)
# Order representations from subsets.
print("repres_by_subset_id", repres_by_subset_id)
representations_ordered = []
representations = []
for id in subset_ids_ordered:
for subset_id, repres in repres_by_subset_id.items():
if repres in representations:
continue
if id == subset_id:
representations_ordered.append((subset_id, repres))
representations.append(repres)
print("representations", representations)
# Load ordered reprensentations.
for subset_id, repres in representations_ordered:
subset_name = subsets_by_id[subset_id]["name"]
profile = profiles_per_subset_id[subset_id]