AYON: General fixes and updates (#4975)

* fix color conversion of maya load colors

* this seems to have been accidentally switched before, if there are no versions, return nothing, if there are, return something

* maya failed to run the userSetup due to the variable having been changed to settings

* fix representation fields conversion

* fix missing legacy io

* fix tools env conversion

* Updated AYON python api

---------

Co-authored-by: Sveinbjorn J. Tryggvason <sveinbjorn@rvx.is>
This commit is contained in:
Jakub Trllo 2023-05-17 12:46:57 +02:00 committed by Jakub Trllo
parent 1ff18dc4f3
commit c360d0b28d
8 changed files with 35 additions and 20 deletions

View file

@ -177,6 +177,9 @@ def convert_v4_project_to_v3(project):
for app_name in apps_attr
]
data.update(attribs)
if "tools" in data:
data["tools_env"] = data.pop("tools")
data["entityType"] = "Project"
config = {}
@ -357,6 +360,9 @@ def convert_v4_folder_to_v3(folder, project_name):
if "attrib" in folder:
output_data.update(folder["attrib"])
if "tools" in output_data:
output_data["tools_env"] = output_data.pop("tools")
if "tasks" in folder:
output_data["tasks"] = convert_v4_tasks_to_v3(folder["tasks"])
@ -600,7 +606,7 @@ def representation_fields_v3_to_v4(fields, con):
output |= REPRESENTATION_FILES_FIELDS
elif field.startswith("data"):
fields |= {
output |= {
"attrib.{}".format(attr)
for attr in representation_attributes
}

View file

@ -391,8 +391,8 @@ def get_last_version_by_subset_id(project_name, subset_id, fields=None):
fields=fields
)
if not versions:
return versions[0]
return None
return None
return versions[0]
def get_last_version_by_subset_name(

View file

@ -16,7 +16,7 @@ project_name = get_current_project_name()
settings = get_project_settings(project_name)
# Loading plugins explicitly.
explicit_plugins_loading = project_settings["maya"]["explicit_plugins_loading"]
explicit_plugins_loading = settings["maya"]["explicit_plugins_loading"]
if explicit_plugins_loading["enabled"]:
def _explicit_load_plugins():
for plugin in explicit_plugins_loading["plugins_to_load"]:

View file

@ -539,6 +539,10 @@ def _convert_maya_project_settings(ayon_settings, output):
_convert_host_imageio(ayon_maya)
load_colors = ayon_maya["load"]["colors"]
for key, color in tuple(load_colors.items()):
load_colors[key] = _convert_color(color)
output["maya"] = ayon_maya

View file

@ -589,12 +589,15 @@ class EntityHub(object):
parent_id = task["folderId"]
tasks_by_parent_id[parent_id].append(task)
lock_queue = collections.deque()
hierarchy_queue = collections.deque()
hierarchy_queue.append((None, project_entity))
while hierarchy_queue:
item = hierarchy_queue.popleft()
parent_id, parent_entity = item
lock_queue.append(parent_entity)
children_ids = set()
for folder in folders_by_parent_id[parent_id]:
folder_entity = self.add_folder(folder)
@ -604,10 +607,16 @@ class EntityHub(object):
for task in tasks_by_parent_id[parent_id]:
task_entity = self.add_task(task)
lock_queue.append(task_entity)
children_ids.add(task_entity.id)
parent_entity.fill_children_ids(children_ids)
self.lock()
# Lock entities when all are added to hub
# - lock only entities added in this method
while lock_queue:
entity = lock_queue.popleft()
entity.lock()
def lock(self):
if self._project_entity is None:
@ -1198,6 +1207,7 @@ class BaseEntity(object):
self._attribs.lock()
self._immutable_for_hierarchy_cache = None
self._created = False
def _get_entity_by_id(self, entity_id):
return self._entity_hub.get_entity_by_id(entity_id)

View file

@ -314,7 +314,6 @@ def representations_graphql_query(fields):
def representations_parents_qraphql_query(
version_fields, subset_fields, folder_fields
):
query = GraphQlQuery("RepresentationsParentsQuery")
project_name_var = query.add_variable("projectName", "String!")
@ -388,7 +387,7 @@ def workfiles_info_graphql_query(fields):
def events_graphql_query(fields):
query = GraphQlQuery("WorkfilesInfo")
query = GraphQlQuery("Events")
topics_var = query.add_variable("eventTopics", "[String!]")
projects_var = query.add_variable("projectNames", "[String!]")
states_var = query.add_variable("eventStates", "[String!]")

View file

@ -14,6 +14,7 @@ except ImportError:
HTTPStatus = None
import requests
from requests.exceptions import JSONDecodeError as RequestsJSONDecodeError
from .constants import (
DEFAULT_PROJECT_FIELDS,
@ -112,9 +113,9 @@ class RestApiResponse(object):
@property
def data(self):
if self._data is None:
if self.status != 204:
try:
self._data = self.orig_response.json()
else:
except RequestsJSONDecodeError:
self._data = {}
return self._data
@ -128,7 +129,10 @@ class RestApiResponse(object):
@property
def detail(self):
return self.get("detail", _get_description(self))
detail = self.get("detail")
if detail:
return detail
return _get_description(self)
@property
def status_code(self):
@ -299,14 +303,6 @@ class ServerAPI(object):
'production').
"""
_entity_types_link_mapping = {
"folder": ("folderIds", "folders"),
"task": ("taskIds", "tasks"),
"subset": ("subsetIds", "subsets"),
"version": ("versionIds", "versions"),
"representation": ("representationIds", "representations"),
}
def __init__(
self,
base_url,
@ -916,7 +912,7 @@ class ServerAPI(object):
project_names = set(project_names)
if not project_names:
return
filters["projectName"] = list(project_names)
filters["projectNames"] = list(project_names)
if states is not None:
states = set(states)

View file

@ -1,2 +1,2 @@
"""Package declaring Python API for Ayon server."""
__version__ = "0.1.17-1"
__version__ = "0.1.18"