mirror of
https://github.com/ynput/ayon-core.git
synced 2026-01-01 08:24:53 +01:00
use 'get_ayon_server_api_connection' in server functions
This commit is contained in:
parent
1e0f449239
commit
8e0513fe54
3 changed files with 25 additions and 27 deletions
|
|
@ -1,9 +1,8 @@
|
|||
import collections
|
||||
|
||||
from ayon_api import get_server_api_connection
|
||||
|
||||
from openpype.client.mongo.operations import CURRENT_THUMBNAIL_SCHEMA
|
||||
|
||||
from .utils import get_ayon_server_api_connection
|
||||
from .openpype_comp import get_folders_with_tasks
|
||||
from .conversion_utils import (
|
||||
project_fields_v3_to_v4,
|
||||
|
|
@ -37,7 +36,7 @@ def get_projects(active=True, inactive=False, library=None, fields=None):
|
|||
elif inactive:
|
||||
active = False
|
||||
|
||||
con = get_server_api_connection()
|
||||
con = get_ayon_server_api_connection()
|
||||
fields = project_fields_v3_to_v4(fields, con)
|
||||
for project in con.get_projects(active, library, fields=fields):
|
||||
yield convert_v4_project_to_v3(project)
|
||||
|
|
@ -45,7 +44,7 @@ def get_projects(active=True, inactive=False, library=None, fields=None):
|
|||
|
||||
def get_project(project_name, active=True, inactive=False, fields=None):
|
||||
# Skip if both are disabled
|
||||
con = get_server_api_connection()
|
||||
con = get_ayon_server_api_connection()
|
||||
fields = project_fields_v3_to_v4(fields, con)
|
||||
return convert_v4_project_to_v3(
|
||||
con.get_project(project_name, fields=fields)
|
||||
|
|
@ -66,7 +65,7 @@ def _get_subsets(
|
|||
fields=None
|
||||
):
|
||||
# Convert fields and add minimum required fields
|
||||
con = get_server_api_connection()
|
||||
con = get_ayon_server_api_connection()
|
||||
fields = subset_fields_v3_to_v4(fields, con)
|
||||
if fields is not None:
|
||||
for key in (
|
||||
|
|
@ -102,7 +101,7 @@ def _get_versions(
|
|||
active=None,
|
||||
fields=None
|
||||
):
|
||||
con = get_server_api_connection()
|
||||
con = get_ayon_server_api_connection()
|
||||
|
||||
fields = version_fields_v3_to_v4(fields, con)
|
||||
|
||||
|
|
@ -198,7 +197,7 @@ def get_assets(
|
|||
if archived:
|
||||
active = None
|
||||
|
||||
con = get_server_api_connection()
|
||||
con = get_ayon_server_api_connection()
|
||||
fields = folder_fields_v3_to_v4(fields, con)
|
||||
kwargs = dict(
|
||||
folder_ids=asset_ids,
|
||||
|
|
@ -236,7 +235,7 @@ def get_archived_assets(
|
|||
|
||||
|
||||
def get_asset_ids_with_subsets(project_name, asset_ids=None):
|
||||
con = get_server_api_connection()
|
||||
con = get_ayon_server_api_connection()
|
||||
return con.get_folder_ids_with_products(project_name, asset_ids)
|
||||
|
||||
|
||||
|
|
@ -282,7 +281,7 @@ def get_subsets(
|
|||
|
||||
|
||||
def get_subset_families(project_name, subset_ids=None):
|
||||
con = get_server_api_connection()
|
||||
con = get_ayon_server_api_connection()
|
||||
return con.get_product_type_names(project_name, subset_ids)
|
||||
|
||||
|
||||
|
|
@ -430,7 +429,7 @@ def get_output_link_versions(project_name, version_id, fields=None):
|
|||
if not version_id:
|
||||
return []
|
||||
|
||||
con = get_server_api_connection()
|
||||
con = get_ayon_server_api_connection()
|
||||
version_links = con.get_version_links(
|
||||
project_name, version_id, link_direction="out")
|
||||
|
||||
|
|
@ -446,7 +445,7 @@ def get_output_link_versions(project_name, version_id, fields=None):
|
|||
|
||||
|
||||
def version_is_latest(project_name, version_id):
|
||||
con = get_server_api_connection()
|
||||
con = get_ayon_server_api_connection()
|
||||
return con.version_is_latest(project_name, version_id)
|
||||
|
||||
|
||||
|
|
@ -501,7 +500,7 @@ def get_representations(
|
|||
else:
|
||||
active = None
|
||||
|
||||
con = get_server_api_connection()
|
||||
con = get_ayon_server_api_connection()
|
||||
fields = representation_fields_v3_to_v4(fields, con)
|
||||
if fields and active is not None:
|
||||
fields.add("active")
|
||||
|
|
@ -535,7 +534,7 @@ def get_representations_parents(project_name, representations):
|
|||
repre["_id"]
|
||||
for repre in representations
|
||||
}
|
||||
con = get_server_api_connection()
|
||||
con = get_ayon_server_api_connection()
|
||||
parents_by_repre_id = con.get_representations_parents(project_name,
|
||||
repre_ids)
|
||||
folder_ids = set()
|
||||
|
|
@ -677,7 +676,7 @@ def get_workfile_info(
|
|||
if not asset_id or not task_name or not filename:
|
||||
return None
|
||||
|
||||
con = get_server_api_connection()
|
||||
con = get_ayon_server_api_connection()
|
||||
task = con.get_task_by_name(
|
||||
project_name, asset_id, task_name, fields=["id", "name", "folderId"]
|
||||
)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,4 @@
|
|||
import ayon_api
|
||||
from ayon_api import get_folder_links, get_versions_links
|
||||
|
||||
from .utils import get_ayon_server_api_connection
|
||||
from .entities import get_assets, get_representation_by_id
|
||||
|
||||
|
||||
|
|
@ -28,7 +26,8 @@ def get_linked_asset_ids(project_name, asset_doc=None, asset_id=None):
|
|||
if not asset_id:
|
||||
asset_id = asset_doc["_id"]
|
||||
|
||||
links = get_folder_links(project_name, asset_id, link_direction="in")
|
||||
con = get_ayon_server_api_connection()
|
||||
links = con.get_folder_links(project_name, asset_id, link_direction="in")
|
||||
return [
|
||||
link["entityId"]
|
||||
for link in links
|
||||
|
|
@ -115,6 +114,7 @@ def get_linked_representation_id(
|
|||
if link_type:
|
||||
link_types = [link_type]
|
||||
|
||||
con = get_ayon_server_api_connection()
|
||||
# Store already found version ids to avoid recursion, and also to store
|
||||
# output -> Don't forget to remove 'version_id' at the end!!!
|
||||
linked_version_ids = {version_id}
|
||||
|
|
@ -124,7 +124,7 @@ def get_linked_representation_id(
|
|||
if not versions_to_check:
|
||||
break
|
||||
|
||||
links = get_versions_links(
|
||||
links = con.get_versions_links(
|
||||
project_name,
|
||||
versions_to_check,
|
||||
link_types=link_types,
|
||||
|
|
@ -145,8 +145,8 @@ def get_linked_representation_id(
|
|||
linked_version_ids.remove(version_id)
|
||||
if not linked_version_ids:
|
||||
return []
|
||||
|
||||
representations = ayon_api.get_representations(
|
||||
con = get_ayon_server_api_connection()
|
||||
representations = con.get_representations(
|
||||
project_name,
|
||||
version_ids=linked_version_ids,
|
||||
fields=["id"])
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ import uuid
|
|||
import datetime
|
||||
|
||||
from bson.objectid import ObjectId
|
||||
from ayon_api import get_server_api_connection
|
||||
|
||||
from openpype.client.operations_base import (
|
||||
REMOVED_VALUE,
|
||||
|
|
@ -41,7 +40,7 @@ from .conversion_utils import (
|
|||
convert_update_representation_to_v4,
|
||||
convert_update_workfile_info_to_v4,
|
||||
)
|
||||
from .utils import create_entity_id
|
||||
from .utils import create_entity_id, get_ayon_server_api_connection
|
||||
|
||||
|
||||
def _create_or_convert_to_id(entity_id=None):
|
||||
|
|
@ -680,7 +679,7 @@ class OperationsSession(BaseOperationsSession):
|
|||
def __init__(self, con=None, *args, **kwargs):
|
||||
super(OperationsSession, self).__init__(*args, **kwargs)
|
||||
if con is None:
|
||||
con = get_server_api_connection()
|
||||
con = get_ayon_server_api_connection()
|
||||
self._con = con
|
||||
self._project_cache = {}
|
||||
self._nested_operations = collections.defaultdict(list)
|
||||
|
|
@ -858,7 +857,7 @@ def create_project(
|
|||
"""
|
||||
|
||||
if con is None:
|
||||
con = get_server_api_connection()
|
||||
con = get_ayon_server_api_connection()
|
||||
|
||||
return con.create_project(
|
||||
project_name,
|
||||
|
|
@ -870,12 +869,12 @@ def create_project(
|
|||
|
||||
def delete_project(project_name, con=None):
|
||||
if con is None:
|
||||
con = get_server_api_connection()
|
||||
con = get_ayon_server_api_connection()
|
||||
|
||||
return con.delete_project(project_name)
|
||||
|
||||
|
||||
def create_thumbnail(project_name, src_filepath, thumbnail_id=None, con=None):
|
||||
if con is None:
|
||||
con = get_server_api_connection()
|
||||
con = get_ayon_server_api_connection()
|
||||
return con.create_thumbnail(project_name, src_filepath, thumbnail_id)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue