blaxel 0.1.14rc51__py3-none-any.whl → 0.1.14rc53__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):
blaxel/jobs/__init__.py CHANGED
@@ -27,7 +27,7 @@ class BlJob:
27
27
 
28
28
  @property
29
29
  def index_key(self) -> str:
30
- return os.getenv('BL_EXECUTION_INDEX_KEY', 'TASK_INDEX')
30
+ return os.getenv('BL_TASK_KEY', 'TASK_INDEX')
31
31
 
32
32
  @property
33
33
  def index(self) -> int:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: blaxel
3
- Version: 0.1.14rc51
3
+ Version: 0.1.14rc53
4
4
  Summary: Add your description here
5
5
  Author-email: cploujoux <cploujoux@blaxel.ai>
6
6
  License-File: LICENSE
@@ -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
@@ -270,7 +270,7 @@ blaxel/instrumentation/log.py,sha256=4tGyvLg6r4DbjqJfajYbbZ1toUzF4Q4H7kHVqYWFAEA
270
270
  blaxel/instrumentation/manager.py,sha256=jVwVasyMI6tu0zv27DVYOaN57nXYuHFJ8QzJQKaNoK4,8880
271
271
  blaxel/instrumentation/map.py,sha256=zZoiUiQHmik5WQZ4VCWNARSa6ppMi0r7D6hlb41N-Mg,1589
272
272
  blaxel/instrumentation/span.py,sha256=X2lwfu_dyxwQTMQJT2vbXOrbVSChEhjRLc413QOxQJM,3244
273
- blaxel/jobs/__init__.py,sha256=r4p2tYz8fCKzDGynLTq55KFSjdSIxhxjnarQf4hdMWI,1838
273
+ blaxel/jobs/__init__.py,sha256=xJzVGQG7hB8w7V6OL9DoDH0I2Sd8a6lF5FMjRiQefZE,1827
274
274
  blaxel/mcp/__init__.py,sha256=KednMrtuc4Y0O3lv7u1Lla54FCk8UX9c1k0USjL3Ahk,69
275
275
  blaxel/mcp/client.py,sha256=cFFXfpKXoMu8qTUly2ejF0pX2iBQkSNAxqwvDV1V6xY,4979
276
276
  blaxel/mcp/server.py,sha256=GIldtA_NgIc2dzd7ZpPvpbhpIt_7AfKu5yS_YJ0bDGg,7310
@@ -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.14rc51.dist-info/METADATA,sha256=0bHZpjz5hWC2_2kAotlLCOn7JhfJ-OcBAN1EuSBBY0o,11776
345
- blaxel-0.1.14rc51.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
346
- blaxel-0.1.14rc51.dist-info/licenses/LICENSE,sha256=p5PNQvpvyDT_0aYBDgmV1fFI_vAD2aSV0wWG7VTgRis,1069
347
- blaxel-0.1.14rc51.dist-info/RECORD,,
344
+ blaxel-0.1.14rc53.dist-info/METADATA,sha256=h6wxyBGSVQt-ShhL8f3_pgQGRAJ41SJlH0zMjnrUTmw,11776
345
+ blaxel-0.1.14rc53.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
346
+ blaxel-0.1.14rc53.dist-info/licenses/LICENSE,sha256=p5PNQvpvyDT_0aYBDgmV1fFI_vAD2aSV0wWG7VTgRis,1069
347
+ blaxel-0.1.14rc53.dist-info/RECORD,,