pybiolib 1.2.1228__py3-none-any.whl → 1.2.1235__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/_internal/utils/__init__.py +25 -0
- biolib/app/app.py +2 -2
- biolib/jobs/job.py +42 -2
- biolib/jobs/job_result.py +5 -26
- {pybiolib-1.2.1228.dist-info → pybiolib-1.2.1235.dist-info}/METADATA +1 -1
- {pybiolib-1.2.1228.dist-info → pybiolib-1.2.1235.dist-info}/RECORD +9 -9
- {pybiolib-1.2.1228.dist-info → pybiolib-1.2.1235.dist-info}/WHEEL +0 -0
- {pybiolib-1.2.1228.dist-info → pybiolib-1.2.1235.dist-info}/entry_points.txt +0 -0
- {pybiolib-1.2.1228.dist-info → pybiolib-1.2.1235.dist-info}/licenses/LICENSE +0 -0
@@ -1,5 +1,30 @@
|
|
1
1
|
import time
|
2
2
|
import uuid
|
3
|
+
from fnmatch import fnmatch
|
4
|
+
|
5
|
+
from biolib.biolib_binary_format.utils import LazyLoadedFile
|
6
|
+
from biolib.typing_utils import Callable, List, Union, cast
|
7
|
+
|
8
|
+
PathFilter = Union[str, Callable[[str], bool]]
|
9
|
+
|
10
|
+
|
11
|
+
def filter_lazy_loaded_files(files: List[LazyLoadedFile], path_filter: PathFilter) -> List[LazyLoadedFile]:
|
12
|
+
if not (isinstance(path_filter, str) or callable(path_filter)):
|
13
|
+
raise Exception('Expected path_filter to be a string or a function')
|
14
|
+
|
15
|
+
if callable(path_filter):
|
16
|
+
return list(filter(lambda x: path_filter(x.path), files)) # type: ignore
|
17
|
+
|
18
|
+
glob_filter = cast(str, path_filter)
|
19
|
+
|
20
|
+
# since all file paths start with /, make sure filter does too
|
21
|
+
if not glob_filter.startswith('/'):
|
22
|
+
glob_filter = '/' + glob_filter
|
23
|
+
|
24
|
+
def _filter_function(file: LazyLoadedFile) -> bool:
|
25
|
+
return fnmatch(file.path, glob_filter)
|
26
|
+
|
27
|
+
return list(filter(_filter_function, files))
|
3
28
|
|
4
29
|
|
5
30
|
def open_browser_window_from_notebook(url_to_open: str) -> None:
|
biolib/app/app.py
CHANGED
@@ -72,7 +72,7 @@ class BioLibApp:
|
|
72
72
|
result_prefix: Optional[str] = None,
|
73
73
|
timeout: Optional[int] = None,
|
74
74
|
notify: bool = False,
|
75
|
-
|
75
|
+
max_workers: Optional[int] = None,
|
76
76
|
experiment: Optional[str] = None,
|
77
77
|
temporary_client_secrets: Optional[Dict[str, str]] = None,
|
78
78
|
check: bool = False,
|
@@ -112,7 +112,7 @@ class BioLibApp:
|
|
112
112
|
override_command=override_command,
|
113
113
|
result_prefix=result_prefix,
|
114
114
|
timeout=timeout,
|
115
|
-
requested_machine_count=
|
115
|
+
requested_machine_count=max_workers,
|
116
116
|
temporary_client_secrets=temporary_client_secrets,
|
117
117
|
api_client=self._api_client,
|
118
118
|
)
|
biolib/jobs/job.py
CHANGED
@@ -10,7 +10,7 @@ import biolib.api.client
|
|
10
10
|
from biolib import utils
|
11
11
|
from biolib._internal.http_client import HttpClient
|
12
12
|
from biolib._internal.tree_utils import build_tree_from_files, build_tree_str
|
13
|
-
from biolib._internal.utils import open_browser_window_from_notebook
|
13
|
+
from biolib._internal.utils import PathFilter, filter_lazy_loaded_files, open_browser_window_from_notebook
|
14
14
|
from biolib.api.client import ApiClient
|
15
15
|
from biolib.biolib_api_client import BiolibApiClient, CreatedJobDict
|
16
16
|
from biolib.biolib_api_client.biolib_app_api import BiolibAppApi
|
@@ -18,11 +18,12 @@ from biolib.biolib_api_client.biolib_job_api import BiolibJobApi
|
|
18
18
|
from biolib.biolib_binary_format import LazyLoadedFile, ModuleInput, ModuleInputDict, ModuleOutputV2
|
19
19
|
from biolib.biolib_binary_format.remote_endpoints import RemoteJobStorageEndpoint
|
20
20
|
from biolib.biolib_binary_format.stdout_and_stderr import StdoutAndStderr
|
21
|
+
from biolib.biolib_binary_format.utils import InMemoryIndexableBuffer
|
21
22
|
from biolib.biolib_errors import BioLibError, CloudJobFinishedError
|
22
23
|
from biolib.biolib_logging import logger, logger_no_user_data
|
23
24
|
from biolib.compute_node.job_worker.job_storage import JobStorage
|
24
25
|
from biolib.compute_node.utils import SystemExceptionCodeMap, SystemExceptionCodes
|
25
|
-
from biolib.jobs.job_result import JobResult
|
26
|
+
from biolib.jobs.job_result import JobResult
|
26
27
|
from biolib.jobs.types import CloudJobDict, CloudJobStartedDict, JobDict
|
27
28
|
from biolib.tables import BioLibTable
|
28
29
|
from biolib.typing_utils import Dict, List, Optional, Union, cast
|
@@ -187,6 +188,45 @@ class Result:
|
|
187
188
|
"""
|
188
189
|
return self.result.list_output_files(path_filter=path_filter)
|
189
190
|
|
191
|
+
def list_input_files(
|
192
|
+
self,
|
193
|
+
path_filter: Optional[PathFilter] = None,
|
194
|
+
) -> List[LazyLoadedFile]:
|
195
|
+
"""List input files from the result.
|
196
|
+
|
197
|
+
Args:
|
198
|
+
path_filter (PathFilter, optional): Filter to apply to the input files.
|
199
|
+
Can be a string glob pattern or a callable that takes a path string and returns a boolean.
|
200
|
+
|
201
|
+
Returns:
|
202
|
+
List[LazyLoadedFile]: List of input files.
|
203
|
+
|
204
|
+
Example::
|
205
|
+
>>> result = biolib.get_result("result_id")
|
206
|
+
>>> input_files = result.list_input_files()
|
207
|
+
>>> # Filter files with a glob pattern
|
208
|
+
>>> input_files = result.list_input_files("*.txt")
|
209
|
+
"""
|
210
|
+
presigned_download_url = BiolibJobApi.get_job_storage_download_url(
|
211
|
+
job_uuid=self.id,
|
212
|
+
job_auth_token=self._auth_token,
|
213
|
+
storage_type='input',
|
214
|
+
)
|
215
|
+
response = HttpClient.request(url=presigned_download_url)
|
216
|
+
module_input_serialized: bytes = response.content
|
217
|
+
module_input = ModuleInput(module_input_serialized).deserialize()
|
218
|
+
|
219
|
+
files = []
|
220
|
+
for path, data in module_input['files'].items():
|
221
|
+
buffer = InMemoryIndexableBuffer(data)
|
222
|
+
lazy_file = LazyLoadedFile(path=path, buffer=buffer, start=0, length=len(data))
|
223
|
+
files.append(lazy_file)
|
224
|
+
|
225
|
+
if not path_filter:
|
226
|
+
return files
|
227
|
+
|
228
|
+
return filter_lazy_loaded_files(files, path_filter)
|
229
|
+
|
190
230
|
def get_output_file(self, filename: str) -> LazyLoadedFile:
|
191
231
|
return self.result.get_output_file(filename=filename)
|
192
232
|
|
biolib/jobs/job_result.py
CHANGED
@@ -1,16 +1,14 @@
|
|
1
1
|
import time
|
2
|
-
from fnmatch import fnmatch
|
3
2
|
from pathlib import Path
|
4
3
|
|
4
|
+
from biolib._internal.utils import PathFilter, filter_lazy_loaded_files
|
5
5
|
from biolib.biolib_binary_format import ModuleOutputV2
|
6
6
|
from biolib.biolib_binary_format.remote_endpoints import RemoteJobStorageEndpoint
|
7
7
|
from biolib.biolib_binary_format.remote_stream_seeker import StreamSeeker
|
8
8
|
from biolib.biolib_binary_format.utils import LazyLoadedFile, RemoteIndexableBuffer
|
9
9
|
from biolib.biolib_errors import BioLibError
|
10
10
|
from biolib.biolib_logging import logger
|
11
|
-
from biolib.typing_utils import
|
12
|
-
|
13
|
-
PathFilter = Union[str, Callable[[str], bool]]
|
11
|
+
from biolib.typing_utils import List, Optional
|
14
12
|
|
15
13
|
|
16
14
|
class JobResult:
|
@@ -43,7 +41,7 @@ class JobResult:
|
|
43
41
|
) -> None:
|
44
42
|
module_output = self._get_module_output()
|
45
43
|
output_files = module_output.get_files()
|
46
|
-
filtered_output_files =
|
44
|
+
filtered_output_files = filter_lazy_loaded_files(output_files, path_filter) if path_filter else output_files
|
47
45
|
|
48
46
|
if len(filtered_output_files) == 0:
|
49
47
|
logger.debug('No output files to save')
|
@@ -100,7 +98,7 @@ class JobResult:
|
|
100
98
|
|
101
99
|
def get_output_file(self, filename) -> LazyLoadedFile:
|
102
100
|
files = self._get_module_output().get_files()
|
103
|
-
filtered_files =
|
101
|
+
filtered_files = filter_lazy_loaded_files(files, path_filter=filename)
|
104
102
|
if not filtered_files:
|
105
103
|
raise BioLibError(f'File {filename} not found in results.')
|
106
104
|
|
@@ -114,26 +112,7 @@ class JobResult:
|
|
114
112
|
if not path_filter:
|
115
113
|
return files
|
116
114
|
|
117
|
-
return
|
118
|
-
|
119
|
-
@staticmethod
|
120
|
-
def _get_filtered_files(files: List[LazyLoadedFile], path_filter: PathFilter) -> List[LazyLoadedFile]:
|
121
|
-
if not (isinstance(path_filter, str) or callable(path_filter)):
|
122
|
-
raise Exception('Expected path_filter to be a string or a function')
|
123
|
-
|
124
|
-
if callable(path_filter):
|
125
|
-
return list(filter(lambda x: path_filter(x.path), files)) # type: ignore
|
126
|
-
|
127
|
-
glob_filter = cast(str, path_filter)
|
128
|
-
|
129
|
-
# since all file paths start with /, make sure filter does too
|
130
|
-
if not glob_filter.startswith('/'):
|
131
|
-
glob_filter = '/' + glob_filter
|
132
|
-
|
133
|
-
def _filter_function(file: LazyLoadedFile) -> bool:
|
134
|
-
return fnmatch(file.path, glob_filter)
|
135
|
-
|
136
|
-
return list(filter(_filter_function, files))
|
115
|
+
return filter_lazy_loaded_files(files, path_filter)
|
137
116
|
|
138
117
|
def _get_module_output(self) -> ModuleOutputV2:
|
139
118
|
if self._module_output is None:
|
@@ -59,14 +59,14 @@ biolib/_internal/types/resource_version.py,sha256=cU0YFHqxO-wX_Y6CoeK0Iei61gFwVo
|
|
59
59
|
biolib/_internal/types/result.py,sha256=MesSTBXCkaw8HydXgHf1OKGVLzsxhZ1KV5z4w-VI-0M,231
|
60
60
|
biolib/_internal/types/typing.py,sha256=qrsk8hHcGEbDpU1QQFzHAKnhQxkMe7uJ6pxHeAnfv1Y,414
|
61
61
|
biolib/_internal/types/user.py,sha256=5_hYG0jrdGxynCCWXGaHZCAlVcRKBqMIEA2EBGrnpiE,439
|
62
|
-
biolib/_internal/utils/__init__.py,sha256=
|
62
|
+
biolib/_internal/utils/__init__.py,sha256=xp1I-lVnu5owV1CW53jiPEZLKmqqHiPUDfauYDfJ7iQ,1540
|
63
63
|
biolib/_internal/utils/multinode.py,sha256=N7kR49xD1PdkMVlxxzRiSYHfgi9MG-kLCwemcY1rojg,8323
|
64
64
|
biolib/_runtime/runtime.py,sha256=vRJ0YFSGYVHWULam_fnS2EHmNEm_qkrJXWdsy0n8JDA,5857
|
65
65
|
biolib/_session/session.py,sha256=US1Y1jfFIAm86-Lq3C7nCXpZXUJXXBVBkND9djMNYxI,1649
|
66
66
|
biolib/api/__init__.py,sha256=mQ4u8FijqyLzjYMezMUUbbBGNB3iFmkNdjXnWPZ7Jlw,138
|
67
67
|
biolib/api/client.py,sha256=2GpKE7QrPgyPdgJgrV7XnZByIJf1n26UCy3aoaHBs1M,7881
|
68
68
|
biolib/app/__init__.py,sha256=cdPtcfb_U-bxb9iSL4fCEq2rpD9OjkyY4W-Zw60B0LI,37
|
69
|
-
biolib/app/app.py,sha256=
|
69
|
+
biolib/app/app.py,sha256=Jc2PwNsZDKca9NxvasI_yrnb0q_S9PrJ94lva-y2Zpc,11882
|
70
70
|
biolib/app/search_apps.py,sha256=K4a41f5XIWth2BWI7OffASgIsD0ko8elCax8YL2igaY,1470
|
71
71
|
biolib/biolib_api_client/__init__.py,sha256=E5EMa19wJoblwSdQPYrxc_BtIeRsAuO0L_jQweWw-Yk,182
|
72
72
|
biolib/biolib_api_client/api_client.py,sha256=IONzXeFCHl4wuct6fqOC_7NiTv_zFy6ys0hsAtvLzTA,7578
|
@@ -141,8 +141,8 @@ biolib/compute_node/webserver/worker_thread.py,sha256=7uD9yQPhePYvP2HCJ27EeZ_h6p
|
|
141
141
|
biolib/experiments/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
142
142
|
biolib/experiments/experiment.py,sha256=4g1xMYmfp5yzSOdwjf3pUUULF9QjqBJb4uQ25FHrFrk,13688
|
143
143
|
biolib/jobs/__init__.py,sha256=aIb2H2DHjQbM2Bs-dysFijhwFcL58Blp0Co0gimED3w,32
|
144
|
-
biolib/jobs/job.py,sha256=
|
145
|
-
biolib/jobs/job_result.py,sha256=
|
144
|
+
biolib/jobs/job.py,sha256=7giHZfDt1lux8Nl2BZKwtVNaLr-vCcwFYZ28Cs_tZN0,28957
|
145
|
+
biolib/jobs/job_result.py,sha256=_xqQu9z9BqPQrU6tjqKPuKlQDt5W0Zw5xiQvzEBkDyE,5266
|
146
146
|
biolib/jobs/types.py,sha256=ezvaoTANsWazK6PmfpYcqezdfjP7MNBEBfqIZGoZhz8,997
|
147
147
|
biolib/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
148
148
|
biolib/runtime/__init__.py,sha256=MlRepA11n2H-3plB5rzWyyHK2JmP6PiaP3i6x3vt0mg,506
|
@@ -157,8 +157,8 @@ biolib/utils/cache_state.py,sha256=u256F37QSRIVwqKlbnCyzAX4EMI-kl6Dwu6qwj-Qmag,3
|
|
157
157
|
biolib/utils/multipart_uploader.py,sha256=XvGP1I8tQuKhAH-QugPRoEsCi9qvbRk-DVBs5PNwwJo,8452
|
158
158
|
biolib/utils/seq_util.py,sha256=rImaghQGuIqTVWks6b9P2yKuN34uePUYPUFW_Wyoa4A,6737
|
159
159
|
biolib/utils/zip/remote_zip.py,sha256=0wErYlxir5921agfFeV1xVjf29l9VNgGQvNlWOlj2Yc,23232
|
160
|
-
pybiolib-1.2.
|
161
|
-
pybiolib-1.2.
|
162
|
-
pybiolib-1.2.
|
163
|
-
pybiolib-1.2.
|
164
|
-
pybiolib-1.2.
|
160
|
+
pybiolib-1.2.1235.dist-info/METADATA,sha256=BfK36P1WXe47dq0raBjDfGe46dGTtqQmMma7Ms8Vf_o,1644
|
161
|
+
pybiolib-1.2.1235.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
|
162
|
+
pybiolib-1.2.1235.dist-info/entry_points.txt,sha256=p6DyaP_2kctxegTX23WBznnrDi4mz6gx04O5uKtRDXg,42
|
163
|
+
pybiolib-1.2.1235.dist-info/licenses/LICENSE,sha256=F2h7gf8i0agDIeWoBPXDMYScvQOz02pAWkKhTGOHaaw,1067
|
164
|
+
pybiolib-1.2.1235.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|