blaxel 0.1.14rc52__py3-none-any.whl → 0.1.14rc54__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.
@@ -7,6 +7,7 @@ client credentials and refresh tokens.
7
7
  from dataclasses import dataclass
8
8
  from datetime import datetime, timedelta
9
9
  from typing import Generator, Optional
10
+ import time
10
11
 
11
12
  import requests
12
13
  from httpx import Request, Response
@@ -46,14 +47,17 @@ class ClientCredentials(BlaxelAuth):
46
47
  "X-Blaxel-Workspace": self.workspace_name,
47
48
  }
48
49
 
49
- def get_token(self) -> Optional[Exception]:
50
+ def _request_token(self, remaining_retries: int = 3) -> Optional[Exception]:
50
51
  """
51
- Checks if the access token needs to be refreshed and performs the refresh if necessary.
52
+ Makes the token request with recursive retry logic.
53
+
54
+ Args:
55
+ remaining_retries (int): Number of retry attempts remaining.
52
56
 
53
57
  Returns:
54
- Optional[Exception]: An exception if refreshing fails, otherwise None.
58
+ Optional[Exception]: An exception if refreshing fails after all retries, otherwise None.
55
59
  """
56
- if self.need_token():
60
+ try:
57
61
  headers = {"Authorization": f"Basic {self.credentials.client_credentials}", "Content-Type": "application/json"}
58
62
  body = {"grant_type": "client_credentials"}
59
63
  response = requests.post(f"{self.base_url}/oauth/token", headers=headers, json=body)
@@ -63,6 +67,23 @@ class ClientCredentials(BlaxelAuth):
63
67
  self.credentials.refresh_token = creds["refresh_token"]
64
68
  self.credentials.expires_in = creds["expires_in"]
65
69
  self.expires_at = datetime.now() + timedelta(seconds=self.credentials.expires_in)
70
+ return None
71
+ except Exception as e:
72
+ if remaining_retries > 0:
73
+ time.sleep(1)
74
+ return self._request_token(remaining_retries - 1)
75
+ return e
76
+
77
+ def get_token(self) -> Optional[Exception]:
78
+ """
79
+ Checks if the access token needs to be refreshed and performs the refresh if necessary.
80
+ Uses recursive retry logic for up to 3 attempts.
81
+
82
+ Returns:
83
+ Optional[Exception]: An exception if refreshing fails after all retries, otherwise None.
84
+ """
85
+ if self.need_token():
86
+ return self._request_token()
66
87
  return None
67
88
 
68
89
  def need_token(self):
@@ -1,13 +1,13 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: blaxel
3
- Version: 0.1.14rc52
3
+ Version: 0.1.14rc54
4
4
  Summary: Add your description here
5
5
  Author-email: cploujoux <cploujoux@blaxel.ai>
6
6
  License-File: LICENSE
7
7
  Requires-Python: >=3.10
8
8
  Requires-Dist: attrs>=21.3.0
9
9
  Requires-Dist: httpx>=0.27.0
10
- Requires-Dist: mcp>=1.2.1
10
+ Requires-Dist: mcp<=1.7.1
11
11
  Requires-Dist: opentelemetry-api>=1.28.0
12
12
  Requires-Dist: opentelemetry-exporter-otlp>=1.28.0
13
13
  Requires-Dist: opentelemetry-instrumentation-anthropic==0.35.0
@@ -2,7 +2,7 @@ blaxel/__init__.py,sha256=qmuJKjl5oGnjj4TbqHcJqUkKoxk4PvCsMb6-8rp67pE,159
2
2
  blaxel/agents/__init__.py,sha256=RDWkvfICIXXaQxJuuSu63jsFj_F8NBAL4U752hfN4AE,5262
3
3
  blaxel/authentication/__init__.py,sha256=tL9XKNCek5ixszTqjlKRBvidXMg4Nj6ODlBKlxxA9uk,3283
4
4
  blaxel/authentication/apikey.py,sha256=nOgLVba7EfVk3V-qm7cj-30LAL-BT7NOMIlGL9Ni1jY,1249
5
- blaxel/authentication/clientcredentials.py,sha256=SfWNuZVHZw6jjMqoBMMB4ZawmpyKbVPbOpv-JDFqzw8,3080
5
+ blaxel/authentication/clientcredentials.py,sha256=7ZrqsXTQTBmCzzrWWUl9qRqq7ZPjucBWQ6dzFCB7JT4,3804
6
6
  blaxel/authentication/devicemode.py,sha256=kWbArs4okIIDqW-ql5oV2eQRE_LpRwfadCB6LG83irw,5986
7
7
  blaxel/authentication/oauth.py,sha256=Q5J0taIK1JrvGB6BC-zz3hM77HPCNu01DPGf4l7xjPQ,1417
8
8
  blaxel/authentication/types.py,sha256=E3lmfbmZuJ4Bc_kGA0Kc0GZC02Sjha1_2CbabP7z6oo,1603
@@ -341,7 +341,7 @@ blaxel/tools/llamaindex.py,sha256=-gQ-C9V_h9a11J4ItsbWjXrCJOg0lRKsb98v9rVsNak,71
341
341
  blaxel/tools/openai.py,sha256=GuFXkj6bXEwldyVr89jEsRAi5ihZUVEVe327QuWiGNs,653
342
342
  blaxel/tools/pydantic.py,sha256=CvnNbAG_J4yBtA-XFI4lQrq3FYKjNd39hu841vZT004,1801
343
343
  blaxel/tools/types.py,sha256=YPCGJ4vZDhqR0X2H_TWtc5chQScsC32nGTQdRKJlO8Y,707
344
- blaxel-0.1.14rc52.dist-info/METADATA,sha256=ucA8WG9ZWyezcTvuD24e34rOtxxVLsUA7dFRCatPEZU,11776
345
- blaxel-0.1.14rc52.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
346
- blaxel-0.1.14rc52.dist-info/licenses/LICENSE,sha256=p5PNQvpvyDT_0aYBDgmV1fFI_vAD2aSV0wWG7VTgRis,1069
347
- blaxel-0.1.14rc52.dist-info/RECORD,,
344
+ blaxel-0.1.14rc54.dist-info/METADATA,sha256=2jL6j0mOA14FnKcDB52Qmv8Fa2VC_RxqkF_9C8OJ8rQ,11776
345
+ blaxel-0.1.14rc54.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
346
+ blaxel-0.1.14rc54.dist-info/licenses/LICENSE,sha256=p5PNQvpvyDT_0aYBDgmV1fFI_vAD2aSV0wWG7VTgRis,1069
347
+ blaxel-0.1.14rc54.dist-info/RECORD,,