Ayon-Python-Api 0.1.17__tar.gz → 0.1.18__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (24) hide show
  1. {ayon-python-api-0.1.17 → ayon-python-api-0.1.18}/PKG-INFO +1 -1
  2. {ayon-python-api-0.1.17 → ayon-python-api-0.1.18}/ayon_api/entity_hub.py +11 -1
  3. {ayon-python-api-0.1.17 → ayon-python-api-0.1.18}/ayon_api/graphql_queries.py +1 -2
  4. {ayon-python-api-0.1.17 → ayon-python-api-0.1.18}/ayon_api/server_api.py +34 -17
  5. {ayon-python-api-0.1.17 → ayon-python-api-0.1.18}/ayon_api/version.py +1 -1
  6. {ayon-python-api-0.1.17 → ayon-python-api-0.1.18}/ayon_python_api.egg-info/PKG-INFO +1 -1
  7. {ayon-python-api-0.1.17 → ayon-python-api-0.1.18}/pyproject.toml +1 -1
  8. {ayon-python-api-0.1.17 → ayon-python-api-0.1.18}/LICENSE +0 -0
  9. {ayon-python-api-0.1.17 → ayon-python-api-0.1.18}/README.md +0 -0
  10. {ayon-python-api-0.1.17 → ayon-python-api-0.1.18}/ayon_api/__init__.py +0 -0
  11. {ayon-python-api-0.1.17 → ayon-python-api-0.1.18}/ayon_api/_api.py +0 -0
  12. {ayon-python-api-0.1.17 → ayon-python-api-0.1.18}/ayon_api/constants.py +0 -0
  13. {ayon-python-api-0.1.17 → ayon-python-api-0.1.18}/ayon_api/events.py +0 -0
  14. {ayon-python-api-0.1.17 → ayon-python-api-0.1.18}/ayon_api/exceptions.py +0 -0
  15. {ayon-python-api-0.1.17 → ayon-python-api-0.1.18}/ayon_api/graphql.py +0 -0
  16. {ayon-python-api-0.1.17 → ayon-python-api-0.1.18}/ayon_api/operations.py +0 -0
  17. {ayon-python-api-0.1.17 → ayon-python-api-0.1.18}/ayon_api/thumbnails.py +0 -0
  18. {ayon-python-api-0.1.17 → ayon-python-api-0.1.18}/ayon_api/utils.py +0 -0
  19. {ayon-python-api-0.1.17 → ayon-python-api-0.1.18}/ayon_python_api.egg-info/SOURCES.txt +0 -0
  20. {ayon-python-api-0.1.17 → ayon-python-api-0.1.18}/ayon_python_api.egg-info/dependency_links.txt +0 -0
  21. {ayon-python-api-0.1.17 → ayon-python-api-0.1.18}/ayon_python_api.egg-info/requires.txt +0 -0
  22. {ayon-python-api-0.1.17 → ayon-python-api-0.1.18}/ayon_python_api.egg-info/top_level.txt +0 -0
  23. {ayon-python-api-0.1.17 → ayon-python-api-0.1.18}/setup.cfg +0 -0
  24. {ayon-python-api-0.1.17 → ayon-python-api-0.1.18}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ayon-python-api
3
- Version: 0.1.17
3
+ Version: 0.1.18
4
4
  Summary: AYON Python API
5
5
  Home-page: https://github.com/ynput/ayon-python-api
6
6
  Author: ynput.io
@@ -589,12 +589,15 @@ class EntityHub(object):
589
589
  parent_id = task["folderId"]
590
590
  tasks_by_parent_id[parent_id].append(task)
591
591
 
592
+ lock_queue = collections.deque()
592
593
  hierarchy_queue = collections.deque()
593
594
  hierarchy_queue.append((None, project_entity))
594
595
  while hierarchy_queue:
595
596
  item = hierarchy_queue.popleft()
596
597
  parent_id, parent_entity = item
597
598
 
599
+ lock_queue.append(parent_entity)
600
+
598
601
  children_ids = set()
599
602
  for folder in folders_by_parent_id[parent_id]:
600
603
  folder_entity = self.add_folder(folder)
@@ -604,10 +607,16 @@ class EntityHub(object):
604
607
 
605
608
  for task in tasks_by_parent_id[parent_id]:
606
609
  task_entity = self.add_task(task)
610
+ lock_queue.append(task_entity)
607
611
  children_ids.add(task_entity.id)
608
612
 
609
613
  parent_entity.fill_children_ids(children_ids)
610
- self.lock()
614
+
615
+ # Lock entities when all are added to hub
616
+ # - lock only entities added in this method
617
+ while lock_queue:
618
+ entity = lock_queue.popleft()
619
+ entity.lock()
611
620
 
612
621
  def lock(self):
613
622
  if self._project_entity is None:
@@ -1198,6 +1207,7 @@ class BaseEntity(object):
1198
1207
  self._attribs.lock()
1199
1208
 
1200
1209
  self._immutable_for_hierarchy_cache = None
1210
+ self._created = False
1201
1211
 
1202
1212
  def _get_entity_by_id(self, entity_id):
1203
1213
  return self._entity_hub.get_entity_by_id(entity_id)
@@ -314,7 +314,6 @@ def representations_graphql_query(fields):
314
314
  def representations_parents_qraphql_query(
315
315
  version_fields, subset_fields, folder_fields
316
316
  ):
317
-
318
317
  query = GraphQlQuery("RepresentationsParentsQuery")
319
318
 
320
319
  project_name_var = query.add_variable("projectName", "String!")
@@ -388,7 +387,7 @@ def workfiles_info_graphql_query(fields):
388
387
 
389
388
 
390
389
  def events_graphql_query(fields):
391
- query = GraphQlQuery("WorkfilesInfo")
390
+ query = GraphQlQuery("Events")
392
391
  topics_var = query.add_variable("eventTopics", "[String!]")
393
392
  projects_var = query.add_variable("projectNames", "[String!]")
394
393
  states_var = query.add_variable("eventStates", "[String!]")
@@ -14,6 +14,7 @@ except ImportError:
14
14
  HTTPStatus = None
15
15
 
16
16
  import requests
17
+ from requests.exceptions import JSONDecodeError as RequestsJSONDecodeError
17
18
 
18
19
  from .constants import (
19
20
  DEFAULT_PROJECT_FIELDS,
@@ -112,9 +113,9 @@ class RestApiResponse(object):
112
113
  @property
113
114
  def data(self):
114
115
  if self._data is None:
115
- if self.status != 204:
116
+ try:
116
117
  self._data = self.orig_response.json()
117
- else:
118
+ except RequestsJSONDecodeError:
118
119
  self._data = {}
119
120
  return self._data
120
121
 
@@ -128,7 +129,10 @@ class RestApiResponse(object):
128
129
 
129
130
  @property
130
131
  def detail(self):
131
- return self.get("detail", _get_description(self))
132
+ detail = self.get("detail")
133
+ if detail:
134
+ return detail
135
+ return _get_description(self)
132
136
 
133
137
  @property
134
138
  def status_code(self):
@@ -299,14 +303,6 @@ class ServerAPI(object):
299
303
  'production').
300
304
  """
301
305
 
302
- _entity_types_link_mapping = {
303
- "folder": ("folderIds", "folders"),
304
- "task": ("taskIds", "tasks"),
305
- "subset": ("subsetIds", "subsets"),
306
- "version": ("versionIds", "versions"),
307
- "representation": ("representationIds", "representations"),
308
- }
309
-
310
306
  def __init__(
311
307
  self,
312
308
  base_url,
@@ -916,7 +912,7 @@ class ServerAPI(object):
916
912
  project_names = set(project_names)
917
913
  if not project_names:
918
914
  return
919
- filters["projectName"] = list(project_names)
915
+ filters["projectNames"] = list(project_names)
920
916
 
921
917
  if states is not None:
922
918
  states = set(states)
@@ -4514,13 +4510,34 @@ class ServerAPI(object):
4514
4510
  dict[str, list[dict[str, Any]]]: Link info by entity ids.
4515
4511
  """
4516
4512
 
4517
- mapped_type = self._entity_types_link_mapping.get(entity_type)
4518
- if not mapped_type:
4513
+ if entity_type == "folder":
4514
+ query_func = folders_graphql_query
4515
+ id_filter_key = "folderIds"
4516
+ project_sub_key = "folders"
4517
+ elif entity_type == "task":
4518
+ query_func = tasks_graphql_query
4519
+ id_filter_key = "taskIds"
4520
+ project_sub_key = "tasks"
4521
+ elif entity_type == "subset":
4522
+ query_func = subsets_graphql_query
4523
+ id_filter_key = "subsetIds"
4524
+ project_sub_key = "subsets"
4525
+ elif entity_type == "version":
4526
+ query_func = versions_graphql_query
4527
+ id_filter_key = "versionIds"
4528
+ project_sub_key = "versions"
4529
+ elif entity_type == "representation":
4530
+ query_func = representations_graphql_query
4531
+ id_filter_key = "representationIds"
4532
+ project_sub_key = "representations"
4533
+ else:
4519
4534
  raise ValueError("Unknown type \"{}\". Expected {}".format(
4520
- entity_type, ", ".join(self._entity_types_link_mapping.keys())
4535
+ entity_type,
4536
+ ", ".join(
4537
+ ("folder", "task", "subset", "version", "representation")
4538
+ )
4521
4539
  ))
4522
4540
 
4523
- id_filter_key, project_sub_key = mapped_type
4524
4541
  output = collections.defaultdict(list)
4525
4542
  filters = {
4526
4543
  "projectName": project_name
@@ -4534,7 +4551,7 @@ class ServerAPI(object):
4534
4551
  if not self._prepare_link_filters(filters, link_types, link_direction):
4535
4552
  return output
4536
4553
 
4537
- query = folders_graphql_query({"id", "links"})
4554
+ query = query_func({"id", "links"})
4538
4555
  for attr, filter_value in filters.items():
4539
4556
  query.set_variable_value(attr, filter_value)
4540
4557
 
@@ -1,2 +1,2 @@
1
1
  """Package declaring Python API for Ayon server."""
2
- __version__ = "0.1.17"
2
+ __version__ = "0.1.18"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ayon-python-api
3
- Version: 0.1.17
3
+ Version: 0.1.18
4
4
  Summary: AYON Python API
5
5
  Home-page: https://github.com/ynput/ayon-python-api
6
6
  Author: ynput.io
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "ayon_api"
3
- version = "0.1.17"
3
+ version = "0.1.18"
4
4
  description = "Python api for AYON server"
5
5
  authors = ["ynput.io <info@ynput.io>"]
6
6