Ayon-Python-Api 0.4.3__tar.gz → 0.5.1__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 (23) hide show
  1. {ayon-python-api-0.4.3 → ayon-python-api-0.5.1}/PKG-INFO +1 -1
  2. {ayon-python-api-0.4.3 → ayon-python-api-0.5.1}/ayon_api/_api.py +6 -4
  3. {ayon-python-api-0.4.3 → ayon-python-api-0.5.1}/ayon_api/graphql_queries.py +1 -0
  4. {ayon-python-api-0.4.3 → ayon-python-api-0.5.1}/ayon_api/server_api.py +79 -40
  5. {ayon-python-api-0.4.3 → ayon-python-api-0.5.1}/ayon_api/version.py +1 -1
  6. {ayon-python-api-0.4.3 → ayon-python-api-0.5.1}/ayon_python_api.egg-info/PKG-INFO +1 -1
  7. {ayon-python-api-0.4.3 → ayon-python-api-0.5.1}/pyproject.toml +1 -1
  8. {ayon-python-api-0.4.3 → ayon-python-api-0.5.1}/LICENSE +0 -0
  9. {ayon-python-api-0.4.3 → ayon-python-api-0.5.1}/README.md +0 -0
  10. {ayon-python-api-0.4.3 → ayon-python-api-0.5.1}/ayon_api/__init__.py +0 -0
  11. {ayon-python-api-0.4.3 → ayon-python-api-0.5.1}/ayon_api/constants.py +0 -0
  12. {ayon-python-api-0.4.3 → ayon-python-api-0.5.1}/ayon_api/entity_hub.py +0 -0
  13. {ayon-python-api-0.4.3 → ayon-python-api-0.5.1}/ayon_api/events.py +0 -0
  14. {ayon-python-api-0.4.3 → ayon-python-api-0.5.1}/ayon_api/exceptions.py +0 -0
  15. {ayon-python-api-0.4.3 → ayon-python-api-0.5.1}/ayon_api/graphql.py +0 -0
  16. {ayon-python-api-0.4.3 → ayon-python-api-0.5.1}/ayon_api/operations.py +0 -0
  17. {ayon-python-api-0.4.3 → ayon-python-api-0.5.1}/ayon_api/utils.py +0 -0
  18. {ayon-python-api-0.4.3 → ayon-python-api-0.5.1}/ayon_python_api.egg-info/SOURCES.txt +0 -0
  19. {ayon-python-api-0.4.3 → ayon-python-api-0.5.1}/ayon_python_api.egg-info/dependency_links.txt +0 -0
  20. {ayon-python-api-0.4.3 → ayon-python-api-0.5.1}/ayon_python_api.egg-info/requires.txt +0 -0
  21. {ayon-python-api-0.4.3 → ayon-python-api-0.5.1}/ayon_python_api.egg-info/top_level.txt +0 -0
  22. {ayon-python-api-0.4.3 → ayon-python-api-0.5.1}/setup.cfg +0 -0
  23. {ayon-python-api-0.4.3 → ayon-python-api-0.5.1}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ayon-python-api
3
- Version: 0.4.3
3
+ Version: 0.5.1
4
4
  Summary: AYON Python API
5
5
  Home-page: https://github.com/ynput/ayon-python-api
6
6
  Author: ynput.io
@@ -602,12 +602,12 @@ def delete_installer(*args, **kwargs):
602
602
 
603
603
  def download_installer(*args, **kwargs):
604
604
  con = get_server_api_connection()
605
- con.download_installer(*args, **kwargs)
605
+ return con.download_installer(*args, **kwargs)
606
606
 
607
607
 
608
608
  def upload_installer(*args, **kwargs):
609
609
  con = get_server_api_connection()
610
- con.upload_installer(*args, **kwargs)
610
+ return con.upload_installer(*args, **kwargs)
611
611
 
612
612
 
613
613
  # Dependency packages
@@ -978,12 +978,14 @@ def delete_project(project_name):
978
978
 
979
979
  def get_thumbnail_by_id(project_name, thumbnail_id):
980
980
  con = get_server_api_connection()
981
- con.get_thumbnail_by_id(project_name, thumbnail_id)
981
+ return con.get_thumbnail_by_id(project_name, thumbnail_id)
982
982
 
983
983
 
984
984
  def get_thumbnail(project_name, entity_type, entity_id, thumbnail_id=None):
985
985
  con = get_server_api_connection()
986
- con.get_thumbnail(project_name, entity_type, entity_id, thumbnail_id)
986
+ return con.get_thumbnail(
987
+ project_name, entity_type, entity_id, thumbnail_id
988
+ )
987
989
 
988
990
 
989
991
  def get_folder_thumbnail(project_name, folder_id, thumbnail_id=None):
@@ -144,6 +144,7 @@ def product_types_query(fields):
144
144
  query_queue.append((k, v, field))
145
145
  return query
146
146
 
147
+
147
148
  def project_product_types_query(fields):
148
149
  query = GraphQlQuery("ProjectProductTypes")
149
150
  project_query = query.add_field("project")
@@ -655,13 +655,10 @@ class ServerAPI(object):
655
655
  as default variant.
656
656
 
657
657
  Args:
658
- variant (Literal['production', 'staging']): Settings variant name.
658
+ variant (str): Settings variant name. It is possible to use
659
+ 'production', 'staging' or name of dev bundle.
659
660
  """
660
661
 
661
- if variant not in ("production", "staging"):
662
- raise ValueError((
663
- "Invalid variant name {}. Expected 'production' or 'staging'"
664
- ).format(variant))
665
662
  self._default_settings_variant = variant
666
663
 
667
664
  default_settings_variant = property(
@@ -931,8 +928,8 @@ class ServerAPI(object):
931
928
  int(re_match.group("major")),
932
929
  int(re_match.group("minor")),
933
930
  int(re_match.group("patch")),
934
- re_match.group("prerelease"),
935
- re_match.group("buildmetadata")
931
+ re_match.group("prerelease") or "",
932
+ re_match.group("buildmetadata") or "",
936
933
  )
937
934
  return self._server_version_tuple
938
935
 
@@ -1133,31 +1130,41 @@ class ServerAPI(object):
1133
1130
 
1134
1131
  response = None
1135
1132
  new_response = None
1136
- for _ in range(max_retries):
1133
+ for retry_idx in reversed(range(max_retries)):
1137
1134
  try:
1138
1135
  response = function(url, **kwargs)
1139
1136
  break
1140
1137
 
1141
1138
  except ConnectionRefusedError:
1139
+ if retry_idx == 0:
1140
+ self.log.warning(
1141
+ "Connection error happened.", exc_info=True
1142
+ )
1143
+
1142
1144
  # Server may be restarting
1143
1145
  new_response = RestApiResponse(
1144
1146
  None,
1145
1147
  {"detail": "Unable to connect the server. Connection refused"}
1146
1148
  )
1149
+
1147
1150
  except requests.exceptions.Timeout:
1148
1151
  # Connection timed out
1149
1152
  new_response = RestApiResponse(
1150
1153
  None,
1151
1154
  {"detail": "Connection timed out."}
1152
1155
  )
1156
+
1153
1157
  except requests.exceptions.ConnectionError:
1154
- # Other connection error (ssl, etc) - does not make sense to
1155
- # try call server again
1158
+ # Log warning only on last attempt
1159
+ if retry_idx == 0:
1160
+ self.log.warning(
1161
+ "Connection error happened.", exc_info=True
1162
+ )
1163
+
1156
1164
  new_response = RestApiResponse(
1157
1165
  None,
1158
1166
  {"detail": "Unable to connect the server. Connection error"}
1159
1167
  )
1160
- break
1161
1168
 
1162
1169
  time.sleep(0.1)
1163
1170
 
@@ -1342,7 +1349,9 @@ class ServerAPI(object):
1342
1349
  status=None,
1343
1350
  description=None,
1344
1351
  summary=None,
1345
- payload=None
1352
+ payload=None,
1353
+ progress=None,
1354
+ retries=None
1346
1355
  ):
1347
1356
  kwargs = {
1348
1357
  key: value
@@ -1353,9 +1362,27 @@ class ServerAPI(object):
1353
1362
  ("description", description),
1354
1363
  ("summary", summary),
1355
1364
  ("payload", payload),
1365
+ ("progress", progress),
1366
+ ("retries", retries),
1356
1367
  )
1357
1368
  if value is not None
1358
1369
  }
1370
+ # 'progress' and 'retries' are available since 0.5.x server version
1371
+ major, minor, _, _, _ = self.server_version_tuple
1372
+ if (major, minor) < (0, 5):
1373
+ args = []
1374
+ if progress is not None:
1375
+ args.append("progress")
1376
+ if retries is not None:
1377
+ args.append("retries")
1378
+ fields = ", ".join("'{}'".format(f) for f in args)
1379
+ ending = "s" if len(args) > 1 else ""
1380
+ raise ValueError((
1381
+ "Your server version '{}' does not support update"
1382
+ " of {} field{} on event. The fields are supported since"
1383
+ " server version '0.5'."
1384
+ ).format(self.get_server_version(), fields, ending))
1385
+
1359
1386
  response = self.patch(
1360
1387
  "events/{}".format(event_id),
1361
1388
  **kwargs
@@ -1427,6 +1454,7 @@ class ServerAPI(object):
1427
1454
  description=None,
1428
1455
  sequential=None,
1429
1456
  events_filter=None,
1457
+ max_retries=None,
1430
1458
  ):
1431
1459
  """Enroll job based on events.
1432
1460
 
@@ -1468,8 +1496,12 @@ class ServerAPI(object):
1468
1496
  in target event.
1469
1497
  sequential (Optional[bool]): The source topic must be processed
1470
1498
  in sequence.
1471
- events_filter (Optional[ayon_server.sqlfilter.Filter]): A dict-like
1472
- with conditions to filter the source event.
1499
+ events_filter (Optional[dict[str, Any]]): Filtering conditions
1500
+ to filter the source event. For more technical specifications
1501
+ look to server backed 'ayon_server.sqlfilter.Filter'.
1502
+ TODO: Add example of filters.
1503
+ max_retries (Optional[int]): How many times can be event retried.
1504
+ Default value is based on server (3 at the time of this PR).
1473
1505
 
1474
1506
  Returns:
1475
1507
  Union[None, dict[str, Any]]: None if there is no event matching
@@ -1480,6 +1512,7 @@ class ServerAPI(object):
1480
1512
  "sourceTopic": source_topic,
1481
1513
  "targetTopic": target_topic,
1482
1514
  "sender": sender,
1515
+ "maxRetries": max_retries,
1483
1516
  }
1484
1517
  if sequential is not None:
1485
1518
  kwargs["sequential"] = sequential
@@ -2229,6 +2262,34 @@ class ServerAPI(object):
2229
2262
  response.raise_for_status("Failed to create/update dependency")
2230
2263
  return response.data
2231
2264
 
2265
+ def _get_dependency_package_route(
2266
+ self, filename=None, platform_name=None
2267
+ ):
2268
+ major, minor, patch, _, _ = self.server_version_tuple
2269
+ if (major, minor, patch) <= (0, 2, 0):
2270
+ # Backwards compatibility for AYON server 0.2.0 and lower
2271
+ self.log.warning((
2272
+ "Using deprecated dependency package route."
2273
+ " Please update your AYON server to version 0.2.1 or higher."
2274
+ " Backwards compatibility for this route will be removed"
2275
+ " in future releases of ayon-python-api."
2276
+ ))
2277
+ if platform_name is None:
2278
+ platform_name = platform.system().lower()
2279
+ base = "dependencies"
2280
+ if not filename:
2281
+ return base
2282
+ return "{}/{}/{}".format(base, filename, platform_name)
2283
+
2284
+ if (major, minor) <= (0, 3):
2285
+ endpoint = "desktop/dependency_packages"
2286
+ else:
2287
+ endpoint = "desktop/dependencyPackages"
2288
+
2289
+ if filename:
2290
+ return "{}/{}".format(endpoint, filename)
2291
+ return endpoint
2292
+
2232
2293
  def get_dependency_packages(self):
2233
2294
  """Information about dependency packages on server.
2234
2295
 
@@ -2256,33 +2317,11 @@ class ServerAPI(object):
2256
2317
  server.
2257
2318
  """
2258
2319
 
2259
- endpoint = "desktop/dependencyPackages"
2260
- major, minor, _, _, _ = self.server_version_tuple
2261
- if major == 0 and minor <= 3:
2262
- endpoint = "desktop/dependency_packages"
2263
-
2320
+ endpoint = self._get_dependency_package_route()
2264
2321
  result = self.get(endpoint)
2265
2322
  result.raise_for_status()
2266
2323
  return result.data
2267
2324
 
2268
- def _get_dependency_package_route(
2269
- self, filename=None, platform_name=None
2270
- ):
2271
- major, minor, patch, _, _ = self.server_version_tuple
2272
- if major == 0 and (minor > 2 or (minor == 2 and patch >= 1)):
2273
- base = "desktop/dependency_packages"
2274
- if not filename:
2275
- return base
2276
- return "{}/{}".format(base, filename)
2277
-
2278
- # Backwards compatibility for AYON server 0.2.0 and lower
2279
- if platform_name is None:
2280
- platform_name = platform.system().lower()
2281
- base = "dependencies"
2282
- if not filename:
2283
- return base
2284
- return "{}/{}/{}".format(base, filename, platform_name)
2285
-
2286
2325
  def create_dependency_package(
2287
2326
  self,
2288
2327
  filename,
@@ -4323,9 +4362,6 @@ class ServerAPI(object):
4323
4362
  fields.remove("attrib")
4324
4363
  fields |= self.get_attributes_fields_for_type("version")
4325
4364
 
4326
- if active is not None:
4327
- fields.add("active")
4328
-
4329
4365
  # Make sure fields have minimum required fields
4330
4366
  fields |= {"id", "version"}
4331
4367
 
@@ -4334,6 +4370,9 @@ class ServerAPI(object):
4334
4370
  use_rest = True
4335
4371
  fields = {"id"}
4336
4372
 
4373
+ if active is not None:
4374
+ fields.add("active")
4375
+
4337
4376
  if own_attributes:
4338
4377
  fields.add("ownAttrib")
4339
4378
 
@@ -1,2 +1,2 @@
1
1
  """Package declaring Python API for Ayon server."""
2
- __version__ = "0.4.3"
2
+ __version__ = "0.5.1"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ayon-python-api
3
- Version: 0.4.3
3
+ Version: 0.5.1
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
  [project]
2
2
  name = "ayon-python-api"
3
- version = "0.4.3"
3
+ version = "0.5.1"
4
4
  description = "AYON Python API"
5
5
  license = {file = "LICENSE"}
6
6
  readme = {file = "README.md", content-type = "text/markdown"}
File without changes