craft-ai-sdk 0.68.0rc2__py3-none-any.whl → 0.68.2rc1__py3-none-any.whl

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.

craft_ai_sdk/__init__.py CHANGED
@@ -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.
craft_ai_sdk/sdk.py CHANGED
@@ -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
  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
@@ -1,4 +1,4 @@
1
- craft_ai_sdk/__init__.py,sha256=tQ-JG-V2iIWjxexEj0I_3oCwgBx3uzOfVMQgxpFtC4E,366
1
+ craft_ai_sdk/__init__.py,sha256=eFFCciMenzXHcefjgWH5c0zm394Bnnv3KxLYwpt0VwQ,366
2
2
  craft_ai_sdk/constants.py,sha256=rH4JrGlTpbjjjNRrKhk5oScbj5G5INrcVza6Bb6kIzY,980
3
3
  craft_ai_sdk/core/data_store.py,sha256=BPQalGcm6bujgkgu-MtNWWhKiJEg4MiVuCtByNbTbK8,9956
4
4
  craft_ai_sdk/core/deployments.py,sha256=Hig0Z6tZXbaLxms9ENtKI4OG3ki7G4Iz3wGk2V2Gmfg,37731
@@ -11,11 +11,11 @@ craft_ai_sdk/core/pipelines.py,sha256=FD6ai2_YhE1tz6QO57bj_lA-i93TXZzm0Y9PA0mpoc
11
11
  craft_ai_sdk/core/resource_metrics.py,sha256=ubCe6QOhud3f-EQr_TXKBsrFFaxZubqTS3fZqfV7kgg,3457
12
12
  craft_ai_sdk/core/steps.py,sha256=TwOWXAAVpLPuSZ_gvf-3E5uKEvfGIzR52Y58bqKn_Ds,23487
13
13
  craft_ai_sdk/core/users.py,sha256=q5et87q0SOMpRTBOiLX026oaEOTaY1aGqKdbUC51zbA,618
14
- craft_ai_sdk/core/vector_database.py,sha256=S3h68Ej1FnHYJdc5LdLlNjobYYdmaCloSq2UaylPWko,2334
14
+ craft_ai_sdk/core/vector_database.py,sha256=cidA9R-KL9nYR7d7VqBx8o8pIu1Rdp3XYLZn6pnwmok,2397
15
15
  craft_ai_sdk/exceptions.py,sha256=IC-JfZmmmaTsbMCgirOEByRmWnatQLjKe8BErRkuwM0,1075
16
16
  craft_ai_sdk/io.py,sha256=x1G7ga10W_SeTDLHe-FrhU26_WNwWW32-yprMmCZ5Ck,11836
17
- craft_ai_sdk/sdk.py,sha256=55KwLEN2oa57_LpLb2QTM3CXfFHY4FPwMetBAvwG9K4,11031
18
- craft_ai_sdk/shared/authentication.py,sha256=5lJS_aNphkgI0-wvHFK4aW316ZRfOq9oywNpv-Oyn2M,1062
17
+ craft_ai_sdk/sdk.py,sha256=-BuLBOOlzg7CFHimo26cMnz5Ax_eZbfZOaxKWdjOT_0,11717
18
+ craft_ai_sdk/shared/authentication.py,sha256=mnsEhG0mWwG9ZY-GToHDNnYERoou_cjt4k8l_87QW6s,1024
19
19
  craft_ai_sdk/shared/environments.py,sha256=JOV3s0KIFVl_zskJb--bybzIXEGQJjrf_T4dL-szSlQ,500
20
20
  craft_ai_sdk/shared/execution_context.py,sha256=B2Ghq-wiUvq81q5mhsm79Oc59c8c00uQxMIpApFD03o,585
21
21
  craft_ai_sdk/shared/helpers.py,sha256=5ZBiHlS-k1OgKejZgMlDJiYwIPYk7yg-lzeJI67poCc,1070
@@ -27,8 +27,8 @@ craft_ai_sdk/utils/__init__.py,sha256=A0sLCXSPD1Z3q2GP1uLDjvif4ivOr__Hzg9RQysEuq
27
27
  craft_ai_sdk/utils/datetime_utils.py,sha256=yYP5HVdI879WXxQCajPTnas1pWrwInOxMux-mxqQNQM,734
28
28
  craft_ai_sdk/utils/dict_utils.py,sha256=1HQ3A14SN48XPFDmQleujGAgksmkjIs3hyPLpwhwh24,748
29
29
  craft_ai_sdk/utils/file_utils.py,sha256=o10-CDt4qzgCJNPykvlNrL6WTouhVLY8C8BVpHJYt18,2795
30
- craft_ai_sdk-0.68.0rc2.dist-info/LICENSE,sha256=_2oYRJic9lZK05LceuJ9aZZw5mPHYc1WQhJiVS-oGFU,10754
31
- craft_ai_sdk-0.68.0rc2.dist-info/METADATA,sha256=Ss_ejMAL2d4PYxqq65vkwDBGWO9Vs-yPLhMSVY4BpY8,1679
32
- craft_ai_sdk-0.68.0rc2.dist-info/WHEEL,sha256=XbeZDeTWKc1w7CSIyre5aMDU_-PohRwTQceYnisIYYY,88
33
- craft_ai_sdk-0.68.0rc2.dist-info/entry_points.txt,sha256=QC96WcXvvUfLMRgFD-l_y7_TgC9SqZybLs9EQ8dsGiQ,417
34
- craft_ai_sdk-0.68.0rc2.dist-info/RECORD,,
30
+ craft_ai_sdk-0.68.2rc1.dist-info/LICENSE,sha256=_2oYRJic9lZK05LceuJ9aZZw5mPHYc1WQhJiVS-oGFU,10754
31
+ craft_ai_sdk-0.68.2rc1.dist-info/METADATA,sha256=DbN2rnk6mZMqGMKju5vc0tPeAW6yQ51OX63LxQOleEg,1679
32
+ craft_ai_sdk-0.68.2rc1.dist-info/WHEEL,sha256=XbeZDeTWKc1w7CSIyre5aMDU_-PohRwTQceYnisIYYY,88
33
+ craft_ai_sdk-0.68.2rc1.dist-info/entry_points.txt,sha256=QC96WcXvvUfLMRgFD-l_y7_TgC9SqZybLs9EQ8dsGiQ,417
34
+ craft_ai_sdk-0.68.2rc1.dist-info/RECORD,,