blaxel 0.2.7rc81__py3-none-any.whl → 0.2.7rc82__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.
- blaxel/core/authentication/__init__.py +16 -15
- {blaxel-0.2.7rc81.dist-info → blaxel-0.2.7rc82.dist-info}/METADATA +1 -1
- {blaxel-0.2.7rc81.dist-info → blaxel-0.2.7rc82.dist-info}/RECORD +5 -5
- {blaxel-0.2.7rc81.dist-info → blaxel-0.2.7rc82.dist-info}/WHEEL +0 -0
- {blaxel-0.2.7rc81.dist-info → blaxel-0.2.7rc82.dist-info}/licenses/LICENSE +0 -0
@@ -12,6 +12,7 @@ from .types import BlaxelAuth, CredentialsType
|
|
12
12
|
|
13
13
|
logger = getLogger(__name__)
|
14
14
|
|
15
|
+
|
15
16
|
def get_credentials() -> Optional[CredentialsType]:
|
16
17
|
"""
|
17
18
|
Get credentials from environment variables or config file.
|
@@ -19,35 +20,34 @@ def get_credentials() -> Optional[CredentialsType]:
|
|
19
20
|
Returns:
|
20
21
|
Optional[CredentialsType]: The credentials or None if not found
|
21
22
|
"""
|
23
|
+
|
22
24
|
def get_workspace():
|
23
25
|
if os.environ.get("BL_WORKSPACE"):
|
24
26
|
return os.environ.get("BL_WORKSPACE")
|
25
27
|
home_dir = Path.home()
|
26
|
-
config_path = home_dir /
|
27
|
-
with open(config_path, encoding=
|
28
|
+
config_path = home_dir / ".blaxel" / "config.yaml"
|
29
|
+
with open(config_path, encoding="utf-8") as f:
|
28
30
|
config_json = yaml.safe_load(f)
|
29
31
|
return config_json.get("context", {}).get("workspace")
|
30
32
|
|
31
33
|
if os.environ.get("BL_API_KEY"):
|
32
|
-
return CredentialsType(
|
33
|
-
api_key=os.environ.get("BL_API_KEY"),
|
34
|
-
workspace=get_workspace()
|
35
|
-
)
|
34
|
+
return CredentialsType(api_key=os.environ.get("BL_API_KEY"), workspace=get_workspace())
|
36
35
|
|
37
36
|
if os.environ.get("BL_CLIENT_CREDENTIALS"):
|
38
37
|
return CredentialsType(
|
39
|
-
client_credentials=os.environ.get("BL_CLIENT_CREDENTIALS"),
|
40
|
-
workspace=get_workspace()
|
38
|
+
client_credentials=os.environ.get("BL_CLIENT_CREDENTIALS"), workspace=get_workspace()
|
41
39
|
)
|
42
40
|
|
43
41
|
try:
|
44
42
|
home_dir = Path.home()
|
45
|
-
config_path = home_dir /
|
43
|
+
config_path = home_dir / ".blaxel" / "config.yaml"
|
46
44
|
|
47
|
-
with open(config_path, encoding=
|
45
|
+
with open(config_path, encoding="utf-8") as f:
|
48
46
|
config_json = yaml.safe_load(f)
|
49
47
|
|
50
|
-
workspace_name = os.environ.get("BL_WORKSPACE") or config_json.get("context", {}).get(
|
48
|
+
workspace_name = os.environ.get("BL_WORKSPACE") or config_json.get("context", {}).get(
|
49
|
+
"workspace"
|
50
|
+
)
|
51
51
|
|
52
52
|
for workspace in config_json.get("workspaces", []):
|
53
53
|
if workspace.get("name") == workspace_name:
|
@@ -55,12 +55,12 @@ def get_credentials() -> Optional[CredentialsType]:
|
|
55
55
|
credentials["workspace"] = workspace_name
|
56
56
|
return CredentialsType(
|
57
57
|
workspace=credentials["workspace"],
|
58
|
-
api_key=credentials.get("
|
59
|
-
client_credentials=credentials.get("
|
58
|
+
api_key=credentials.get("apiKey"),
|
59
|
+
client_credentials=credentials.get("clientCredentials"),
|
60
60
|
refresh_token=credentials.get("refresh_token"),
|
61
61
|
access_token=credentials.get("access_token"),
|
62
62
|
device_code=credentials.get("device_code"),
|
63
|
-
expires_in=credentials.get("expires_in")
|
63
|
+
expires_in=credentials.get("expires_in"),
|
64
64
|
)
|
65
65
|
|
66
66
|
return None
|
@@ -94,4 +94,5 @@ def auth(env: str, base_url: str) -> BlaxelAuth:
|
|
94
94
|
|
95
95
|
return BlaxelAuth(credentials, credentials.workspace, base_url)
|
96
96
|
|
97
|
-
|
97
|
+
|
98
|
+
__all__ = ["BlaxelAuth", "CredentialsType"]
|
@@ -2,7 +2,7 @@ blaxel/__init__.py,sha256=dK8RSbcDKSdr3Fr45aLDs6qPkLkxrsERQo24HCATbf4,241
|
|
2
2
|
blaxel/core/__init__.py,sha256=OeRTi6S78PQiyrDMM8RjgLYbjXb3inTxW8Z6rrbg39w,1026
|
3
3
|
blaxel/core/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
4
4
|
blaxel/core/agents/__init__.py,sha256=_mtes7ZRf2AXtGF4AWE13T0iHd0SMc0b03ypuX5k3TM,4088
|
5
|
-
blaxel/core/authentication/__init__.py,sha256=
|
5
|
+
blaxel/core/authentication/__init__.py,sha256=7gK_yLclpI0oiK4ZiGRyA6l5yXkcKrYMnVLYCulV598,3262
|
6
6
|
blaxel/core/authentication/apikey.py,sha256=n_5IA2y3wS_218R8N1Ic82Okhq6C69g_Tg4Pt5YSDnA,1250
|
7
7
|
blaxel/core/authentication/clientcredentials.py,sha256=esxSfGUacO8D_hn9nAx7wQ0oG8D0VsjfUzrPAeui8oM,3928
|
8
8
|
blaxel/core/authentication/devicemode.py,sha256=nCo9-y194L2XDt5_9FOSK36Nc7l6Oxz1NKJQk6g2ses,6019
|
@@ -402,7 +402,7 @@ blaxel/telemetry/instrumentation/map.py,sha256=PCzZJj39yiYVYJrxLBNP-NW-tjjYyTijw
|
|
402
402
|
blaxel/telemetry/instrumentation/utils.py,sha256=KInMYZH-mu9_wvetmf0EmgrfN3Sw8IWk2Y95v2u90_U,1901
|
403
403
|
blaxel/telemetry/log/log.py,sha256=RvQByRjZMoP_dRaAZu8oK6DTegsHs-xV4W-UIqis6CA,2461
|
404
404
|
blaxel/telemetry/log/logger.py,sha256=NPAS3g82ryROjvc_DEZaTIfrcehoLEZoP-JkLxADxc0,4113
|
405
|
-
blaxel-0.2.
|
406
|
-
blaxel-0.2.
|
407
|
-
blaxel-0.2.
|
408
|
-
blaxel-0.2.
|
405
|
+
blaxel-0.2.7rc82.dist-info/METADATA,sha256=PZvVY1dTI91z_fmxB056Pn0fEAJd6yUYt5GE7EavU7k,9879
|
406
|
+
blaxel-0.2.7rc82.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
407
|
+
blaxel-0.2.7rc82.dist-info/licenses/LICENSE,sha256=p5PNQvpvyDT_0aYBDgmV1fFI_vAD2aSV0wWG7VTgRis,1069
|
408
|
+
blaxel-0.2.7rc82.dist-info/RECORD,,
|
File without changes
|
File without changes
|