diff --git a/client/ayon_core/pipeline/anatomy.py b/client/ayon_core/pipeline/anatomy.py index 55dc3c38b2..3c98727fdf 100644 --- a/client/ayon_core/pipeline/anatomy.py +++ b/client/ayon_core/pipeline/anatomy.py @@ -8,13 +8,9 @@ import numbers import six import time -from ayon_core import AYON_SERVER_ENABLED from ayon_core.settings.lib import ( get_local_settings, ) -from ayon_core.settings.constants import ( - DEFAULT_PROJECT_KEY -) from ayon_core.client import get_project, get_ayon_server_api_connection from ayon_core.lib import Logger, get_local_site_id from ayon_core.lib.path_templates import ( @@ -474,40 +470,12 @@ class Anatomy(BaseAnatomy): Returns: Union[Dict[str, str], None]): Local root overrides. """ - - if AYON_SERVER_ENABLED: - if not project_name: - return - con = get_ayon_server_api_connection() - return con.get_project_roots_for_site( - project_name, get_local_site_id() - ) - - if local_settings is None: - local_settings = get_local_settings() - - local_project_settings = local_settings.get("projects") or {} - if not local_project_settings: - return None - - # Check for roots existence in local settings first - roots_project_locals = ( - local_project_settings - .get(project_name, {}) - ) - roots_default_locals = ( - local_project_settings - .get(DEFAULT_PROJECT_KEY, {}) - ) - - # Skip rest of processing if roots are not set - if not roots_project_locals and not roots_default_locals: + if not project_name: return - - # Combine roots from local settings - roots_locals = roots_default_locals.get("studio") or {} - roots_locals.update(roots_project_locals.get("studio") or {}) - return roots_locals + con = get_ayon_server_api_connection() + return con.get_project_roots_for_site( + project_name, get_local_site_id() + ) @classmethod def _get_site_root_overrides(cls, project_name, site_name): diff --git a/client/ayon_core/pipeline/context_tools.py b/client/ayon_core/pipeline/context_tools.py index 577b732e0f..f2737f0bc2 100644 --- a/client/ayon_core/pipeline/context_tools.py +++ b/client/ayon_core/pipeline/context_tools.py @@ -10,7 +10,7 @@ import uuid import pyblish.api from pyblish.lib import MessageHandler -from ayon_core import AYON_SERVER_ENABLED, AYON_CORE_ROOT +from ayon_core import AYON_CORE_ROOT from ayon_core.host import HostBase from ayon_core.client import ( get_project, @@ -114,8 +114,7 @@ def install_host(host): _is_installed = True # Make sure global AYON connection has set site id and version - if AYON_SERVER_ENABLED: - get_ayon_server_api_connection() + get_ayon_server_api_connection() legacy_io.install() modules_manager = _get_modules_manager() diff --git a/client/ayon_core/pipeline/create/context.py b/client/ayon_core/pipeline/create/context.py index 27f0cd478a..6b94da0e5b 100644 --- a/client/ayon_core/pipeline/create/context.py +++ b/client/ayon_core/pipeline/create/context.py @@ -11,7 +11,6 @@ from contextlib import contextmanager import pyblish.logic import pyblish.api -from ayon_core import AYON_SERVER_ENABLED from ayon_core.client import ( get_assets, get_asset_by_name, @@ -931,15 +930,9 @@ class CreatedInstance: data.pop("family", None) data.pop("subset", None) - if AYON_SERVER_ENABLED: - asset_name = data.pop("asset", None) - if "folderPath" not in data: - data["folderPath"] = asset_name - - elif "folderPath" in data: - asset_name = data.pop("folderPath").split("/")[-1] - if "asset" not in data: - data["asset"] = asset_name + asset_name = data.pop("asset", None) + if "folderPath" not in data: + data["folderPath"] = asset_name # QUESTION Does it make sense to have data stored as ordered dict? self._data = collections.OrderedDict() @@ -1283,9 +1276,7 @@ class CreatedInstance: def has_set_asset(self): """Asset name is set in data.""" - if AYON_SERVER_ENABLED: - return "folderPath" in self._data - return "asset" in self._data + return "folderPath" in self._data @property def has_set_task(self): @@ -2021,13 +2012,9 @@ class CreateContext: self.host_name ) asset_name = get_asset_name_identifier(asset_doc) - if AYON_SERVER_ENABLED: - asset_name_key = "folderPath" - else: - asset_name_key = "asset" instance_data = { - asset_name_key: asset_name, + "folderPath": asset_name, "task": task_name, "family": creator.family, "variant": variant @@ -2251,11 +2238,8 @@ class CreateContext: task_names_by_asset_name = {} for instance in instances: + asset_name = instance.get("folderPath") task_name = instance.get("task") - if AYON_SERVER_ENABLED: - asset_name = instance.get("folderPath") - else: - asset_name = instance.get("asset") if asset_name: task_names_by_asset_name[asset_name] = set() if task_name: @@ -2266,13 +2250,10 @@ class CreateContext: for asset_name in task_names_by_asset_name.keys() if asset_name is not None } - fields = {"name", "data.tasks"} - if AYON_SERVER_ENABLED: - fields |= {"data.parents"} asset_docs = list(get_assets( self.project_name, asset_names=asset_names, - fields=fields + fields={"name", "data.tasks", "data.parents"} )) task_names_by_asset_name = {} @@ -2287,15 +2268,12 @@ class CreateContext: if not instance.has_valid_asset or not instance.has_valid_task: continue - if AYON_SERVER_ENABLED: - asset_name = instance["folderPath"] - if asset_name and "/" not in asset_name: - asset_docs = asset_docs_by_name.get(asset_name) - if len(asset_docs) == 1: - asset_name = get_asset_name_identifier(asset_docs[0]) - instance["folderPath"] = asset_name - else: - asset_name = instance["asset"] + asset_name = instance["folderPath"] + if asset_name and "/" not in asset_name: + asset_docs = asset_docs_by_name.get(asset_name) + if len(asset_docs) == 1: + asset_name = get_asset_name_identifier(asset_docs[0]) + instance["folderPath"] = asset_name if asset_name not in task_names_by_asset_name: instance.set_asset_invalid(True) diff --git a/client/ayon_core/pipeline/thumbnail.py b/client/ayon_core/pipeline/thumbnail.py index 5751b5adab..138ae7f547 100644 --- a/client/ayon_core/pipeline/thumbnail.py +++ b/client/ayon_core/pipeline/thumbnail.py @@ -2,7 +2,6 @@ import os import copy import logging -from ayon_core import AYON_SERVER_ENABLED from ayon_core.lib import Logger from ayon_core.client import get_project, get_ayon_server_api_connection from . import legacy_io @@ -145,8 +144,6 @@ class ServerThumbnailResolver(ThumbnailResolver): return cls._cache def process(self, thumbnail_entity, thumbnail_type): - if not AYON_SERVER_ENABLED: - return None data = thumbnail_entity["data"] entity_type = data.get("entity_type") entity_id = data.get("entity_id") diff --git a/client/ayon_core/pipeline/workfile/workfile_template_builder.py b/client/ayon_core/pipeline/workfile/workfile_template_builder.py index 244ab072fa..30f82c9164 100644 --- a/client/ayon_core/pipeline/workfile/workfile_template_builder.py +++ b/client/ayon_core/pipeline/workfile/workfile_template_builder.py @@ -18,12 +18,14 @@ import copy from abc import ABCMeta, abstractmethod import six +from ayon_api import get_products, get_last_versions +from ayon_api.graphql_queries import folders_graphql_query -from ayon_core import AYON_SERVER_ENABLED from ayon_core.client import ( get_asset_by_name, get_linked_assets, get_representations, + get_ayon_server_api_connection, ) from ayon_core.settings import ( get_project_settings, @@ -1273,44 +1275,25 @@ class PlaceholderLoadMixin(object): # Sort for readability families = list(sorted(families)) - if AYON_SERVER_ENABLED: - builder_type_enum_items = [ - {"label": "Current folder", "value": "context_folder"}, - # TODO implement linked folders - # {"label": "Linked folders", "value": "linked_folders"}, - {"label": "All folders", "value": "all_folders"}, - ] - build_type_label = "Folder Builder Type" - build_type_help = ( - "Folder Builder Type\n" - "\nBuilder type describe what template loader will look" - " for." - "\nCurrent Folder: Template loader will look for products" - " of current context folder (Folder /assets/bob will" - " find asset)" - "\nAll folders: All folders matching the regex will be" - " used." - ) - else: - builder_type_enum_items = [ - {"label": "Current asset", "value": "context_asset"}, - {"label": "Linked assets", "value": "linked_asset"}, - {"label": "All assets", "value": "all_assets"}, - ] - build_type_label = "Asset Builder Type" - build_type_help = ( - "Asset Builder Type\n" - "\nBuilder type describe what template loader will look" - " for." - "\ncontext_asset : Template loader will look for subsets" - " of current context asset (Asset bob will find asset)" - "\nlinked_asset : Template loader will look for assets" - " linked to current context asset." - "\nLinked asset are looked in database under" - " field \"inputLinks\"" - ) + builder_type_enum_items = [ + {"label": "Current folder", "value": "context_folder"}, + # TODO implement linked folders + # {"label": "Linked folders", "value": "linked_folders"}, + {"label": "All folders", "value": "all_folders"}, + ] + build_type_label = "Folder Builder Type" + build_type_help = ( + "Folder Builder Type\n" + "\nBuilder type describe what template loader will look" + " for." + "\nCurrent Folder: Template loader will look for products" + " of current context folder (Folder /assets/bob will" + " find asset)" + "\nAll folders: All folders matching the regex will be" + " used." + ) - attr_defs = [ + return [ attribute_definitions.UISeparatorDef(), attribute_definitions.UILabelDef("Main attributes"), attribute_definitions.UISeparatorDef(), @@ -1376,63 +1359,27 @@ class PlaceholderLoadMixin(object): attribute_definitions.UISeparatorDef(), attribute_definitions.UILabelDef("Optional attributes"), attribute_definitions.UISeparatorDef(), - ] - if AYON_SERVER_ENABLED: - attr_defs.extend([ - attribute_definitions.TextDef( - "folder_path", - label="Folder filter", - default=options.get("folder_path"), - placeholder="regex filtering by folder path", - tooltip=( - "Filtering assets by matching" - " field regex to folder path" - ) - ), - attribute_definitions.TextDef( - "product_name", - label="Product filter", - default=options.get("product_name"), - placeholder="regex filtering by product name", - tooltip=( - "Filtering assets by matching" - " field regex to product name" - ) - ), - ]) - else: - attr_defs.extend([ - attribute_definitions.TextDef( - "asset", - label="Asset filter", - default=options.get("asset"), - placeholder="regex filtering by asset name", - tooltip=( - "Filtering assets by matching" - " field regex to asset's name" - ) - ), - attribute_definitions.TextDef( - "subset", - label="Subset filter", - default=options.get("subset"), - placeholder="regex filtering by subset name", - tooltip=( - "Filtering assets by matching" - " field regex to subset's name" - ) - ), - attribute_definitions.TextDef( - "hierarchy", - label="Hierarchy filter", - default=options.get("hierarchy"), - placeholder="regex filtering by asset's hierarchy", - tooltip=( - "Filtering assets by matching field asset's hierarchy" - ) + attribute_definitions.TextDef( + "folder_path", + label="Folder filter", + default=options.get("folder_path"), + placeholder="regex filtering by folder path", + tooltip=( + "Filtering assets by matching" + " field regex to folder path" ) - ]) - return attr_defs + ), + attribute_definitions.TextDef( + "product_name", + label="Product filter", + default=options.get("product_name"), + placeholder="regex filtering by product name", + tooltip=( + "Filtering assets by matching" + " field regex to product name" + ) + ), + ] def parse_loader_args(self, loader_args): """Helper function to parse string of loader arugments. @@ -1477,9 +1424,6 @@ class PlaceholderLoadMixin(object): list[str]: List of folder paths. """ - from ayon_api.graphql_queries import folders_graphql_query - from ayon_core.client import get_ayon_server_api_connection - query = folders_graphql_query({"id"}) folders_field = None @@ -1509,7 +1453,25 @@ class PlaceholderLoadMixin(object): for folder in parsed_data["project"]["folders"]: yield folder["id"] - def _get_representations_ayon(self, placeholder): + def _get_representations(self, placeholder): + """Prepared query of representations based on load options. + + This function is directly connected to options defined in + 'get_load_plugin_options'. + + Note: + This returns all representation documents from all versions of + matching subset. To filter for last version use + '_reduce_last_version_repre_docs'. + + Args: + placeholder (PlaceholderItem): Item which should be populated. + + Returns: + List[Dict[str, Any]]: Representation documents matching filters + from placeholder data. + """ + # An OpenPype placeholder loaded in AYON if "asset" in placeholder.data: return [] @@ -1541,8 +1503,6 @@ class PlaceholderLoadMixin(object): if not folder_ids: return [] - from ayon_api import get_products, get_last_versions - products = list(get_products( project_name, folder_ids=folder_ids, @@ -1552,8 +1512,8 @@ class PlaceholderLoadMixin(object): filtered_product_ids = set() for product in products: if ( - product_name_regex is None - or product_name_regex.match(product["name"]) + product_name_regex is None + or product_name_regex.match(product["name"]) ): filtered_product_ids.add(product["id"]) @@ -1572,77 +1532,6 @@ class PlaceholderLoadMixin(object): version_ids=version_ids )) - - def _get_representations(self, placeholder): - """Prepared query of representations based on load options. - - This function is directly connected to options defined in - 'get_load_plugin_options'. - - Note: - This returns all representation documents from all versions of - matching subset. To filter for last version use - '_reduce_last_version_repre_docs'. - - Args: - placeholder (PlaceholderItem): Item which should be populated. - - Returns: - List[Dict[str, Any]]: Representation documents matching filters - from placeholder data. - """ - - if AYON_SERVER_ENABLED: - return self._get_representations_ayon(placeholder) - - # An AYON placeholder loaded in OpenPype - if "folder_path" in placeholder.data: - return [] - - project_name = self.builder.project_name - current_asset_doc = self.builder.current_asset_doc - linked_asset_docs = self.builder.linked_asset_docs - - builder_type = placeholder.data["builder_type"] - if builder_type == "context_asset": - context_filters = { - "asset": [current_asset_doc["name"]], - "subset": [re.compile(placeholder.data["subset"])], - "hierarchy": [re.compile(placeholder.data["hierarchy"])], - "representation": [placeholder.data["representation"]], - "family": [placeholder.data["family"]] - } - - elif builder_type == "linked_asset": - asset_regex = re.compile(placeholder.data["asset"]) - linked_asset_names = [] - for asset_doc in linked_asset_docs: - asset_name = asset_doc["name"] - if asset_regex.match(asset_name): - linked_asset_names.append(asset_name) - - context_filters = { - "asset": linked_asset_names, - "subset": [re.compile(placeholder.data["subset"])], - "hierarchy": [re.compile(placeholder.data["hierarchy"])], - "representation": [placeholder.data["representation"]], - "family": [placeholder.data["family"]], - } - - else: - context_filters = { - "asset": [re.compile(placeholder.data["asset"])], - "subset": [re.compile(placeholder.data["subset"])], - "hierarchy": [re.compile(placeholder.data["hierarchy"])], - "representation": [placeholder.data["representation"]], - "family": [placeholder.data["family"]] - } - - return list(get_representations( - project_name, - context_filters=context_filters - )) - def _before_placeholder_load(self, placeholder): """Can be overridden. It's called before placeholder representations are loaded.