craft-ai-sdk 0.68.0rc2__tar.gz → 0.68.2rc1__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.

Potentially problematic release.


This version of craft-ai-sdk might be problematic. Click here for more details.

Files changed (34) hide show
  1. {craft_ai_sdk-0.68.0rc2 → craft_ai_sdk-0.68.2rc1}/PKG-INFO +1 -1
  2. {craft_ai_sdk-0.68.0rc2 → craft_ai_sdk-0.68.2rc1}/craft_ai_sdk/__init__.py +1 -1
  3. {craft_ai_sdk-0.68.0rc2 → craft_ai_sdk-0.68.2rc1}/craft_ai_sdk/core/vector_database.py +2 -1
  4. {craft_ai_sdk-0.68.0rc2 → craft_ai_sdk-0.68.2rc1}/craft_ai_sdk/sdk.py +14 -3
  5. {craft_ai_sdk-0.68.0rc2 → craft_ai_sdk-0.68.2rc1}/craft_ai_sdk/shared/authentication.py +2 -4
  6. {craft_ai_sdk-0.68.0rc2 → craft_ai_sdk-0.68.2rc1}/documentation.pdf +0 -0
  7. {craft_ai_sdk-0.68.0rc2 → craft_ai_sdk-0.68.2rc1}/pyproject.toml +1 -1
  8. {craft_ai_sdk-0.68.0rc2 → craft_ai_sdk-0.68.2rc1}/LICENSE +0 -0
  9. {craft_ai_sdk-0.68.0rc2 → craft_ai_sdk-0.68.2rc1}/README.md +0 -0
  10. {craft_ai_sdk-0.68.0rc2 → craft_ai_sdk-0.68.2rc1}/craft_ai_sdk/constants.py +0 -0
  11. {craft_ai_sdk-0.68.0rc2 → craft_ai_sdk-0.68.2rc1}/craft_ai_sdk/core/data_store.py +0 -0
  12. {craft_ai_sdk-0.68.0rc2 → craft_ai_sdk-0.68.2rc1}/craft_ai_sdk/core/deployments.py +0 -0
  13. {craft_ai_sdk-0.68.0rc2 → craft_ai_sdk-0.68.2rc1}/craft_ai_sdk/core/endpoints.py +0 -0
  14. {craft_ai_sdk-0.68.0rc2 → craft_ai_sdk-0.68.2rc1}/craft_ai_sdk/core/environment_variables.py +0 -0
  15. {craft_ai_sdk-0.68.0rc2 → craft_ai_sdk-0.68.2rc1}/craft_ai_sdk/core/pipeline_executions.py +0 -0
  16. {craft_ai_sdk-0.68.0rc2 → craft_ai_sdk-0.68.2rc1}/craft_ai_sdk/core/pipeline_metrics.py +0 -0
  17. {craft_ai_sdk-0.68.0rc2 → craft_ai_sdk-0.68.2rc1}/craft_ai_sdk/core/pipeline_templates.py +0 -0
  18. {craft_ai_sdk-0.68.0rc2 → craft_ai_sdk-0.68.2rc1}/craft_ai_sdk/core/pipelines.py +0 -0
  19. {craft_ai_sdk-0.68.0rc2 → craft_ai_sdk-0.68.2rc1}/craft_ai_sdk/core/resource_metrics.py +0 -0
  20. {craft_ai_sdk-0.68.0rc2 → craft_ai_sdk-0.68.2rc1}/craft_ai_sdk/core/steps.py +0 -0
  21. {craft_ai_sdk-0.68.0rc2 → craft_ai_sdk-0.68.2rc1}/craft_ai_sdk/core/users.py +0 -0
  22. {craft_ai_sdk-0.68.0rc2 → craft_ai_sdk-0.68.2rc1}/craft_ai_sdk/exceptions.py +0 -0
  23. {craft_ai_sdk-0.68.0rc2 → craft_ai_sdk-0.68.2rc1}/craft_ai_sdk/io.py +0 -0
  24. {craft_ai_sdk-0.68.0rc2 → craft_ai_sdk-0.68.2rc1}/craft_ai_sdk/shared/environments.py +0 -0
  25. {craft_ai_sdk-0.68.0rc2 → craft_ai_sdk-0.68.2rc1}/craft_ai_sdk/shared/execution_context.py +0 -0
  26. {craft_ai_sdk-0.68.0rc2 → craft_ai_sdk-0.68.2rc1}/craft_ai_sdk/shared/helpers.py +0 -0
  27. {craft_ai_sdk-0.68.0rc2 → craft_ai_sdk-0.68.2rc1}/craft_ai_sdk/shared/logger.py +0 -0
  28. {craft_ai_sdk-0.68.0rc2 → craft_ai_sdk-0.68.2rc1}/craft_ai_sdk/shared/request_response_handler.py +0 -0
  29. {craft_ai_sdk-0.68.0rc2 → craft_ai_sdk-0.68.2rc1}/craft_ai_sdk/shared/types.py +0 -0
  30. {craft_ai_sdk-0.68.0rc2 → craft_ai_sdk-0.68.2rc1}/craft_ai_sdk/shared/warnings.py +0 -0
  31. {craft_ai_sdk-0.68.0rc2 → craft_ai_sdk-0.68.2rc1}/craft_ai_sdk/utils/__init__.py +0 -0
  32. {craft_ai_sdk-0.68.0rc2 → craft_ai_sdk-0.68.2rc1}/craft_ai_sdk/utils/datetime_utils.py +0 -0
  33. {craft_ai_sdk-0.68.0rc2 → craft_ai_sdk-0.68.2rc1}/craft_ai_sdk/utils/dict_utils.py +0 -0
  34. {craft_ai_sdk-0.68.0rc2 → craft_ai_sdk-0.68.2rc1}/craft_ai_sdk/utils/file_utils.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: craft-ai-sdk
3
- Version: 0.68.0rc2
3
+ Version: 0.68.2rc1
4
4
  Summary: Craft AI MLOps platform SDK
5
5
  License: Apache-2.0
6
6
  Author: Craft AI
@@ -13,4 +13,4 @@ from .io import ( # noqa: F401
13
13
  )
14
14
  from .sdk import CraftAiSdk # noqa: F401
15
15
 
16
- __version__ = "0.68.0rc2"
16
+ __version__ = "0.68.2rc1"
@@ -31,7 +31,8 @@ def get_vector_database_credentials(sdk: BaseCraftAiSdk) -> VectorDatabaseCreden
31
31
 
32
32
  @log_func_result("Connecting to Weaviate")
33
33
  def get_weaviate_client(sdk: BaseCraftAiSdk):
34
- """Get the Weaviate client.
34
+ """Initializes and returns a Weaviate client for interacting with the vector
35
+ database.
35
36
 
36
37
  Returns:
37
38
  :obj:`weaviate.WeaviateClient`: The Weaviate client.
@@ -3,7 +3,7 @@ import sys
3
3
  import time
4
4
  import warnings
5
5
  from abc import ABC, abstractmethod
6
- from datetime import timedelta
6
+ from datetime import datetime, timedelta
7
7
  from typing import Any
8
8
 
9
9
  import jwt
@@ -140,8 +140,9 @@ class CraftAiSdk(BaseCraftAiSdk):
140
140
  _MULTIPART_PART_SIZE = int(
141
141
  os.environ.get("CRAFT_AI__MULTIPART_PART_SIZE__B", str(38 * 256 * 1024))
142
142
  )
143
- _access_token_margin = timedelta(seconds=30)
144
- _version = "0.68.0rc2" # Would be better to share it somewhere
143
+ # Default timeout of proxy network components
144
+ _access_token_margin = timedelta(seconds=120)
145
+ _version = "0.68.2rc1" # Would be better to share it somewhere
145
146
 
146
147
  def __init__(
147
148
  self,
@@ -285,11 +286,21 @@ class CraftAiSdk(BaseCraftAiSdk):
285
286
  return self._session.post(url, json=data)
286
287
 
287
288
  def _refresh_access_token(self):
289
+ # While a bit weird, those time calculations support any time configuration
290
+ # on the client & control. Incorrect local datetime should be supported.
291
+ token_refreshed_at = datetime.now()
288
292
  response = self._query_refresh_access_token()
289
293
  self._access_token = response["access_token"]
290
294
  self._access_token_data = jwt.decode(
291
295
  self._access_token, options={"verify_signature": False}
292
296
  )
297
+ # `exp` & `iat` are both relative to control datetime.
298
+ # Diff between them is an absolute duration
299
+ token_validity_duration = timedelta(
300
+ seconds=self._access_token_data["exp"] - self._access_token_data["iat"]
301
+ )
302
+ # Adding that duration to local time gives a local expiration time.
303
+ self._access_token_valid_until = token_refreshed_at + token_validity_duration
293
304
 
294
305
  def _clear_access_token(self):
295
306
  self._access_token = None
@@ -19,10 +19,8 @@ def use_authentication(
19
19
  @functools.wraps(action_func)
20
20
  def wrapper(sdk, *args, headers=None, **kwargs):
21
21
  actual_headers = None
22
- if (
23
- sdk._access_token_data is None
24
- or sdk._access_token_data["exp"]
25
- < (datetime.now() + sdk._access_token_margin).timestamp()
22
+ if sdk._access_token_data is None or (
23
+ datetime.now() > sdk._access_token_valid_until - sdk._access_token_margin
26
24
  ):
27
25
  sdk._refresh_access_token()
28
26
  actual_headers = {"Authorization": f"Bearer {sdk._access_token}"}
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "craft-ai-sdk"
3
- version = "0.68.0rc2"
3
+ version = "0.68.2rc1"
4
4
  description = "Craft AI MLOps platform SDK"
5
5
  license = "Apache-2.0"
6
6
  authors = ["Craft AI <contact@craft.ai>"]