pybiolib 1.1.1739__py3-none-any.whl → 1.1.1745__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/biolib_api_client/auth.py +0 -12
- biolib/biolib_api_client/biolib_app_api.py +4 -7
- biolib/utils/seq_util.py +5 -5
- biolib/utils/zip/remote_zip.py +9 -17
- {pybiolib-1.1.1739.dist-info → pybiolib-1.1.1745.dist-info}/METADATA +1 -2
- {pybiolib-1.1.1739.dist-info → pybiolib-1.1.1745.dist-info}/RECORD +9 -9
- {pybiolib-1.1.1739.dist-info → pybiolib-1.1.1745.dist-info}/LICENSE +0 -0
- {pybiolib-1.1.1739.dist-info → pybiolib-1.1.1745.dist-info}/WHEEL +0 -0
- {pybiolib-1.1.1739.dist-info → pybiolib-1.1.1745.dist-info}/entry_points.txt +0 -0
biolib/biolib_api_client/auth.py
CHANGED
@@ -1,20 +1,8 @@
|
|
1
|
-
from requests.auth import AuthBase # type: ignore
|
2
|
-
|
3
1
|
from biolib import api
|
4
2
|
from biolib.biolib_api_client.api_client import UserTokens
|
5
3
|
from biolib.typing_utils import TypedDict, Literal
|
6
4
|
|
7
5
|
|
8
|
-
class BearerAuth(AuthBase):
|
9
|
-
def __init__(self, access_token=None):
|
10
|
-
self.access_token = access_token
|
11
|
-
|
12
|
-
def __call__(self, req):
|
13
|
-
if self.access_token:
|
14
|
-
req.headers['Authorization'] = 'Bearer ' + self.access_token
|
15
|
-
return req
|
16
|
-
|
17
|
-
|
18
6
|
class AuthChallengeCreate(TypedDict):
|
19
7
|
token: str
|
20
8
|
|
@@ -4,14 +4,14 @@ import re
|
|
4
4
|
import os
|
5
5
|
import subprocess
|
6
6
|
|
7
|
-
from requests.exceptions import HTTPError
|
8
|
-
|
9
7
|
import biolib.api
|
10
8
|
from biolib import biolib_errors
|
9
|
+
from biolib._internal.http_client import HttpError
|
11
10
|
from biolib.typing_utils import Optional
|
12
11
|
from biolib.biolib_api_client import AppGetResponse
|
13
12
|
from biolib.biolib_logging import logger
|
14
13
|
|
14
|
+
|
15
15
|
def encode_multipart(data, files):
|
16
16
|
boundary = f'----------{random.randint(0, 1000000000)}'
|
17
17
|
line_array = []
|
@@ -76,13 +76,10 @@ class BiolibAppApi:
|
|
76
76
|
app_response: AppGetResponse = response.json()
|
77
77
|
return app_response
|
78
78
|
|
79
|
-
except
|
80
|
-
if error.
|
79
|
+
except HttpError as error:
|
80
|
+
if error.code == 404:
|
81
81
|
raise biolib_errors.NotFound(f'Application {uri} not found.') from None
|
82
82
|
|
83
|
-
if error.response.status_code == 400:
|
84
|
-
raise biolib_errors.BioLibError(error.response.content.decode()) from None
|
85
|
-
|
86
83
|
raise error
|
87
84
|
|
88
85
|
@staticmethod
|
biolib/utils/seq_util.py
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
import re
|
2
|
-
from io import
|
2
|
+
from io import BufferedIOBase
|
3
3
|
from biolib.typing_utils import List, Optional, Dict, Union
|
4
4
|
|
5
5
|
allowed_sequence_chars = set("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_.")
|
@@ -33,7 +33,7 @@ class SeqUtilRecord:
|
|
33
33
|
class SeqUtil:
|
34
34
|
@staticmethod
|
35
35
|
def parse_fasta(
|
36
|
-
input_file: Union[str,
|
36
|
+
input_file: Union[str, BufferedIOBase] = None,
|
37
37
|
default_header: Optional[str] = None,
|
38
38
|
allow_any_sequence_characters: bool = False,
|
39
39
|
allow_empty_sequence: bool = False,
|
@@ -43,14 +43,14 @@ class SeqUtil:
|
|
43
43
|
if file_name:
|
44
44
|
input_file = file_name
|
45
45
|
else:
|
46
|
-
raise ValueError("input_file must be a file name (str) or a
|
46
|
+
raise ValueError("input_file must be a file name (str) or a BufferedIOBase object")
|
47
47
|
if isinstance(input_file, str):
|
48
48
|
with open(input_file, 'r') as file_handle:
|
49
49
|
data = file_handle.read().strip()
|
50
|
-
elif isinstance(input_file,
|
50
|
+
elif isinstance(input_file, BufferedIOBase):
|
51
51
|
data = input_file.read().decode('utf-8')
|
52
52
|
else:
|
53
|
-
raise ValueError("input_file must be a file name (str) or a
|
53
|
+
raise ValueError("input_file must be a file name (str) or a BufferedIOBase object")
|
54
54
|
if not data:
|
55
55
|
return []
|
56
56
|
|
biolib/utils/zip/remote_zip.py
CHANGED
@@ -9,14 +9,15 @@ https://github.com/uktrade/stream-unzip
|
|
9
9
|
import io
|
10
10
|
import zipfile
|
11
11
|
|
12
|
-
import requests
|
13
|
-
|
14
12
|
from functools import partial
|
15
13
|
from struct import Struct
|
16
14
|
import zlib
|
17
15
|
|
18
16
|
__all__ = ['RemoteIOError', 'RemoteZip']
|
19
17
|
|
18
|
+
from biolib._internal.http_client import HttpClient
|
19
|
+
|
20
|
+
|
20
21
|
class RemoteZipError(Exception):
|
21
22
|
pass
|
22
23
|
|
@@ -152,8 +153,7 @@ class RemoteIO(io.IOBase):
|
|
152
153
|
|
153
154
|
|
154
155
|
class RemoteZip(zipfile.ZipFile):
|
155
|
-
def __init__(self, url, initial_buffer_size=64*1024
|
156
|
-
self.kwargs = kwargs
|
156
|
+
def __init__(self, url, initial_buffer_size=64*1024):
|
157
157
|
self.url = url
|
158
158
|
|
159
159
|
rio = RemoteIO(self.fetch_fun, initial_buffer_size)
|
@@ -191,22 +191,14 @@ class RemoteZip(zipfile.ZipFile):
|
|
191
191
|
return "bytes=%s%s" % (range_min, '' if range_min < 0 else '-')
|
192
192
|
return "bytes=%s-%s" % (range_min, range_max)
|
193
193
|
|
194
|
-
@staticmethod
|
195
|
-
def request(url, range_header, kwargs):
|
196
|
-
kwargs['headers'] = headers = dict(kwargs.get('headers', {}))
|
197
|
-
headers['Range'] = range_header
|
198
|
-
res = requests.get(url, stream=True, **kwargs)
|
199
|
-
res.raise_for_status()
|
200
|
-
if 'Content-Range' not in res.headers:
|
201
|
-
raise RangeNotSupported("The server doesn't support range requests")
|
202
|
-
return res.raw, res.headers
|
203
|
-
|
204
194
|
def fetch_fun(self, data_range, stream=False):
|
205
195
|
range_header = self.make_header(*data_range)
|
206
|
-
kwargs = dict(self.kwargs)
|
207
196
|
try:
|
208
|
-
|
209
|
-
|
197
|
+
response = HttpClient.request(url=self.url, headers={'Range': range_header})
|
198
|
+
if 'Content-Range' not in response.headers:
|
199
|
+
raise RangeNotSupported("The server doesn't support range requests")
|
200
|
+
|
201
|
+
return self.make_buffer(io.BytesIO(response.content), response.headers['Content-Range'], stream=False)
|
210
202
|
except IOError as e:
|
211
203
|
raise RemoteIOError(str(e))
|
212
204
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: pybiolib
|
3
|
-
Version: 1.1.
|
3
|
+
Version: 1.1.1745
|
4
4
|
Summary: BioLib Python Client
|
5
5
|
Home-page: https://github.com/biolib
|
6
6
|
License: MIT
|
@@ -25,7 +25,6 @@ Requires-Dist: flask (>=2.0.1) ; extra == "compute-node"
|
|
25
25
|
Requires-Dist: gunicorn (>=20.1.0) ; extra == "compute-node"
|
26
26
|
Requires-Dist: importlib-metadata (>=1.6.1)
|
27
27
|
Requires-Dist: pyyaml (>=5.3.1)
|
28
|
-
Requires-Dist: requests (>=2.25.1)
|
29
28
|
Requires-Dist: rich (>=12.4.4)
|
30
29
|
Requires-Dist: typing_extensions (>=3.10.0) ; python_version < "3.8"
|
31
30
|
Description-Content-Type: text/markdown
|
@@ -12,9 +12,9 @@ biolib/app/search_apps.py,sha256=CIanvDebNpMtWck0w4IoR_tRZ6LpSWC8DPxXW2e6Ww4,149
|
|
12
12
|
biolib/biolib_api_client/__init__.py,sha256=E5EMa19wJoblwSdQPYrxc_BtIeRsAuO0L_jQweWw-Yk,182
|
13
13
|
biolib/biolib_api_client/api_client.py,sha256=oaLqTb208TLRVW4-h_va734TrVDRD3kLpFJ93cwQTxk,7130
|
14
14
|
biolib/biolib_api_client/app_types.py,sha256=vEjkpMwaMfz8MxBBZQfWCkxqT7NXxWocB_Oe9WHjJ_g,2425
|
15
|
-
biolib/biolib_api_client/auth.py,sha256=
|
15
|
+
biolib/biolib_api_client/auth.py,sha256=kjm0ZHnH3I8so3su2sZbBxNHYp-ZUdrZ5lwQ0K36RSw,949
|
16
16
|
biolib/biolib_api_client/biolib_account_api.py,sha256=sHng5jDvSktv6tOLKU8wJRieidY2kLxRU8hI_6ZauXE,210
|
17
|
-
biolib/biolib_api_client/biolib_app_api.py,sha256=
|
17
|
+
biolib/biolib_api_client/biolib_app_api.py,sha256=vPFoONWh-i-Bg7pm_x50EQqbN9qQFLgNDTkkWKqDUTY,4248
|
18
18
|
biolib/biolib_api_client/biolib_job_api.py,sha256=IpFahcRzm7GNy8DJ-XHYe-x7r4Voba8o22IXw5puHn8,6782
|
19
19
|
biolib/biolib_api_client/biolib_large_file_system_api.py,sha256=p8QhvQ0aI0NJgyRm7duqDVtPx0zrVaSLKS22ocOafFQ,1038
|
20
20
|
biolib/biolib_api_client/common_types.py,sha256=RH-1KNHqUF-EkTpfPOSTt5Mq1GPdfju_cqXDesscO1I,123
|
@@ -99,10 +99,10 @@ biolib/utils/__init__.py,sha256=AuBhxgZV8-3LWPnewhhYw4isQhPmVs-k55umk8t-r7U,5535
|
|
99
99
|
biolib/utils/app_uri.py,sha256=hOFsTQfA7QbyQyg9ItGdD8VDWBJw0vYMqzLdSiJXmqQ,1857
|
100
100
|
biolib/utils/cache_state.py,sha256=BFrZlV4XZIueIFzAFiPidX4hmwADKY5Y5ZuqlerF5l0,3060
|
101
101
|
biolib/utils/multipart_uploader.py,sha256=XvGP1I8tQuKhAH-QugPRoEsCi9qvbRk-DVBs5PNwwJo,8452
|
102
|
-
biolib/utils/seq_util.py,sha256=
|
103
|
-
biolib/utils/zip/remote_zip.py,sha256=
|
104
|
-
pybiolib-1.1.
|
105
|
-
pybiolib-1.1.
|
106
|
-
pybiolib-1.1.
|
107
|
-
pybiolib-1.1.
|
108
|
-
pybiolib-1.1.
|
102
|
+
biolib/utils/seq_util.py,sha256=3BGUppEaR8asFBxktHCrIW0cMmF23b06PsbDQOoeCDQ,4879
|
103
|
+
biolib/utils/zip/remote_zip.py,sha256=0wErYlxir5921agfFeV1xVjf29l9VNgGQvNlWOlj2Yc,23232
|
104
|
+
pybiolib-1.1.1745.dist-info/LICENSE,sha256=F2h7gf8i0agDIeWoBPXDMYScvQOz02pAWkKhTGOHaaw,1067
|
105
|
+
pybiolib-1.1.1745.dist-info/METADATA,sha256=9o0h8mS0eI03dktYDVNCm_Qjf2JR8EleLReIN1owqgQ,1508
|
106
|
+
pybiolib-1.1.1745.dist-info/WHEEL,sha256=FMvqSimYX_P7y0a7UY-_Mc83r5zkBZsCYPm7Lr0Bsq4,88
|
107
|
+
pybiolib-1.1.1745.dist-info/entry_points.txt,sha256=p6DyaP_2kctxegTX23WBznnrDi4mz6gx04O5uKtRDXg,42
|
108
|
+
pybiolib-1.1.1745.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|