Ayon-Python-Api 0.1.15__tar.gz → 0.1.16__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.15 → ayon-python-api-0.1.16}/PKG-INFO +1 -1
  2. {ayon-python-api-0.1.15 → ayon-python-api-0.1.16}/ayon_api/entity_hub.py +1 -0
  3. {ayon-python-api-0.1.15 → ayon-python-api-0.1.16}/ayon_api/server_api.py +30 -18
  4. {ayon-python-api-0.1.15 → ayon-python-api-0.1.16}/ayon_api/version.py +1 -1
  5. {ayon-python-api-0.1.15 → ayon-python-api-0.1.16}/ayon_python_api.egg-info/PKG-INFO +1 -1
  6. {ayon-python-api-0.1.15 → ayon-python-api-0.1.16}/pyproject.toml +1 -1
  7. {ayon-python-api-0.1.15 → ayon-python-api-0.1.16}/LICENSE +0 -0
  8. {ayon-python-api-0.1.15 → ayon-python-api-0.1.16}/README.md +0 -0
  9. {ayon-python-api-0.1.15 → ayon-python-api-0.1.16}/ayon_api/__init__.py +0 -0
  10. {ayon-python-api-0.1.15 → ayon-python-api-0.1.16}/ayon_api/_api.py +0 -0
  11. {ayon-python-api-0.1.15 → ayon-python-api-0.1.16}/ayon_api/constants.py +0 -0
  12. {ayon-python-api-0.1.15 → ayon-python-api-0.1.16}/ayon_api/events.py +0 -0
  13. {ayon-python-api-0.1.15 → ayon-python-api-0.1.16}/ayon_api/exceptions.py +0 -0
  14. {ayon-python-api-0.1.15 → ayon-python-api-0.1.16}/ayon_api/graphql.py +0 -0
  15. {ayon-python-api-0.1.15 → ayon-python-api-0.1.16}/ayon_api/graphql_queries.py +0 -0
  16. {ayon-python-api-0.1.15 → ayon-python-api-0.1.16}/ayon_api/operations.py +0 -0
  17. {ayon-python-api-0.1.15 → ayon-python-api-0.1.16}/ayon_api/thumbnails.py +0 -0
  18. {ayon-python-api-0.1.15 → ayon-python-api-0.1.16}/ayon_api/utils.py +0 -0
  19. {ayon-python-api-0.1.15 → ayon-python-api-0.1.16}/ayon_python_api.egg-info/SOURCES.txt +0 -0
  20. {ayon-python-api-0.1.15 → ayon-python-api-0.1.16}/ayon_python_api.egg-info/dependency_links.txt +0 -0
  21. {ayon-python-api-0.1.15 → ayon-python-api-0.1.16}/ayon_python_api.egg-info/requires.txt +0 -0
  22. {ayon-python-api-0.1.15 → ayon-python-api-0.1.16}/ayon_python_api.egg-info/top_level.txt +0 -0
  23. {ayon-python-api-0.1.15 → ayon-python-api-0.1.16}/setup.cfg +0 -0
  24. {ayon-python-api-0.1.15 → ayon-python-api-0.1.16}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ayon-python-api
3
- Version: 0.1.15
3
+ Version: 0.1.16
4
4
  Summary: AYON Python API
5
5
  Home-page: https://github.com/ynput/ayon-python-api
6
6
  Author: ynput.io
@@ -673,6 +673,7 @@ class EntityHub(object):
673
673
  if entity_id in processed_ids:
674
674
  continue
675
675
  entity = self._entities_by_id[entity_id]
676
+ processed_ids.add(entity_id)
676
677
  operations_body.append(self._get_create_body(entity))
677
678
 
678
679
  for entity_id in reversed(removed_entity_ids):
@@ -4156,7 +4156,13 @@ class ServerAPI(object):
4156
4156
  "Failed to create thumbnail.{}".format(details))
4157
4157
  return response.data["id"]
4158
4158
 
4159
- def send_batch_operations(self, project_name, operations, can_fail=False):
4159
+ def send_batch_operations(
4160
+ self,
4161
+ project_name,
4162
+ operations,
4163
+ can_fail=False,
4164
+ raise_on_fail=True
4165
+ ):
4160
4166
  """Post multiple CRUD operations to server.
4161
4167
 
4162
4168
  When multiple changes should be made on server side this is the best
@@ -4169,28 +4175,32 @@ class ServerAPI(object):
4169
4175
  operations (list[dict[str, Any]]): Operations to be processed.
4170
4176
  can_fail (bool): Server will try to process all operations even if
4171
4177
  one of them fails.
4178
+ raise_on_fail (bool): Raise exception if an operation fails.
4179
+ You can handle failed operations on your own when set to
4180
+ 'False'.
4172
4181
 
4173
4182
  Raises:
4174
- FailedOperations: When one or more operations fail.
4183
+ ValueError: Operations can't be converted to json string.
4184
+ FailedOperations: When output does not contain server operations
4185
+ or 'raise_on_fail' is enabled and any operation fails.
4186
+
4187
+ Returns:
4188
+ list[dict[str, Any]]: Operations result with process details.
4175
4189
  """
4176
4190
 
4177
4191
  if not operations:
4178
- return
4192
+ return []
4179
4193
 
4180
4194
  body_by_id = {}
4195
+ operations_body = []
4181
4196
  for operation in operations:
4182
4197
  if not operation:
4183
4198
  continue
4199
+
4184
4200
  op_id = operation.get("id")
4185
4201
  if not op_id:
4186
4202
  op_id = create_entity_id()
4187
4203
  operation["id"] = op_id
4188
- body_by_id[op_id] = operation
4189
-
4190
- operations_body = []
4191
- for operation in operations:
4192
- if not operation:
4193
- continue
4194
4204
 
4195
4205
  try:
4196
4206
  body = json.loads(
@@ -4203,11 +4213,11 @@ class ServerAPI(object):
4203
4213
  )
4204
4214
  ))
4205
4215
 
4206
- body_by_id[operation["id"]] = body
4216
+ body_by_id[op_id] = body
4207
4217
  operations_body.append(body)
4208
4218
 
4209
4219
  if not operations_body:
4210
- return
4220
+ return []
4211
4221
 
4212
4222
  result = self.post(
4213
4223
  "projects/{}/operations".format(project_name),
@@ -4215,21 +4225,23 @@ class ServerAPI(object):
4215
4225
  canFail=can_fail
4216
4226
  )
4217
4227
 
4218
- if result.get("success"):
4219
- return
4220
-
4221
- if "operations" not in result:
4228
+ op_results = result.get("operations")
4229
+ if op_results is None:
4222
4230
  raise FailedOperations(
4223
4231
  "Operation failed. Content: {}".format(str(result))
4224
4232
  )
4225
4233
 
4226
- for op_result in result["operations"]:
4234
+ if result.get("success") or not raise_on_fail:
4235
+ return op_results
4236
+
4237
+ for op_result in op_results:
4227
4238
  if not op_result["success"]:
4228
4239
  operation_id = op_result["id"]
4229
4240
  raise FailedOperations((
4230
- "Operation \"{}\" failed with data:\n{}\nError: {}."
4241
+ "Operation \"{}\" failed with data:\n{}\nDetail: {}."
4231
4242
  ).format(
4232
4243
  operation_id,
4233
4244
  json.dumps(body_by_id[operation_id], indent=4),
4234
- op_result["error"],
4245
+ op_result["detail"],
4235
4246
  ))
4247
+ return op_results
@@ -1,2 +1,2 @@
1
1
  """Package declaring Python API for Ayon server."""
2
- __version__ = "0.1.15"
2
+ __version__ = "0.1.16"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ayon-python-api
3
- Version: 0.1.15
3
+ Version: 0.1.16
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.15"
3
+ version = "0.1.16"
4
4
  description = "Python api for AYON server"
5
5
  authors = ["ynput.io <info@ynput.io>"]
6
6