pybiolib 1.1.1995__py3-none-any.whl → 1.1.1998__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.
@@ -1,23 +1,34 @@
1
+ import os
1
2
  from datetime import datetime, timedelta
3
+ from urllib.parse import urlparse
2
4
 
3
5
  from biolib.api import client as api_client
4
6
  from biolib.biolib_api_client.lfs_types import LargeFileSystemVersion
5
7
  from biolib.biolib_binary_format.utils import RemoteEndpoint
6
8
  from biolib.biolib_logging import logger
9
+ from biolib.typing_utils import Optional
7
10
 
8
11
 
9
12
  class DataRecordRemoteStorageEndpoint(RemoteEndpoint):
10
13
  def __init__(self, resource_version_uuid: str):
11
14
  self._resource_version_uuid: str = resource_version_uuid
12
- self._expires_at = None
13
- self._presigned_url = None
15
+ self._expires_at: Optional[datetime] = None
16
+ self._presigned_url: Optional[str] = None
14
17
 
15
- def get_remote_url(self):
16
- if not self._presigned_url or datetime.utcnow() > self._expires_at:
18
+ def get_remote_url(self) -> str:
19
+ if not self._presigned_url or not self._expires_at or datetime.utcnow() > self._expires_at:
17
20
  lfs_version: LargeFileSystemVersion = api_client.get(
18
21
  path=f'/lfs/versions/{self._resource_version_uuid}/',
19
22
  ).json()
20
- self._presigned_url = lfs_version['presigned_download_url']
23
+
24
+ app_caller_proxy_job_storage_base_url = os.getenv('BIOLIB_CLOUD_JOB_STORAGE_BASE_URL', '')
25
+ if app_caller_proxy_job_storage_base_url:
26
+ # Done to hit App Caller Proxy when downloading from inside an app
27
+ parsed_url = urlparse(lfs_version['presigned_download_url'])
28
+ self._presigned_url = f'{app_caller_proxy_job_storage_base_url}{parsed_url.path}?{parsed_url.query}'
29
+ else:
30
+ self._presigned_url = lfs_version['presigned_download_url']
31
+
21
32
  self._expires_at = datetime.utcnow() + timedelta(minutes=8)
22
33
  logger.debug(
23
34
  f'DataRecord "{self._resource_version_uuid}" fetched presigned URL '
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pybiolib
3
- Version: 1.1.1995
3
+ Version: 1.1.1998
4
4
  Summary: BioLib Python Client
5
5
  Home-page: https://github.com/biolib
6
6
  License: MIT
@@ -4,7 +4,7 @@ biolib/__init__.py,sha256=nfZvVkrHZLvjvvlAvFzhvem9NMfqgmw8NWaCH9HGzew,4045
4
4
  biolib/_internal/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
5
  biolib/_internal/data_record/__init__.py,sha256=1Bk303i3rFet9veS56fIsrBYtT5X3n9vcsYMA6T6c5o,36
6
6
  biolib/_internal/data_record/data_record.py,sha256=ctijrrZ-LfUxtwzS8PEVa1VBuBLVWEhmo2yHcEDkC0A,7178
7
- biolib/_internal/data_record/remote_storage_endpoint.py,sha256=LPq8Lr5FhKF9_o5K-bUdT7TeLe5XFUD0AAeTkNEVZug,1133
7
+ biolib/_internal/data_record/remote_storage_endpoint.py,sha256=hILu0TmFx-ZyDYbWPC4QEPogP0RRVEqwgJc8OEHYp50,1742
8
8
  biolib/_internal/fuse_mount/__init__.py,sha256=B_tM6RM2dBw-vbpoHJC4X3tOAaN1H2RDvqYJOw3xFwg,55
9
9
  biolib/_internal/fuse_mount/experiment_fuse_mount.py,sha256=08aUdEq_bvqLBft_gSLjOClKDy5sBnMts1RfJf7AP_U,7012
10
10
  biolib/_internal/http_client.py,sha256=DdooXei93JKGYGV4aQmzue_oFzvHkozg2UCxgk9dfDM,5081
@@ -109,8 +109,8 @@ biolib/utils/cache_state.py,sha256=u256F37QSRIVwqKlbnCyzAX4EMI-kl6Dwu6qwj-Qmag,3
109
109
  biolib/utils/multipart_uploader.py,sha256=XvGP1I8tQuKhAH-QugPRoEsCi9qvbRk-DVBs5PNwwJo,8452
110
110
  biolib/utils/seq_util.py,sha256=jC5WhH63FTD7SLFJbxQGA2hOt9NTwq9zHl_BEec1Z0c,4907
111
111
  biolib/utils/zip/remote_zip.py,sha256=0wErYlxir5921agfFeV1xVjf29l9VNgGQvNlWOlj2Yc,23232
112
- pybiolib-1.1.1995.dist-info/LICENSE,sha256=F2h7gf8i0agDIeWoBPXDMYScvQOz02pAWkKhTGOHaaw,1067
113
- pybiolib-1.1.1995.dist-info/METADATA,sha256=DAKK-AVJu-iyW_SwhKYCOsgPLzJjoOV6C1eIZlaThkE,1508
114
- pybiolib-1.1.1995.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
115
- pybiolib-1.1.1995.dist-info/entry_points.txt,sha256=p6DyaP_2kctxegTX23WBznnrDi4mz6gx04O5uKtRDXg,42
116
- pybiolib-1.1.1995.dist-info/RECORD,,
112
+ pybiolib-1.1.1998.dist-info/LICENSE,sha256=F2h7gf8i0agDIeWoBPXDMYScvQOz02pAWkKhTGOHaaw,1067
113
+ pybiolib-1.1.1998.dist-info/METADATA,sha256=3V8P0UEv5bTpOlVUAfNJAS7GQPCu2v_l7mu1Xqvr_sc,1508
114
+ pybiolib-1.1.1998.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
115
+ pybiolib-1.1.1998.dist-info/entry_points.txt,sha256=p6DyaP_2kctxegTX23WBznnrDi4mz6gx04O5uKtRDXg,42
116
+ pybiolib-1.1.1998.dist-info/RECORD,,