pybiolib 1.2.1166__py3-none-any.whl → 1.2.1173__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.
@@ -240,17 +240,23 @@ def push_application(
240
240
  with open(config_yml_path) as config_yml_file:
241
241
  config = yaml.safe_load(config_yml_file.read())
242
242
 
243
- app_data = config.get('app_data')
243
+ app_data = config.get('app_data') or config.get('assets')
244
244
  if app_data:
245
+ if config.get('app_data') and config.get('assets'):
246
+ raise BioLibError(
247
+ 'In .biolib/config.yml you cannot specify both "app_data" and "assets" fields. Please use only one.'
248
+ )
249
+
250
+ field_name = 'app_data' if 'app_data' in config else 'assets'
245
251
  if not isinstance(app_data, str):
246
252
  raise BioLibError(
247
- f'In .biolib/config.yml the value of "app_data" must be a string but got {type(app_data)}'
253
+ f'In .biolib/config.yml the value of "{field_name}" must be a string but got {type(app_data)}'
248
254
  )
249
255
 
250
256
  app_data_path = app_path_absolute.joinpath(app_data).resolve()
251
257
  if not app_data_path.is_dir():
252
258
  raise BioLibError(
253
- 'In .biolib/config.yml the value of "app_data" must be a path to a directory '
259
+ f'In .biolib/config.yml the value of "{field_name}" must be a path to a directory '
254
260
  'in the application directory'
255
261
  )
256
262
 
@@ -321,7 +327,7 @@ def push_application(
321
327
  app_response = BiolibAppApi.get_by_uri(app_uri_to_fetch)
322
328
  app = app_response['app']
323
329
 
324
- if app_data and not app['allow_client_side_execution']:
330
+ if app_data and not app['allow_client_side_execution'] and 'app_data' in config:
325
331
  raise BioLibError(
326
332
  'To push a version with app_data the app must be set to "Allow Client-Side Source Code Access"'
327
333
  )
@@ -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
- refresh_token: Optional[str] = None,
15
- base_url: Optional[str] = None,
16
- client_type: Optional[str] = None,
17
- username: Optional[str] = None,
18
- password: Optional[str] = None
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: Optional[str] = None,
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:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: pybiolib
3
- Version: 1.2.1166
3
+ Version: 1.2.1173
4
4
  Summary: BioLib Python Client
5
5
  License: MIT
6
6
  Keywords: biolib
@@ -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
@@ -17,7 +16,7 @@ biolib/_internal/lfs/__init__.py,sha256=gSWo_xg61UniYgD7yNYxeT4I9uaXBCBSi3_nmZjn
17
16
  biolib/_internal/lfs/cache.py,sha256=pQS2np21rdJ6I3DpoOutnzPHpLOZgUIS8TMltUJk_k4,2226
18
17
  biolib/_internal/libs/__init__.py,sha256=Jdf4tNPqe_oIIf6zYml6TiqhL_02Vyqwge6IELrAFhw,98
19
18
  biolib/_internal/libs/fusepy/__init__.py,sha256=AWDzNFS-XV_5yKb0Qx7kggIhPzq1nj_BZS5y2Nso08k,41944
20
- biolib/_internal/push_application.py,sha256=e0SnPh64X99ICUt5xPCIfbS3WHkUzMKLFFyaf6u2vqQ,18286
19
+ biolib/_internal/push_application.py,sha256=xno0SGnSESdlAAjsl6HOw8Y1KQgGhKbCWVQa5zHHq_k,18657
21
20
  biolib/_internal/runtime.py,sha256=BiHl4klUHr36MCpqKaUso4idHeBZfPAahLYRQrabFqA,486
22
21
  biolib/_internal/string_utils.py,sha256=N7J7oGu6_yA_z0pOiKqxEh__lRdiDLh6kigeDkQEZ5g,265
23
22
  biolib/_internal/templates/__init__.py,sha256=NVbhLUMC8HITzkLvP88Qu7FHaL-SvQord-DX3gh1Ykk,24
@@ -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=DgtIQXhPo0iQ8CH64JtDgIYMW77aj9ZagRO5eOSso0k,2690
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=ziBjyQQHxix-QlYtxt13UKhxZrRDyj3Zmtu9PMnFbCI,2545
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.1166.dist-info/LICENSE,sha256=F2h7gf8i0agDIeWoBPXDMYScvQOz02pAWkKhTGOHaaw,1067
162
- pybiolib-1.2.1166.dist-info/METADATA,sha256=1af8plRErFamhl827yHqbfBZsBLiJpePJWChZmEPQRg,1571
163
- pybiolib-1.2.1166.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
164
- pybiolib-1.2.1166.dist-info/entry_points.txt,sha256=p6DyaP_2kctxegTX23WBznnrDi4mz6gx04O5uKtRDXg,42
165
- pybiolib-1.2.1166.dist-info/RECORD,,
160
+ pybiolib-1.2.1173.dist-info/LICENSE,sha256=F2h7gf8i0agDIeWoBPXDMYScvQOz02pAWkKhTGOHaaw,1067
161
+ pybiolib-1.2.1173.dist-info/METADATA,sha256=cwQwfXVcc6Vj5QDe7PwHWDTxWmbzL4r_ypSq57QLa-g,1571
162
+ pybiolib-1.2.1173.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
163
+ pybiolib-1.2.1173.dist-info/entry_points.txt,sha256=p6DyaP_2kctxegTX23WBznnrDi4mz6gx04O5uKtRDXg,42
164
+ pybiolib-1.2.1173.dist-info/RECORD,,
@@ -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']}