pybiolib 1.2.252__py3-none-any.whl → 1.2.261__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.
@@ -79,6 +79,7 @@ class HttpClient:
79
79
  timeout_in_seconds: Optional[int] = None,
80
80
  response_path: Optional[str] = None,
81
81
  retry_on_http_500: Optional[bool] = False,
82
+ max_content_length_in_bytes: Optional[int] = None,
82
83
  ) -> HttpResponse:
83
84
  if not HttpClient.ssl_context:
84
85
  HttpClient.ssl_context = _create_ssl_context()
@@ -107,6 +108,14 @@ class HttpClient:
107
108
  context=HttpClient.ssl_context,
108
109
  timeout=timeout_in_seconds,
109
110
  ) as response:
111
+ if max_content_length_in_bytes:
112
+ content_length = response.getheader('Content-Length')
113
+ if not content_length:
114
+ raise ValueError('No Content-Length in response headers')
115
+
116
+ if int(content_length) > max_content_length_in_bytes:
117
+ raise ValueError(f'Content-Length exceeds {max_content_length_in_bytes} bytes')
118
+
110
119
  return HttpResponse(response, response_path)
111
120
 
112
121
  except urllib.error.HTTPError as error:
@@ -219,12 +219,6 @@ def push_application(
219
219
  docker_tags = new_app_version_json.get('docker_tags', {})
220
220
  if not app_version_to_copy_images_from and docker_tags:
221
221
  logger.info('Found docker images to push.')
222
-
223
- # Auth to be sent to proxy
224
- # The tokens are sent as "{access_token},{job_id}". We leave job_id blank on push.
225
- tokens = f'{BiolibApiClient.get().access_token},'
226
- auth_config = {'username': 'biolib', 'password': tokens}
227
-
228
222
  docker_client = BiolibDockerClient.get_docker_client()
229
223
 
230
224
  for module_name, repo_and_tag in docker_tags.items():
@@ -264,7 +258,11 @@ def push_application(
264
258
  tag=tag,
265
259
  stream=True,
266
260
  decode=True,
267
- auth_config=auth_config,
261
+ auth_config={
262
+ 'username': 'biolib',
263
+ # For legacy reasons access token is sent with trailing comma ','
264
+ 'password': api_client.resource_deploy_key or f'{api_client.access_token},',
265
+ },
268
266
  )
269
267
 
270
268
  process_docker_status_updates(push_status_updates, action='Pushing')
biolib/api/client.py CHANGED
@@ -75,16 +75,19 @@ class ApiClient(HttpClient):
75
75
  # Only keep header keys with a value
76
76
  headers: Dict[str, str] = {key: value for key, value in (opt_headers or {}).items() if value}
77
77
 
78
- deprecated_api_client = DeprecatedApiClient.get()
79
-
80
- if deprecated_api_client.is_signed_in:
81
- deprecated_api_client.refresh_access_token()
82
-
83
- # Adding access_token outside is_signed_in check as job_worker.py currently sets access_token
84
- # without setting refresh_token
85
- access_token = deprecated_api_client.access_token
86
- if access_token and authenticate:
87
- headers['Authorization'] = f'Bearer {access_token}'
78
+ if authenticate:
79
+ deprecated_api_client = DeprecatedApiClient.get()
80
+ if deprecated_api_client.is_signed_in:
81
+ deprecated_api_client.refresh_access_token()
82
+
83
+ if deprecated_api_client.resource_deploy_key:
84
+ headers['Authorization'] = f'Token {deprecated_api_client.resource_deploy_key}'
85
+ else:
86
+ # Adding access_token outside is_signed_in check as job_worker.py currently sets access_token
87
+ # without setting refresh_token
88
+ access_token = deprecated_api_client.access_token
89
+ if access_token:
90
+ headers['Authorization'] = f'Bearer {access_token}'
88
91
 
89
92
  headers['client-type'] = 'biolib-python'
90
93
  headers['client-version'] = ApiClient._biolib_package_version
@@ -30,13 +30,14 @@ class _ApiClient:
30
30
  self.base_url: str = base_url
31
31
  self.access_token: Optional[str] = access_token # TODO: Deprecate passing access_token in constructor
32
32
  self.refresh_token: Optional[str] = None
33
+ self.resource_deploy_key: Optional[str] = None
33
34
 
34
35
  self._user_state = UserState()
35
36
  self._sign_in_attempted: bool = False
36
37
 
37
38
  @property
38
39
  def is_signed_in(self) -> bool:
39
- return bool(self.refresh_token)
40
+ return bool(self.refresh_token or self.resource_deploy_key)
40
41
 
41
42
  def set_user_tokens(self, user_tokens: UserTokens) -> None:
42
43
  with self._user_state as user_state:
@@ -57,8 +58,7 @@ class _ApiClient:
57
58
  user_state['refresh_token'] = None
58
59
 
59
60
  def refresh_access_token(self) -> None:
60
- if not self.is_signed_in:
61
- # Can't refresh access token if not signed in
61
+ if not self.is_signed_in or self.resource_deploy_key:
62
62
  return
63
63
 
64
64
  if self.access_token:
@@ -95,7 +95,10 @@ class _ApiClient:
95
95
  api_token = os.getenv('BIOLIB_TOKEN', default=None)
96
96
 
97
97
  if api_token:
98
- self.sign_in_with_api_token(api_token)
98
+ if api_token.startswith('bld_'):
99
+ self.resource_deploy_key = api_token
100
+ else:
101
+ self.sign_in_with_api_token(api_token)
99
102
  else:
100
103
  with self._user_state as user_state:
101
104
  refresh_token_from_state = user_state['refresh_token']
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pybiolib
3
- Version: 1.2.252
3
+ Version: 1.2.261
4
4
  Summary: BioLib Python Client
5
5
  Home-page: https://github.com/biolib
6
6
  License: MIT
@@ -10,12 +10,12 @@ biolib/_internal/data_record/remote_storage_endpoint.py,sha256=eCptuZ4DMAPnaNCVD
10
10
  biolib/_internal/file_utils.py,sha256=4jT6j7bB21c0JNn5BfnyWQib_zt0CVtJ_TiOFOStRcE,2604
11
11
  biolib/_internal/fuse_mount/__init__.py,sha256=B_tM6RM2dBw-vbpoHJC4X3tOAaN1H2RDvqYJOw3xFwg,55
12
12
  biolib/_internal/fuse_mount/experiment_fuse_mount.py,sha256=08aUdEq_bvqLBft_gSLjOClKDy5sBnMts1RfJf7AP_U,7012
13
- biolib/_internal/http_client.py,sha256=C0bHqVrenT3ifZ3k0FdzBZR7ZxDXKBUG148KRxheAyk,5701
13
+ biolib/_internal/http_client.py,sha256=_uop4dwetHA5MvmxVqGzxV9w1Zl4peRVZXFiImuL2BA,6211
14
14
  biolib/_internal/lfs/__init__.py,sha256=gSWo_xg61UniYgD7yNYxeT4I9uaXBCBSi3_nmZjnPpE,35
15
15
  biolib/_internal/lfs/cache.py,sha256=pQS2np21rdJ6I3DpoOutnzPHpLOZgUIS8TMltUJk_k4,2226
16
16
  biolib/_internal/libs/__init__.py,sha256=Jdf4tNPqe_oIIf6zYml6TiqhL_02Vyqwge6IELrAFhw,98
17
17
  biolib/_internal/libs/fusepy/__init__.py,sha256=AWDzNFS-XV_5yKb0Qx7kggIhPzq1nj_BZS5y2Nso08k,41944
18
- biolib/_internal/push_application.py,sha256=eu9TGTDQUkgY42SAjbURycrrbX8hesBCWBEg0H5CdQQ,11948
18
+ biolib/_internal/push_application.py,sha256=LQSawvF8uWOGOu-6sEJulvc6ia4Fo3pfQ2m_jLBqXRs,11946
19
19
  biolib/_internal/runtime.py,sha256=BiHl4klUHr36MCpqKaUso4idHeBZfPAahLYRQrabFqA,486
20
20
  biolib/_internal/types/__init__.py,sha256=xLgOQJFh3GRtiqIJq7MaqHReZx4pp34_zcaFQ_JjuJ4,198
21
21
  biolib/_internal/types/app.py,sha256=Mz2QGD_jESX-K9JYnLWPo4YA__Q_1FQQTk9pvidCohU,118
@@ -29,12 +29,12 @@ biolib/_internal/utils/__init__.py,sha256=p5vsIFyu-zYqBgdSMfwW9NC_jk7rXvvCbV4Bzd
29
29
  biolib/_internal/utils/multinode.py,sha256=zWrQhcVK5u_xdWX2oIM-D_2fINqNPlqF_h71fu4K8LY,8279
30
30
  biolib/_runtime/runtime.py,sha256=bZQ0m39R9jOBVAtlyvzDnOobKueOAQUCwMUZjDQnO7E,4439
31
31
  biolib/api/__init__.py,sha256=mQ4u8FijqyLzjYMezMUUbbBGNB3iFmkNdjXnWPZ7Jlw,138
32
- biolib/api/client.py,sha256=FRpdH5aI187b_I_4HUNi680v4iOP65z5f2RcUo8D8MA,3559
32
+ biolib/api/client.py,sha256=_kmwaGI_-u7kOeWVCYmo-pD2K1imwEv9n2gNZRb5F-I,3790
33
33
  biolib/app/__init__.py,sha256=cdPtcfb_U-bxb9iSL4fCEq2rpD9OjkyY4W-Zw60B0LI,37
34
34
  biolib/app/app.py,sha256=mJafDLtnoX66egHF94NrUhmhzjpFzvRj2STh0RVGJCY,8862
35
35
  biolib/app/search_apps.py,sha256=K4a41f5XIWth2BWI7OffASgIsD0ko8elCax8YL2igaY,1470
36
36
  biolib/biolib_api_client/__init__.py,sha256=E5EMa19wJoblwSdQPYrxc_BtIeRsAuO0L_jQweWw-Yk,182
37
- biolib/biolib_api_client/api_client.py,sha256=ciNx4ybpyKG5LEf4KQdGEz13r0jTxImyQat4_HDecD0,7373
37
+ biolib/biolib_api_client/api_client.py,sha256=ohvbWbpresxLHFGPkvXACfmiTYsBk8RBx5XsBbLYg_M,7546
38
38
  biolib/biolib_api_client/app_types.py,sha256=1sXz9XnLRKNALMglNdTbew7AL6OkcUan0MPdj4xQLis,2456
39
39
  biolib/biolib_api_client/auth.py,sha256=kjm0ZHnH3I8so3su2sZbBxNHYp-ZUdrZ5lwQ0K36RSw,949
40
40
  biolib/biolib_api_client/biolib_app_api.py,sha256=RUXrTxk7XKzm4wxv7NBXttuFjT60DI9vNOvkS-cjKNc,5065
@@ -120,8 +120,8 @@ biolib/utils/cache_state.py,sha256=u256F37QSRIVwqKlbnCyzAX4EMI-kl6Dwu6qwj-Qmag,3
120
120
  biolib/utils/multipart_uploader.py,sha256=XvGP1I8tQuKhAH-QugPRoEsCi9qvbRk-DVBs5PNwwJo,8452
121
121
  biolib/utils/seq_util.py,sha256=Ozk0blGtPur_D9MwShD02r_mphyQmgZkx-lOHOwnlIM,6730
122
122
  biolib/utils/zip/remote_zip.py,sha256=0wErYlxir5921agfFeV1xVjf29l9VNgGQvNlWOlj2Yc,23232
123
- pybiolib-1.2.252.dist-info/LICENSE,sha256=F2h7gf8i0agDIeWoBPXDMYScvQOz02pAWkKhTGOHaaw,1067
124
- pybiolib-1.2.252.dist-info/METADATA,sha256=1JftPlZ5tUpXRs3iDQk5MZwE_F-h3ZeMjIJc8hFcZos,1558
125
- pybiolib-1.2.252.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
126
- pybiolib-1.2.252.dist-info/entry_points.txt,sha256=p6DyaP_2kctxegTX23WBznnrDi4mz6gx04O5uKtRDXg,42
127
- pybiolib-1.2.252.dist-info/RECORD,,
123
+ pybiolib-1.2.261.dist-info/LICENSE,sha256=F2h7gf8i0agDIeWoBPXDMYScvQOz02pAWkKhTGOHaaw,1067
124
+ pybiolib-1.2.261.dist-info/METADATA,sha256=X7fRthTCjbbApA3D_L8lqPZC8ZpvxXuE7ETTqELbmRU,1558
125
+ pybiolib-1.2.261.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
126
+ pybiolib-1.2.261.dist-info/entry_points.txt,sha256=p6DyaP_2kctxegTX23WBznnrDi4mz6gx04O5uKtRDXg,42
127
+ pybiolib-1.2.261.dist-info/RECORD,,