pybiolib 1.2.1166__py3-none-any.whl → 1.2.1168__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.
- biolib/_session/session.py +6 -32
- biolib/sdk/__init__.py +2 -14
- {pybiolib-1.2.1166.dist-info → pybiolib-1.2.1168.dist-info}/METADATA +1 -1
- {pybiolib-1.2.1166.dist-info → pybiolib-1.2.1168.dist-info}/RECORD +7 -8
- biolib/_internal/auth_utils.py +0 -27
- {pybiolib-1.2.1166.dist-info → pybiolib-1.2.1168.dist-info}/LICENSE +0 -0
- {pybiolib-1.2.1166.dist-info → pybiolib-1.2.1168.dist-info}/WHEEL +0 -0
- {pybiolib-1.2.1166.dist-info → pybiolib-1.2.1168.dist-info}/entry_points.txt +0 -0
biolib/_session/session.py
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
from biolib import utils
|
2
2
|
from biolib._internal.types import Optional
|
3
3
|
from biolib.api.client import ApiClient, ApiClientInitDict
|
4
|
-
from biolib._internal.auth_utils import exchange_username_password_for_tokens
|
5
4
|
from biolib.app import BioLibApp
|
6
5
|
|
7
6
|
|
@@ -10,39 +9,14 @@ class Session:
|
|
10
9
|
self._api = ApiClient(_init_dict=_init_dict)
|
11
10
|
|
12
11
|
@staticmethod
|
13
|
-
def get_session(
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
) -> 'Session':
|
20
|
-
if refresh_token and (username or password):
|
21
|
-
raise ValueError("Cannot specify both refresh_token and username/password authentication")
|
22
|
-
|
23
|
-
if (username and not password) or (password and not username):
|
24
|
-
raise ValueError("Both username and password must be provided for username/password authentication")
|
25
|
-
|
26
|
-
if not refresh_token and not (username and password):
|
27
|
-
raise ValueError("Must provide either refresh_token or username/password for authentication")
|
28
|
-
|
29
|
-
base_url_resolved = base_url or utils.load_base_url_from_env()
|
30
|
-
|
31
|
-
if username and password:
|
32
|
-
tokens = exchange_username_password_for_tokens(
|
33
|
-
username,
|
34
|
-
password,
|
35
|
-
base_url_resolved,
|
12
|
+
def get_session(refresh_token: str, base_url: Optional[str] = None, client_type: Optional[str] = None) -> 'Session':
|
13
|
+
return Session(
|
14
|
+
_init_dict=ApiClientInitDict(
|
15
|
+
refresh_token=refresh_token,
|
16
|
+
base_url=base_url or utils.load_base_url_from_env(),
|
17
|
+
client_type=client_type,
|
36
18
|
)
|
37
|
-
refresh_token = tokens['refresh']
|
38
|
-
|
39
|
-
init_dict = ApiClientInitDict(
|
40
|
-
refresh_token=str(refresh_token),
|
41
|
-
base_url=base_url_resolved,
|
42
|
-
client_type=client_type,
|
43
19
|
)
|
44
|
-
|
45
|
-
return Session(_init_dict=init_dict)
|
46
20
|
|
47
21
|
def load(self, uri: str, suppress_version_warning: bool = False) -> BioLibApp:
|
48
22
|
r"""Load a BioLib application by its URI or website URL.
|
biolib/sdk/__init__.py
CHANGED
@@ -12,20 +12,8 @@ from biolib.app import BioLibApp as _BioLibApp
|
|
12
12
|
Runtime = _Runtime
|
13
13
|
|
14
14
|
|
15
|
-
def get_session(
|
16
|
-
refresh_token
|
17
|
-
base_url: Optional[str] = None,
|
18
|
-
client_type: Optional[str] = None,
|
19
|
-
username: Optional[str] = None,
|
20
|
-
password: Optional[str] = None,
|
21
|
-
) -> _Session:
|
22
|
-
return _Session.get_session(
|
23
|
-
refresh_token=refresh_token,
|
24
|
-
base_url=base_url,
|
25
|
-
client_type=client_type,
|
26
|
-
username=username,
|
27
|
-
password=password,
|
28
|
-
)
|
15
|
+
def get_session(refresh_token: str, base_url: Optional[str] = None, client_type: Optional[str] = None) -> _Session:
|
16
|
+
return _Session.get_session(refresh_token=refresh_token, base_url=base_url, client_type=client_type)
|
29
17
|
|
30
18
|
|
31
19
|
def push_app_version(uri: str, path: str) -> _BioLibApp:
|
@@ -3,7 +3,6 @@ biolib/_data_record/data_record.py,sha256=BM2WEBnn13reSiAqhBtcV8FLewFWSTcMmFV0bD
|
|
3
3
|
biolib/_internal/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
4
4
|
biolib/_internal/add_copilot_prompts.py,sha256=wcIdrceFcfKSoEjvM4uNzhKZ0I1-MCFkfNO4duqtGHA,1861
|
5
5
|
biolib/_internal/add_gui_files.py,sha256=MrtvkIpe70tVVJYBBsMbRhjsxf55hFzlzn-ea2oinTc,2218
|
6
|
-
biolib/_internal/auth_utils.py,sha256=IRNzpgI83iIPVG0vSlPuPri4BRJ_LsIj28M30lrVi5o,978
|
7
6
|
biolib/_internal/data_record/__init__.py,sha256=fGdME6JGRU_2VxpJbYpGXYndjN-feUkmKY4fuMyq3cg,76
|
8
7
|
biolib/_internal/data_record/data_record.py,sha256=SD3-tKQY2RZv9ZSVNUhd2ISDYV64Fk1Sc642qyf_Vis,4618
|
9
8
|
biolib/_internal/data_record/push_data.py,sha256=-L3a_7zZzDCXabBu3O4lWPMAMeBbeRPTrBlEM-_5SCI,2693
|
@@ -63,7 +62,7 @@ biolib/_internal/types/user.py,sha256=5_hYG0jrdGxynCCWXGaHZCAlVcRKBqMIEA2EBGrnpi
|
|
63
62
|
biolib/_internal/utils/__init__.py,sha256=p5vsIFyu-zYqBgdSMfwW9NC_jk7rXvvCbV4Bzd3As7c,630
|
64
63
|
biolib/_internal/utils/multinode.py,sha256=N7kR49xD1PdkMVlxxzRiSYHfgi9MG-kLCwemcY1rojg,8323
|
65
64
|
biolib/_runtime/runtime.py,sha256=vRJ0YFSGYVHWULam_fnS2EHmNEm_qkrJXWdsy0n8JDA,5857
|
66
|
-
biolib/_session/session.py,sha256=
|
65
|
+
biolib/_session/session.py,sha256=US1Y1jfFIAm86-Lq3C7nCXpZXUJXXBVBkND9djMNYxI,1649
|
67
66
|
biolib/api/__init__.py,sha256=mQ4u8FijqyLzjYMezMUUbbBGNB3iFmkNdjXnWPZ7Jlw,138
|
68
67
|
biolib/api/client.py,sha256=2GpKE7QrPgyPdgJgrV7XnZByIJf1n26UCy3aoaHBs1M,7881
|
69
68
|
biolib/app/__init__.py,sha256=cdPtcfb_U-bxb9iSL4fCEq2rpD9OjkyY4W-Zw60B0LI,37
|
@@ -147,7 +146,7 @@ biolib/jobs/job_result.py,sha256=L__GA5dNSDFHoQpAG2xb-tNqp_p4fQl53bAmlcvAt6M,607
|
|
147
146
|
biolib/jobs/types.py,sha256=ezvaoTANsWazK6PmfpYcqezdfjP7MNBEBfqIZGoZhz8,997
|
148
147
|
biolib/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
149
148
|
biolib/runtime/__init__.py,sha256=MlRepA11n2H-3plB5rzWyyHK2JmP6PiaP3i6x3vt0mg,506
|
150
|
-
biolib/sdk/__init__.py,sha256=
|
149
|
+
biolib/sdk/__init__.py,sha256=Z1S5BgpvM87S2o1libtqkYN1CfYUhn_d4ChEJjwdFKM,2356
|
151
150
|
biolib/tables.py,sha256=MmruV-nJLc3HbLVJBAiDuDCgS2-4oaUkpoCLLUNYbxQ,1173
|
152
151
|
biolib/typing_utils.py,sha256=ntzrlyTkUaO2OtccLYzCAGztGdca0WT5fikJUmSkT-Y,148
|
153
152
|
biolib/user/__init__.py,sha256=Db5wtxLfFz3ID9TULSSTo77csw9tO6RtxMRvV5cqKEE,39
|
@@ -158,8 +157,8 @@ biolib/utils/cache_state.py,sha256=u256F37QSRIVwqKlbnCyzAX4EMI-kl6Dwu6qwj-Qmag,3
|
|
158
157
|
biolib/utils/multipart_uploader.py,sha256=XvGP1I8tQuKhAH-QugPRoEsCi9qvbRk-DVBs5PNwwJo,8452
|
159
158
|
biolib/utils/seq_util.py,sha256=Ozk0blGtPur_D9MwShD02r_mphyQmgZkx-lOHOwnlIM,6730
|
160
159
|
biolib/utils/zip/remote_zip.py,sha256=0wErYlxir5921agfFeV1xVjf29l9VNgGQvNlWOlj2Yc,23232
|
161
|
-
pybiolib-1.2.
|
162
|
-
pybiolib-1.2.
|
163
|
-
pybiolib-1.2.
|
164
|
-
pybiolib-1.2.
|
165
|
-
pybiolib-1.2.
|
160
|
+
pybiolib-1.2.1168.dist-info/LICENSE,sha256=F2h7gf8i0agDIeWoBPXDMYScvQOz02pAWkKhTGOHaaw,1067
|
161
|
+
pybiolib-1.2.1168.dist-info/METADATA,sha256=KVqVEGjUzeuV9SuEJM2NhnMrGhK-tFcrsMNlj-JX8Vc,1571
|
162
|
+
pybiolib-1.2.1168.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
|
163
|
+
pybiolib-1.2.1168.dist-info/entry_points.txt,sha256=p6DyaP_2kctxegTX23WBznnrDi4mz6gx04O5uKtRDXg,42
|
164
|
+
pybiolib-1.2.1168.dist-info/RECORD,,
|
biolib/_internal/auth_utils.py
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
from typing import Dict
|
2
|
-
|
3
|
-
from biolib._internal.http_client import HttpClient
|
4
|
-
from biolib.biolib_logging import logger
|
5
|
-
|
6
|
-
|
7
|
-
def exchange_username_password_for_tokens(username: str, password: str, base_url: str) -> Dict[str, str]:
|
8
|
-
try:
|
9
|
-
response = HttpClient.request(
|
10
|
-
method='POST',
|
11
|
-
url=f'{base_url}/api/user/token/',
|
12
|
-
data={'username': username, 'password': password},
|
13
|
-
)
|
14
|
-
except Exception as exception:
|
15
|
-
logger.error('Sign in with username/password failed')
|
16
|
-
raise exception
|
17
|
-
|
18
|
-
try:
|
19
|
-
response_dict = response.json()
|
20
|
-
except Exception as error:
|
21
|
-
logger.error('Could not decode response from server as JSON')
|
22
|
-
raise Exception(response.text) from error
|
23
|
-
|
24
|
-
if 'access' not in response_dict or 'refresh' not in response_dict:
|
25
|
-
raise Exception('Invalid response: missing access or refresh token')
|
26
|
-
|
27
|
-
return {'access': response_dict['access'], 'refresh': response_dict['refresh']}
|
File without changes
|
File without changes
|
File without changes
|