From e242e8094e292c28f049eacb4eed0dbfd61222db Mon Sep 17 00:00:00 2001 From: Jakub Trllo Date: Tue, 5 Mar 2024 13:57:13 +0100 Subject: [PATCH] pipeline is using product entities --- client/ayon_core/lib/path_tools.py | 2 +- .../ayon_core/pipeline/create/product_name.py | 2 +- client/ayon_core/pipeline/create/utils.py | 38 +++-- client/ayon_core/pipeline/load/__init__.py | 12 +- client/ayon_core/pipeline/load/plugins.py | 26 ++-- client/ayon_core/pipeline/load/utils.py | 132 +++++++++--------- client/ayon_core/pipeline/usdlib.py | 46 +++--- .../pipeline/workfile/build_workfile.py | 79 +++++------ .../workfile/workfile_template_builder.py | 9 +- 9 files changed, 169 insertions(+), 177 deletions(-) diff --git a/client/ayon_core/lib/path_tools.py b/client/ayon_core/lib/path_tools.py index 74475adfe3..a65f0f8e13 100644 --- a/client/ayon_core/lib/path_tools.py +++ b/client/ayon_core/lib/path_tools.py @@ -78,7 +78,7 @@ def collect_frames(files): files(list) or (set with single value): list of source paths Returns: - dict: {'/folder/subset_v001.0001.png': '0001', ....} + dict: {'/folder/product_v001.0001.png': '0001', ....} """ patterns = [clique.PATTERNS["frames"]] diff --git a/client/ayon_core/pipeline/create/product_name.py b/client/ayon_core/pipeline/create/product_name.py index 7eaa338c91..8976fb2ff0 100644 --- a/client/ayon_core/pipeline/create/product_name.py +++ b/client/ayon_core/pipeline/create/product_name.py @@ -33,7 +33,7 @@ def get_product_name_template( Args: project_name (str): Project on which the context lives. - product_type (str): Product type for which the subset name is + product_type (str): Product type for which the product name is calculated. host_name (str): Name of host in which the product name is calculated. task_name (str): Name of task in which context the product is created. diff --git a/client/ayon_core/pipeline/create/utils.py b/client/ayon_core/pipeline/create/utils.py index 223a30997c..c94fbe5cb0 100644 --- a/client/ayon_core/pipeline/create/utils.py +++ b/client/ayon_core/pipeline/create/utils.py @@ -2,10 +2,7 @@ import collections import ayon_api -from ayon_core.client import ( - get_subsets, - get_last_versions, -) +from ayon_core.client import get_last_versions def get_last_versions_for_instances( @@ -66,35 +63,36 @@ def get_last_versions_for_instances( if not folder_paths_by_id: return output - subset_docs = get_subsets( + product_entities = ayon_api.get_products( project_name, - asset_ids=folder_paths_by_id.keys(), - subset_names=product_names, - fields=["_id", "name", "parent"] + folder_ids=folder_paths_by_id.keys(), + product_names=product_names, + fields={"id", "name", "folderId"} ) - subset_docs_by_id = {} - for subset_doc in subset_docs: - # Filter subset docs by subset names under parent - folder_id = subset_doc["parent"] + product_entities_by_id = {} + for product_entity in product_entities: + # Filter product entities by names under parent + folder_id = product_entity["folderId"] + product_name = product_entity["name"] folder_path = folder_paths_by_id[folder_id] - product_name = subset_doc["name"] if product_name not in product_names_by_folder_path[folder_path]: continue - subset_docs_by_id[subset_doc["_id"]] = subset_doc + product_entities_by_id[product_entity["id"]] = product_entity - if not subset_docs_by_id: + if not product_entities_by_id: return output last_versions_by_product_id = get_last_versions( project_name, - subset_docs_by_id.keys(), + product_entities_by_id.keys(), fields=["name", "parent"] ) - for subset_id, version_doc in last_versions_by_product_id.items(): - subset_doc = subset_docs_by_id[subset_id] - folder_id = subset_doc["parent"] + for product_id, version_doc in last_versions_by_product_id.items(): + product_entity = product_entities_by_id[product_id] + product_name = product_entity["name"] + folder_id = product_entity["folderId"] folder_path = folder_paths_by_id[folder_id] - _instances = instances_by_hierarchy[folder_path][subset_doc["name"]] + _instances = instances_by_hierarchy[folder_path][product_name] for instance in _instances: output[instance.id] = version_doc["name"] diff --git a/client/ayon_core/pipeline/load/__init__.py b/client/ayon_core/pipeline/load/__init__.py index e955fa72dc..0e2768dbe1 100644 --- a/client/ayon_core/pipeline/load/__init__.py +++ b/client/ayon_core/pipeline/load/__init__.py @@ -9,12 +9,12 @@ from .utils import ( get_repres_contexts, get_contexts_for_repre_docs, - get_subset_contexts, + get_product_contexts, get_representation_context, load_with_repre_context, - load_with_subset_context, - load_with_subset_contexts, + load_with_product_context, + load_with_product_contexts, load_container, remove_container, @@ -63,12 +63,12 @@ __all__ = ( "get_repres_contexts", "get_contexts_for_repre_docs", - "get_subset_contexts", + "get_product_contexts", "get_representation_context", "load_with_repre_context", - "load_with_subset_context", - "load_with_subset_contexts", + "load_with_product_context", + "load_with_product_contexts", "load_container", "remove_container", diff --git a/client/ayon_core/pipeline/load/plugins.py b/client/ayon_core/pipeline/load/plugins.py index 90affa3ab2..797737966d 100644 --- a/client/ayon_core/pipeline/load/plugins.py +++ b/client/ayon_core/pipeline/load/plugins.py @@ -33,7 +33,7 @@ class LoaderPlugin(list): options = [] - log = logging.getLogger("SubsetLoader") + log = logging.getLogger("ProductLoader") log.propagate = True @classmethod @@ -130,10 +130,10 @@ class LoaderPlugin(list): """ plugin_repre_names = cls.get_representations() - plugin_families = cls.families + plugin_product_types = cls.families if ( not plugin_repre_names - or not plugin_families + or not plugin_product_types or not cls.extensions ): return False @@ -152,24 +152,14 @@ class LoaderPlugin(list): if not cls.has_valid_extension(repre_doc): return False - plugin_families = set(plugin_families) - if "*" in plugin_families: + plugin_product_types = set(plugin_product_types) + if "*" in plugin_product_types: return True - subset_doc = context["subset"] - maj_version, _ = schema.get_schema_version(subset_doc["schema"]) - if maj_version < 3: - families = context["version"]["data"].get("families") - else: - families = subset_doc["data"].get("families") - if families is None: - family = subset_doc["data"].get("family") - if family: - families = [family] + product_entity = context["product"] + product_type = product_entity["productType"] - if not families: - return False - return any(family in plugin_families for family in families) + return product_type in plugin_product_types @classmethod def get_representations(cls): diff --git a/client/ayon_core/pipeline/load/utils.py b/client/ayon_core/pipeline/load/utils.py index f1b467fff5..ceb4038b6e 100644 --- a/client/ayon_core/pipeline/load/utils.py +++ b/client/ayon_core/pipeline/load/utils.py @@ -10,8 +10,6 @@ import ayon_api from ayon_core.host import ILoadHost from ayon_core.client import ( - get_subsets, - get_subset_by_id, get_versions, get_version_by_id, get_last_version_by_subset_id, @@ -97,8 +95,8 @@ def get_repres_contexts(representation_ids, project_name=None): Returns: dict: The full representation context by representation id. - keys are repre_id, value is dictionary with full documents of - asset, subset, version and representation. + keys are repre_id, value is dictionary with entities of + folder, product, version and representation. """ from ayon_core.pipeline import get_current_project_name @@ -131,13 +129,13 @@ def get_contexts_for_repre_docs(project_name, repre_docs): version_docs_by_id = {} hero_version_docs = [] versions_for_hero = set() - subset_ids = set() + product_ids = set() for version_doc in version_docs: if version_doc["type"] == "hero_version": hero_version_docs.append(version_doc) versions_for_hero.add(version_doc["version_id"]) version_docs_by_id[version_doc["_id"]] = version_doc - subset_ids.add(version_doc["parent"]) + product_ids.add(version_doc["parent"]) if versions_for_hero: _version_docs = get_versions(project_name, versions_for_hero) @@ -152,12 +150,14 @@ def get_contexts_for_repre_docs(project_name, repre_docs): version_data = copy.deepcopy(_version_data_by_id[version_id]) version_docs_by_id[hero_version_id]["data"] = version_data - subset_docs = get_subsets(project_name, subset_ids) - subset_docs_by_id = {} + product_entities = ayon_api.get_products( + project_name, product_ids=product_ids + ) + product_entities_by_id = {} folder_ids = set() - for subset_doc in subset_docs: - subset_docs_by_id[subset_doc["_id"]] = subset_doc - folder_ids.add(subset_doc["parent"]) + for product_entity in product_entities: + product_entities_by_id[product_entity["id"]] = product_entity + folder_ids.add(product_entity["folderId"]) folder_entities_by_id = { folder_entity["id"]: folder_entity @@ -170,12 +170,12 @@ def get_contexts_for_repre_docs(project_name, repre_docs): for repre_id, repre_doc in repre_docs_by_id.items(): version_doc = version_docs_by_id[repre_doc["parent"]] - subset_doc = subset_docs_by_id[version_doc["parent"]] - folder_entity = folder_entities_by_id[subset_doc["parent"]] + product_entity = product_entities_by_id[version_doc["parent"]] + folder_entity = folder_entities_by_id[product_entity["folderId"]] context = { "project": project_entity, "folder": folder_entity, - "subset": subset_doc, + "product": product_entity, "version": version_doc, "representation": repre_doc, } @@ -184,13 +184,13 @@ def get_contexts_for_repre_docs(project_name, repre_docs): return contexts -def get_subset_contexts(subset_ids, project_name=None): - """Return parenthood context for subset. +def get_product_contexts(product_ids, project_name=None): + """Return parenthood context for product. - Provides context on subset granularity - less detail than + Provides context on product granularity - less detail than 'get_repre_contexts'. Args: - subset_ids (list): The subset ids. + product_ids (list): The product ids. project_name (Optional[str]): Project name. Returns: dict: The full representation context by representation id. @@ -198,17 +198,19 @@ def get_subset_contexts(subset_ids, project_name=None): from ayon_core.pipeline import get_current_project_name contexts = {} - if not subset_ids: + if not product_ids: return contexts if not project_name: project_name = get_current_project_name() - subset_docs = get_subsets(project_name, subset_ids) - subset_docs_by_id = {} + product_entities = ayon_api.get_products( + project_name, product_ids=product_ids + ) + product_entities_by_id = {} folder_ids = set() - for subset_doc in subset_docs: - subset_docs_by_id[subset_doc["_id"]] = subset_doc - folder_ids.add(subset_doc["parent"]) + for product_entity in product_entities: + product_entities_by_id[product_entity["id"]] = product_entity + folder_ids.add(product_entity["folderId"]) folder_entities_by_id = { folder_entity["id"]: folder_entity @@ -219,14 +221,14 @@ def get_subset_contexts(subset_ids, project_name=None): project_entity = ayon_api.get_project(project_name) - for subset_id, subset_doc in subset_docs_by_id.items(): - folder_entity = folder_entities_by_id[subset_doc["parent"]] + for product_id, product_entity in product_entities_by_id.items(): + folder_entity = folder_entities_by_id[product_entity["folderId"]] context = { "project": project_entity, "folder": folder_entity, - "subset": subset_doc + "product": product_entity } - contexts[subset_id] = context + contexts[product_id] = context return contexts @@ -256,14 +258,14 @@ def get_representation_context(representation): ( version_doc, - subset_doc, + product_entity, folder_entity, project_entity ) = get_representation_parents(project_name, representation) if not version_doc: raise AssertionError("Version was not found in database") - if not subset_doc: - raise AssertionError("Subset was not found in database") + if not product_entity: + raise AssertionError("Product was not found in database") if not folder_entity: raise AssertionError("Folder was not found in database") if not project_entity: @@ -272,7 +274,7 @@ def get_representation_context(representation): context = { "project": project_entity, "folder": folder_entity, - "subset": subset_doc, + "product": product_entity, "version": version_doc, "representation": representation, } @@ -288,7 +290,7 @@ def load_with_repre_context( if not is_compatible_loader(Loader, repre_context): raise IncompatibleLoaderError( "Loader {} is incompatible with {}".format( - Loader.__name__, repre_context["subset"]["name"] + Loader.__name__, repre_context["product"]["name"] ) ) @@ -298,9 +300,9 @@ def load_with_repre_context( assert isinstance(options, dict), "Options must be a dictionary" - # Fallback to subset when name is None + # Fallback to product when name is None if name is None: - name = repre_context["subset"]["name"] + name = repre_context["product"]["name"] log.info( "Running '%s' on '%s'" % ( @@ -318,8 +320,8 @@ def load_with_repre_context( return loader.load(repre_context, name, namespace, options) -def load_with_subset_context( - Loader, subset_context, namespace=None, name=None, options=None, **kwargs +def load_with_product_context( + Loader, product_context, namespace=None, name=None, options=None, **kwargs ): # Ensure options is a dictionary when no explicit options provided @@ -328,21 +330,21 @@ def load_with_subset_context( assert isinstance(options, dict), "Options must be a dictionary" - # Fallback to subset when name is None + # Fallback to product when name is None if name is None: - name = subset_context["subset"]["name"] + name = product_context["product"]["name"] log.info( "Running '%s' on '%s'" % ( - Loader.__name__, subset_context["folder"]["path"] + Loader.__name__, product_context["folder"]["path"] ) ) - return Loader().load(subset_context, name, namespace, options) + return Loader().load(product_context, name, namespace, options) -def load_with_subset_contexts( - Loader, subset_contexts, namespace=None, name=None, options=None, **kwargs +def load_with_product_contexts( + Loader, product_contexts, namespace=None, name=None, options=None, **kwargs ): # Ensure options is a dictionary when no explicit options provided @@ -351,19 +353,21 @@ def load_with_subset_contexts( assert isinstance(options, dict), "Options must be a dictionary" - # Fallback to subset when name is None - joined_subset_names = " | ".join( - context["subset"]["name"] - for context in subset_contexts + # Fallback to product when name is None + joined_product_names = " | ".join( + context["product"]["name"] + for context in product_contexts ) if name is None: - name = joined_subset_names + name = joined_product_names log.info( - "Running '{}' on '{}'".format(Loader.__name__, joined_subset_names) + "Running '{}' on '{}'".format( + Loader.__name__, joined_product_names + ) ) - return Loader().load(subset_contexts, name, namespace, options) + return Loader().load(product_contexts, name, namespace, options) def load_container( @@ -376,7 +380,7 @@ def load_container( representation (str or ObjectId or dict): The representation id or full representation as returned by the database. namespace (str, Optional): The namespace to assign. Defaults to None. - name (str, Optional): The name to assign. Defaults to subset name. + name (str, Optional): The name to assign. Defaults to product name. options (dict, Optional): Additional options to pass on to the loader. Returns: @@ -477,9 +481,11 @@ def update_container(container, version=-1): new_version = get_version_by_name( project_name, version, current_version["parent"], fields=["_id"] ) - subset_doc = get_subset_by_id(project_name, current_version["parent"]) + product_entity = ayon_api.get_product_by_id( + project_name, current_version["parent"] + ) folder_entity = ayon_api.get_folder_by_id( - project_name, subset_doc["parent"] + project_name, product_entity["folderId"] ) assert new_version is not None, "This is a bug" @@ -503,7 +509,7 @@ def update_container(container, version=-1): context = { "project": project_entity, "folder": folder_entity, - "subset": subset_doc, + "product": product_entity, "version": new_version, "representation": new_representation, } @@ -551,7 +557,7 @@ def switch_container(container, representation, loader_plugin=None): if not is_compatible_loader(loader_plugin, new_context): raise IncompatibleLoaderError( "Loader {} is incompatible with {}".format( - loader_plugin.__name__, new_context["subset"]["name"] + loader_plugin.__name__, new_context["product"]["name"] ) ) @@ -849,7 +855,7 @@ def filter_containers(containers, project_name): repre_docs_by_str_id[repre_id] = repre_doc repre_docs_by_version_id[version_id].append(repre_doc) - # Query version docs to get it's subset ids + # Query version docs to get it's product ids # - also query hero version to be able identify if representation # belongs to existing version version_docs = get_versions( @@ -859,29 +865,29 @@ def filter_containers(containers, project_name): fields=["_id", "parent", "type"] ) verisons_by_id = {} - versions_by_subset_id = collections.defaultdict(list) + versions_by_product_id = collections.defaultdict(list) hero_version_ids = set() for version_doc in version_docs: version_id = version_doc["_id"] # Store versions by their ids verisons_by_id[version_id] = version_doc - # There's no need to query subsets for hero versions + # There's no need to query products for hero versions # - they are considered as latest? if version_doc["type"] == "hero_version": hero_version_ids.add(version_id) continue - subset_id = version_doc["parent"] - versions_by_subset_id[subset_id].append(version_doc) + product_id = version_doc["parent"] + versions_by_product_id[product_id].append(version_doc) last_versions = get_last_versions( project_name, - subset_ids=versions_by_subset_id.keys(), + subset_ids=versions_by_product_id.keys(), fields=["_id"] ) # Figure out which versions are outdated outdated_version_ids = set() - for subset_id, last_version_doc in last_versions.items(): - for version_doc in versions_by_subset_id[subset_id]: + for product_id, last_version_doc in last_versions.items(): + for version_doc in versions_by_product_id[product_id]: version_id = version_doc["_id"] if version_id != last_version_doc["_id"]: outdated_version_ids.add(version_id) diff --git a/client/ayon_core/pipeline/usdlib.py b/client/ayon_core/pipeline/usdlib.py index 7d4105f06f..dedcee6f99 100644 --- a/client/ayon_core/pipeline/usdlib.py +++ b/client/ayon_core/pipeline/usdlib.py @@ -119,7 +119,7 @@ def create_shot(filepath, layers, create_layers=False): return filepath -def create_model(filename, folder_path, variant_subsets): +def create_model(filename, folder_path, variant_product_names): """Create a USD Model file. For each of the variation paths it will payload the path and set its @@ -132,19 +132,19 @@ def create_model(filename, folder_path, variant_subsets): assert folder_entity, "Folder not found: %s" % folder_path variants = [] - for subset in variant_subsets: + for product_name in variant_product_names: prefix = "usdModel" - if subset.startswith(prefix): + if product_name.startswith(prefix): # Strip off `usdModel_` - variant = subset[len(prefix):] + variant = product_name[len(prefix):] else: raise ValueError( - "Model subsets must start " "with usdModel: %s" % subset + "Model products must start with usdModel: %s" % product_name ) path = get_usd_master_path( folder_entity=folder_entity, - product_name=subset, + product_name=product_name, representation="usd" ) variants.append((variant, path)) @@ -172,11 +172,11 @@ def create_model(filename, folder_path, variant_subsets): stage.GetRootLayer().Save() -def create_shade(filename, folder_path, variant_subsets): +def create_shade(filename, folder_path, variant_product_names): """Create a master USD shade file for an asset. For each available model variation this should generate a reference - to a `usdShade_{modelVariant}` subset. + to a `usdShade_{modelVariant}` product. """ @@ -186,20 +186,22 @@ def create_shade(filename, folder_path, variant_subsets): variants = [] - for subset in variant_subsets: + for product_name in variant_product_names: prefix = "usdModel" - if subset.startswith(prefix): + if product_name.startswith(prefix): # Strip off `usdModel_` - variant = subset[len(prefix):] + variant = product_name[len(prefix):] else: raise ValueError( - "Model subsets must start " "with usdModel: %s" % subset + "Model products must start " "with usdModel: %s" % product_name ) - shade_subset = re.sub("^usdModel", "usdShade", subset) + shade_product_name = re.sub( + "^usdModel", "usdShade", product_name + ) path = get_usd_master_path( folder_entity=folder_entity, - product_name=shade_subset, + product_name=shade_product_name, representation="usd" ) variants.append((variant, path)) @@ -224,12 +226,12 @@ def create_shade_variation(filename, folder_path, model_variant, shade_variants) variants = [] for variant in shade_variants: - subset = "usdShade_{model}_{shade}".format( + product_name = "usdShade_{model}_{shade}".format( model=model_variant, shade=variant ) path = get_usd_master_path( folder_entity=folder_entity, - product_name=subset, + product_name=product_name, representation="usd" ) variants.append((variant, path)) @@ -314,13 +316,13 @@ def _create_variants_file( def get_usd_master_path(folder_entity, product_name, representation): - """Get the filepath for a .usd file of a subset. + """Get the filepath for a .usd file of a product. This will return the path to an unversioned master file generated by `usd_master_file.py`. Args: - folder (Union[str, dict]): Folder path or entity. + folder_entity (Union[str, dict]): Folder entity. product_name (str): Product name. representation (str): Representation name. """ @@ -343,16 +345,16 @@ def get_usd_master_path(folder_entity, product_name, representation): path = template_obj.format_strict(template_data) # Remove the version folder - subset_folder = os.path.dirname(os.path.dirname(path)) - master_folder = os.path.join(subset_folder, "master") + product_folder = os.path.dirname(os.path.dirname(path)) + master_folder = os.path.join(product_folder, "master") fname = "{0}.{1}".format(product_name, representation) return os.path.join(master_folder, fname).replace("\\", "/") def parse_avalon_uri(uri): - # URI Pattern: avalon://{folder}/{subset}.{ext} - pattern = r"avalon://(?P[^/.]*)/(?P[^/]*)\.(?P.*)" + # URI Pattern: avalon://{folder}/{product}.{ext} + pattern = r"avalon://(?P[^/.]*)/(?P[^/]*)\.(?P.*)" if uri.startswith("avalon://"): match = re.match(pattern, uri) if match: diff --git a/client/ayon_core/pipeline/workfile/build_workfile.py b/client/ayon_core/pipeline/workfile/build_workfile.py index 50273dce9e..ec8681d09f 100644 --- a/client/ayon_core/pipeline/workfile/build_workfile.py +++ b/client/ayon_core/pipeline/workfile/build_workfile.py @@ -16,7 +16,6 @@ import json import ayon_api from ayon_core.client import ( - get_subsets, get_last_versions, get_representations, ) @@ -48,17 +47,11 @@ class BuildWorkfile: return self._log @staticmethod - def map_products_by_type(subset_docs): + def map_products_by_type(product_entities): products_by_type = collections.defaultdict(list) - for subset_doc in subset_docs: - product_type = subset_doc["data"].get("family") - if not product_type: - families = subset_doc["data"].get("families") - if not families: - continue - product_type = families[0] - - products_by_type[product_type].append(subset_doc) + for product_entity in product_entities: + product_type = product_entity["productType"] + products_by_type[product_type].append(product_entity) return products_by_type def process(self): @@ -380,7 +373,7 @@ class BuildWorkfile: project_name, folder_ids=linked_folder_ids )) - def _prepare_profile_for_products(self, subset_docs, profiles): + def _prepare_profile_for_products(self, product_entities, profiles): """Select profile for each product by it's data. Profiles are filtered for each product individually. @@ -391,7 +384,7 @@ class BuildWorkfile: matching profile. Args: - subset_docs (List[Dict[str, Any]]): Subset documents. + product_entities (List[Dict[str, Any]]): product entities. profiles (List[Dict[str, Any]]): Build profiles. Returns: @@ -399,10 +392,10 @@ class BuildWorkfile: """ # Prepare products - products_by_type = self.map_products_by_type(subset_docs) + products_by_type = self.map_products_by_type(product_entities) profiles_by_product_id = {} - for product_type, subset_docs in products_by_type.items(): + for product_type, product_entities in products_by_type.items(): product_type_low = product_type.lower() for profile in profiles: # Skip profile if does not contain product type @@ -418,19 +411,19 @@ class BuildWorkfile: profile_regexes = _profile_regexes # TODO prepare regex compilation - for subset_doc in subset_docs: + for product_entity in product_entities: # Verify regex filtering (optional) if profile_regexes: valid = False for pattern in profile_regexes: - if re.match(pattern, subset_doc["name"]): + if re.match(pattern, product_entity["name"]): valid = True break if not valid: continue - profiles_by_product_id[subset_doc["_id"]] = profile + profiles_by_product_id[product_entity["id"]] = profile # break profiles loop on finding the first matching profile break @@ -473,9 +466,9 @@ class BuildWorkfile: products_by_id = {} version_by_product_id = {} repres_by_version_id = {} - for product_id, in_data in linked_folder_data["subsets"].items(): - subset_doc = in_data["subset_doc"] - products_by_id[subset_doc["_id"]] = subset_doc + for product_id, in_data in linked_folder_data["products"].items(): + product_entity = in_data["product_entity"] + products_by_id[product_entity["id"]] = product_entity version_data = in_data["version"] version_doc = version_data["version_doc"] @@ -514,9 +507,9 @@ class BuildWorkfile: folder_entity["path"] ) for product_id, repres in valid_repres_by_product_id.items(): - subset_doc = products_by_id[product_id] + product_entity = products_by_id[product_id] msg += "\n# Product Name/ID: `{}`/{}".format( - subset_doc["name"], product_id + product_entity["name"], product_id ) for repre in repres: msg += "\n## Repre name: `{}`".format(repre["name"]) @@ -545,13 +538,13 @@ class BuildWorkfile: If product has representation matching representation name each loader is tried to load it until any is successful. If none of them was successful then next representation name is tried. - Subset process loop ends when any representation is loaded or + Product process loop ends when any representation is loaded or all matching representations were already tried. Args: repres_by_product_id (Dict[str, Dict[str, Any]]): Available representations mapped by their parent (product) id. - products_by_id (Dict[str, Dict[str, Any]]): Subset documents + products_by_id (Dict[str, Dict[str, Any]]): Product entities mapped by their id. profiles_by_product_id (Dict[str, Dict[str, Any]]): Build profiles mapped by product id. @@ -570,9 +563,9 @@ class BuildWorkfile: product_ids_ordered = [] for preset in build_presets: for product_type in preset["product_types"]: - for product_id, subset_doc in products_by_id.items(): + for product_id, product_entity in products_by_id.items(): # TODO 'families' is not available on product - families = subset_doc["data"].get("families") or [] + families = product_entity["data"].get("families") or [] if product_type not in families: continue @@ -674,9 +667,9 @@ class BuildWorkfile: { : { "folder_entity": , - "subsets": { + "products": { : { - "subset_doc": , + "product_entity": , "version": { "version_doc": , "repres": [ @@ -689,7 +682,7 @@ class BuildWorkfile: }, ... } - output[folder_id]["subsets"][product_id]["version"]["repres"] + output[folder_id]["products"][product_id]["version"]["repres"] ``` """ @@ -705,16 +698,16 @@ class BuildWorkfile: } project_name = get_current_project_name() - subset_docs = list(get_subsets( - project_name, asset_ids=folder_entities_by_id.keys() + product_entities = list(ayon_api.get_products( + project_name, folder_ids=folder_entities_by_id.keys() )) - subset_docs_by_id = { - subset_doc["_id"]: subset_doc - for subset_doc in subset_docs + product_entities_by_id = { + product_entity["id"]: product_entity + for product_entity in product_entities } last_version_by_product_id = get_last_versions( - project_name, subset_docs_by_id.keys() + project_name, product_entities_by_id.keys() ) last_version_docs_by_id = { version["_id"]: version @@ -729,27 +722,27 @@ class BuildWorkfile: version_doc = last_version_docs_by_id[version_id] product_id = version_doc["parent"] - subset_doc = subset_docs_by_id[product_id] + product_entity = product_entities_by_id[product_id] - folder_id = subset_doc["parent"] + folder_id = product_entity["folderId"] folder_entity = folder_entities_by_id[folder_id] if folder_id not in output: output[folder_id] = { "folder_entity": folder_entity, - "subsets": {} + "products": {} } - if product_id not in output[folder_id]["subsets"]: - output[folder_id]["subsets"][product_id] = { - "subset_doc": subset_doc, + if product_id not in output[folder_id]["products"]: + output[folder_id]["products"][product_id] = { + "product_entity": product_entity, "version": { "version_doc": version_doc, "repres": [] } } - output[folder_id]["subsets"][product_id]["version"]["repres"].append( + output[folder_id]["products"][product_id]["version"]["repres"].append( repre_doc ) diff --git a/client/ayon_core/pipeline/workfile/workfile_template_builder.py b/client/ayon_core/pipeline/workfile/workfile_template_builder.py index a39c5dd31d..07287b45c6 100644 --- a/client/ayon_core/pipeline/workfile/workfile_template_builder.py +++ b/client/ayon_core/pipeline/workfile/workfile_template_builder.py @@ -1577,6 +1577,8 @@ class PlaceholderLoadMixin(object): mapping = {} # TODO use representation context with entities + # - using 'asset', 'subset' and 'version' from context on + # representation is danger for repre_doc in representations: repre_context = repre_doc["context"] @@ -1652,16 +1654,17 @@ class PlaceholderLoadMixin(object): failed = False for repre_load_context in repre_load_contexts.values(): + folder_path = repre_load_context["folder"]["path"] + product_name = repre_load_context["product"]["name"] representation = repre_load_context["representation"] - repre_context = representation["context"] self._before_repre_load( placeholder, representation ) self.log.info( "Loading {} from {} with loader {}\n" "Loader arguments used : {}".format( - repre_context["subset"], - repre_context["asset"], + product_name, + folder_path, loader_name, placeholder.data["loader_args"], )