pybiolib 1.1.1974__tar.gz → 1.1.1979__tar.gz
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.
- {pybiolib-1.1.1974 → pybiolib-1.1.1979}/PKG-INFO +1 -1
- {pybiolib-1.1.1974 → pybiolib-1.1.1979}/biolib/app/app.py +32 -71
- {pybiolib-1.1.1974 → pybiolib-1.1.1979}/biolib/biolib_binary_format/remote_endpoints.py +12 -10
- {pybiolib-1.1.1974 → pybiolib-1.1.1979}/biolib/cli/auth.py +1 -1
- {pybiolib-1.1.1974 → pybiolib-1.1.1979}/biolib/jobs/job.py +67 -1
- {pybiolib-1.1.1974 → pybiolib-1.1.1979}/biolib/jobs/job_result.py +4 -3
- {pybiolib-1.1.1974 → pybiolib-1.1.1979}/pyproject.toml +1 -1
- {pybiolib-1.1.1974 → pybiolib-1.1.1979}/LICENSE +0 -0
- {pybiolib-1.1.1974 → pybiolib-1.1.1979}/README.md +0 -0
- {pybiolib-1.1.1974 → pybiolib-1.1.1979}/biolib/__init__.py +0 -0
- {pybiolib-1.1.1974 → pybiolib-1.1.1979}/biolib/_internal/__init__.py +0 -0
- {pybiolib-1.1.1974 → pybiolib-1.1.1979}/biolib/_internal/data_record/__init__.py +0 -0
- {pybiolib-1.1.1974 → pybiolib-1.1.1979}/biolib/_internal/data_record/data_record.py +0 -0
- {pybiolib-1.1.1974 → pybiolib-1.1.1979}/biolib/_internal/data_record/remote_storage_endpoint.py +0 -0
- {pybiolib-1.1.1974 → pybiolib-1.1.1979}/biolib/_internal/fuse_mount/__init__.py +0 -0
- {pybiolib-1.1.1974 → pybiolib-1.1.1979}/biolib/_internal/fuse_mount/experiment_fuse_mount.py +0 -0
- {pybiolib-1.1.1974 → pybiolib-1.1.1979}/biolib/_internal/http_client.py +0 -0
- {pybiolib-1.1.1974 → pybiolib-1.1.1979}/biolib/_internal/libs/__init__.py +0 -0
- {pybiolib-1.1.1974 → pybiolib-1.1.1979}/biolib/_internal/libs/fusepy/__init__.py +0 -0
- {pybiolib-1.1.1974 → pybiolib-1.1.1979}/biolib/_internal/push_application.py +0 -0
- {pybiolib-1.1.1974 → pybiolib-1.1.1979}/biolib/_internal/runtime.py +0 -0
- {pybiolib-1.1.1974 → pybiolib-1.1.1979}/biolib/_internal/utils/__init__.py +0 -0
- {pybiolib-1.1.1974 → pybiolib-1.1.1979}/biolib/api/__init__.py +0 -0
- {pybiolib-1.1.1974 → pybiolib-1.1.1979}/biolib/api/client.py +0 -0
- {pybiolib-1.1.1974 → pybiolib-1.1.1979}/biolib/app/__init__.py +0 -0
- {pybiolib-1.1.1974 → pybiolib-1.1.1979}/biolib/app/search_apps.py +0 -0
- {pybiolib-1.1.1974 → pybiolib-1.1.1979}/biolib/biolib_api_client/__init__.py +0 -0
- {pybiolib-1.1.1974 → pybiolib-1.1.1979}/biolib/biolib_api_client/api_client.py +0 -0
- {pybiolib-1.1.1974 → pybiolib-1.1.1979}/biolib/biolib_api_client/app_types.py +0 -0
- {pybiolib-1.1.1974 → pybiolib-1.1.1979}/biolib/biolib_api_client/auth.py +0 -0
- {pybiolib-1.1.1974 → pybiolib-1.1.1979}/biolib/biolib_api_client/biolib_app_api.py +0 -0
- {pybiolib-1.1.1974 → pybiolib-1.1.1979}/biolib/biolib_api_client/biolib_job_api.py +0 -0
- {pybiolib-1.1.1974 → pybiolib-1.1.1979}/biolib/biolib_api_client/common_types.py +0 -0
- {pybiolib-1.1.1974 → pybiolib-1.1.1979}/biolib/biolib_api_client/job_types.py +0 -0
- {pybiolib-1.1.1974 → pybiolib-1.1.1979}/biolib/biolib_api_client/lfs_types.py +0 -0
- {pybiolib-1.1.1974 → pybiolib-1.1.1979}/biolib/biolib_api_client/user_state.py +0 -0
- {pybiolib-1.1.1974 → pybiolib-1.1.1979}/biolib/biolib_binary_format/__init__.py +0 -0
- {pybiolib-1.1.1974 → pybiolib-1.1.1979}/biolib/biolib_binary_format/base_bbf_package.py +0 -0
- {pybiolib-1.1.1974 → pybiolib-1.1.1979}/biolib/biolib_binary_format/file_in_container.py +0 -0
- {pybiolib-1.1.1974 → pybiolib-1.1.1979}/biolib/biolib_binary_format/module_input.py +0 -0
- {pybiolib-1.1.1974 → pybiolib-1.1.1979}/biolib/biolib_binary_format/module_output_v2.py +0 -0
- {pybiolib-1.1.1974 → pybiolib-1.1.1979}/biolib/biolib_binary_format/remote_stream_seeker.py +0 -0
- {pybiolib-1.1.1974 → pybiolib-1.1.1979}/biolib/biolib_binary_format/saved_job.py +0 -0
- {pybiolib-1.1.1974 → pybiolib-1.1.1979}/biolib/biolib_binary_format/stdout_and_stderr.py +0 -0
- {pybiolib-1.1.1974 → pybiolib-1.1.1979}/biolib/biolib_binary_format/system_exception.py +0 -0
- {pybiolib-1.1.1974 → pybiolib-1.1.1979}/biolib/biolib_binary_format/system_status_update.py +0 -0
- {pybiolib-1.1.1974 → pybiolib-1.1.1979}/biolib/biolib_binary_format/utils.py +0 -0
- {pybiolib-1.1.1974 → pybiolib-1.1.1979}/biolib/biolib_docker_client/__init__.py +0 -0
- {pybiolib-1.1.1974 → pybiolib-1.1.1979}/biolib/biolib_download_container.py +0 -0
- {pybiolib-1.1.1974 → pybiolib-1.1.1979}/biolib/biolib_errors.py +0 -0
- {pybiolib-1.1.1974 → pybiolib-1.1.1979}/biolib/biolib_logging.py +0 -0
- {pybiolib-1.1.1974 → pybiolib-1.1.1979}/biolib/cli/__init__.py +0 -0
- {pybiolib-1.1.1974 → pybiolib-1.1.1979}/biolib/cli/data_record.py +0 -0
- {pybiolib-1.1.1974 → pybiolib-1.1.1979}/biolib/cli/download_container.py +0 -0
- {pybiolib-1.1.1974 → pybiolib-1.1.1979}/biolib/cli/init.py +0 -0
- {pybiolib-1.1.1974 → pybiolib-1.1.1979}/biolib/cli/lfs.py +0 -0
- {pybiolib-1.1.1974 → pybiolib-1.1.1979}/biolib/cli/push.py +0 -0
- {pybiolib-1.1.1974 → pybiolib-1.1.1979}/biolib/cli/run.py +0 -0
- {pybiolib-1.1.1974 → pybiolib-1.1.1979}/biolib/cli/runtime.py +0 -0
- {pybiolib-1.1.1974 → pybiolib-1.1.1979}/biolib/cli/start.py +0 -0
- {pybiolib-1.1.1974 → pybiolib-1.1.1979}/biolib/compute_node/.gitignore +0 -0
- {pybiolib-1.1.1974 → pybiolib-1.1.1979}/biolib/compute_node/__init__.py +0 -0
- {pybiolib-1.1.1974 → pybiolib-1.1.1979}/biolib/compute_node/cloud_utils/__init__.py +0 -0
- {pybiolib-1.1.1974 → pybiolib-1.1.1979}/biolib/compute_node/cloud_utils/cloud_utils.py +0 -0
- {pybiolib-1.1.1974 → pybiolib-1.1.1979}/biolib/compute_node/job_worker/__init__.py +0 -0
- {pybiolib-1.1.1974 → pybiolib-1.1.1979}/biolib/compute_node/job_worker/cache_state.py +0 -0
- {pybiolib-1.1.1974 → pybiolib-1.1.1979}/biolib/compute_node/job_worker/cache_types.py +0 -0
- {pybiolib-1.1.1974 → pybiolib-1.1.1979}/biolib/compute_node/job_worker/docker_image_cache.py +0 -0
- {pybiolib-1.1.1974 → pybiolib-1.1.1979}/biolib/compute_node/job_worker/executors/__init__.py +0 -0
- {pybiolib-1.1.1974 → pybiolib-1.1.1979}/biolib/compute_node/job_worker/executors/docker_executor.py +0 -0
- {pybiolib-1.1.1974 → pybiolib-1.1.1979}/biolib/compute_node/job_worker/executors/docker_types.py +0 -0
- {pybiolib-1.1.1974 → pybiolib-1.1.1979}/biolib/compute_node/job_worker/executors/tars/__init__.py +0 -0
- {pybiolib-1.1.1974 → pybiolib-1.1.1979}/biolib/compute_node/job_worker/executors/types.py +0 -0
- {pybiolib-1.1.1974 → pybiolib-1.1.1979}/biolib/compute_node/job_worker/job_legacy_input_wait_timeout_thread.py +0 -0
- {pybiolib-1.1.1974 → pybiolib-1.1.1979}/biolib/compute_node/job_worker/job_max_runtime_timer_thread.py +0 -0
- {pybiolib-1.1.1974 → pybiolib-1.1.1979}/biolib/compute_node/job_worker/job_storage.py +0 -0
- {pybiolib-1.1.1974 → pybiolib-1.1.1979}/biolib/compute_node/job_worker/job_worker.py +0 -0
- {pybiolib-1.1.1974 → pybiolib-1.1.1979}/biolib/compute_node/job_worker/large_file_system.py +0 -0
- {pybiolib-1.1.1974 → pybiolib-1.1.1979}/biolib/compute_node/job_worker/mappings.py +0 -0
- {pybiolib-1.1.1974 → pybiolib-1.1.1979}/biolib/compute_node/job_worker/utilization_reporter_thread.py +0 -0
- {pybiolib-1.1.1974 → pybiolib-1.1.1979}/biolib/compute_node/job_worker/utils.py +0 -0
- {pybiolib-1.1.1974 → pybiolib-1.1.1979}/biolib/compute_node/remote_host_proxy.py +0 -0
- {pybiolib-1.1.1974 → pybiolib-1.1.1979}/biolib/compute_node/socker_listener_thread.py +0 -0
- {pybiolib-1.1.1974 → pybiolib-1.1.1979}/biolib/compute_node/socket_sender_thread.py +0 -0
- {pybiolib-1.1.1974 → pybiolib-1.1.1979}/biolib/compute_node/utils.py +0 -0
- {pybiolib-1.1.1974 → pybiolib-1.1.1979}/biolib/compute_node/webserver/__init__.py +0 -0
- {pybiolib-1.1.1974 → pybiolib-1.1.1979}/biolib/compute_node/webserver/gunicorn_flask_application.py +0 -0
- {pybiolib-1.1.1974 → pybiolib-1.1.1979}/biolib/compute_node/webserver/webserver.py +0 -0
- {pybiolib-1.1.1974 → pybiolib-1.1.1979}/biolib/compute_node/webserver/webserver_types.py +0 -0
- {pybiolib-1.1.1974 → pybiolib-1.1.1979}/biolib/compute_node/webserver/webserver_utils.py +0 -0
- {pybiolib-1.1.1974 → pybiolib-1.1.1979}/biolib/compute_node/webserver/worker_thread.py +0 -0
- {pybiolib-1.1.1974 → pybiolib-1.1.1979}/biolib/experiments/__init__.py +0 -0
- {pybiolib-1.1.1974 → pybiolib-1.1.1979}/biolib/experiments/experiment.py +0 -0
- {pybiolib-1.1.1974 → pybiolib-1.1.1979}/biolib/experiments/types.py +0 -0
- {pybiolib-1.1.1974 → pybiolib-1.1.1979}/biolib/jobs/__init__.py +0 -0
- {pybiolib-1.1.1974 → pybiolib-1.1.1979}/biolib/jobs/types.py +0 -0
- {pybiolib-1.1.1974 → pybiolib-1.1.1979}/biolib/lfs/__init__.py +0 -0
- {pybiolib-1.1.1974 → pybiolib-1.1.1979}/biolib/lfs/cache.py +0 -0
- {pybiolib-1.1.1974 → pybiolib-1.1.1979}/biolib/lfs/utils.py +0 -0
- {pybiolib-1.1.1974 → pybiolib-1.1.1979}/biolib/runtime/__init__.py +0 -0
- {pybiolib-1.1.1974 → pybiolib-1.1.1979}/biolib/sdk/__init__.py +0 -0
- {pybiolib-1.1.1974 → pybiolib-1.1.1979}/biolib/tables.py +0 -0
- {pybiolib-1.1.1974 → pybiolib-1.1.1979}/biolib/templates/__init__.py +0 -0
- {pybiolib-1.1.1974 → pybiolib-1.1.1979}/biolib/templates/example_app.py +0 -0
- {pybiolib-1.1.1974 → pybiolib-1.1.1979}/biolib/typing_utils.py +0 -0
- {pybiolib-1.1.1974 → pybiolib-1.1.1979}/biolib/user/__init__.py +0 -0
- {pybiolib-1.1.1974 → pybiolib-1.1.1979}/biolib/user/sign_in.py +0 -0
- {pybiolib-1.1.1974 → pybiolib-1.1.1979}/biolib/utils/__init__.py +0 -0
- {pybiolib-1.1.1974 → pybiolib-1.1.1979}/biolib/utils/app_uri.py +0 -0
- {pybiolib-1.1.1974 → pybiolib-1.1.1979}/biolib/utils/cache_state.py +0 -0
- {pybiolib-1.1.1974 → pybiolib-1.1.1979}/biolib/utils/multipart_uploader.py +0 -0
- {pybiolib-1.1.1974 → pybiolib-1.1.1979}/biolib/utils/seq_util.py +0 -0
- {pybiolib-1.1.1974 → pybiolib-1.1.1979}/biolib/utils/zip/remote_zip.py +0 -0
@@ -1,29 +1,26 @@
|
|
1
|
-
import os
|
2
1
|
import io
|
3
|
-
import random
|
4
2
|
import json
|
3
|
+
import os
|
4
|
+
import random
|
5
5
|
import string
|
6
|
-
|
7
6
|
from pathlib import Path
|
7
|
+
|
8
8
|
from biolib import utils
|
9
|
-
from biolib.
|
10
|
-
from biolib.compute_node.job_worker.job_worker import JobWorker
|
11
|
-
from biolib.experiments.experiment import Experiment
|
12
|
-
from biolib.jobs import Job
|
13
|
-
from biolib.typing_utils import Optional, cast
|
14
|
-
from biolib.biolib_api_client import CreatedJobDict, JobState
|
15
|
-
from biolib.jobs.types import JobDict
|
9
|
+
from biolib.biolib_api_client import JobState
|
16
10
|
from biolib.biolib_api_client.app_types import App, AppVersion
|
17
|
-
from biolib.biolib_api_client.biolib_job_api import BiolibJobApi
|
18
11
|
from biolib.biolib_api_client.biolib_app_api import BiolibAppApi
|
12
|
+
from biolib.biolib_api_client.biolib_job_api import BiolibJobApi
|
19
13
|
from biolib.biolib_binary_format import ModuleInput
|
20
14
|
from biolib.biolib_errors import BioLibError
|
21
15
|
from biolib.biolib_logging import logger
|
16
|
+
from biolib.compute_node.job_worker.job_worker import JobWorker
|
17
|
+
from biolib.experiments.experiment import Experiment
|
18
|
+
from biolib.jobs import Job
|
19
|
+
from biolib.typing_utils import Optional
|
22
20
|
from biolib.utils.app_uri import parse_app_uri
|
23
21
|
|
24
22
|
|
25
23
|
class BioLibApp:
|
26
|
-
|
27
24
|
def __init__(self, uri: str):
|
28
25
|
app_response = BiolibAppApi.get_by_uri(uri)
|
29
26
|
self._app: App = app_response['app']
|
@@ -48,17 +45,17 @@ class BioLibApp:
|
|
48
45
|
return self._app_version
|
49
46
|
|
50
47
|
def cli(
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
48
|
+
self,
|
49
|
+
args=None,
|
50
|
+
stdin=None,
|
51
|
+
files=None,
|
52
|
+
override_command=False,
|
53
|
+
machine='',
|
54
|
+
blocking: bool = True,
|
55
|
+
experiment_id: Optional[str] = None,
|
56
|
+
result_prefix: Optional[str] = None,
|
57
|
+
timeout: Optional[int] = None,
|
58
|
+
notify: bool = False,
|
62
59
|
) -> Job:
|
63
60
|
if not experiment_id:
|
64
61
|
experiment = Experiment.get_experiment_in_context()
|
@@ -78,7 +75,9 @@ class BioLibApp:
|
|
78
75
|
|
79
76
|
return self._run_locally(module_input_serialized)
|
80
77
|
|
81
|
-
job =
|
78
|
+
job = Job._start_job_in_cloud( # pylint: disable=protected-access
|
79
|
+
app_uri=self._app_uri,
|
80
|
+
app_version_uuid=self._app_version['public_id'],
|
82
81
|
experiment_id=experiment_id,
|
83
82
|
machine=machine,
|
84
83
|
module_input_serialized=module_input_serialized,
|
@@ -93,8 +92,8 @@ class BioLibApp:
|
|
93
92
|
utils.STREAM_STDOUT = True
|
94
93
|
|
95
94
|
enable_print = bool(
|
96
|
-
utils.STREAM_STDOUT
|
97
|
-
(self._app_version.get('main_output_file') or self._app_version.get('stdout_render_type') == 'text')
|
95
|
+
utils.STREAM_STDOUT
|
96
|
+
and (self._app_version.get('main_output_file') or self._app_version.get('stdout_render_type') == 'text')
|
98
97
|
)
|
99
98
|
job._stream_logs(enable_print=enable_print) # pylint: disable=protected-access
|
100
99
|
|
@@ -108,11 +107,11 @@ class BioLibApp:
|
|
108
107
|
self.cli()
|
109
108
|
|
110
109
|
else:
|
111
|
-
raise BioLibError(
|
110
|
+
raise BioLibError("""
|
112
111
|
Calling an app directly with app() is currently being reworked.
|
113
112
|
To use the previous functionality, please call app.cli() instead.
|
114
113
|
Example: "app.cli('--help')"
|
115
|
-
|
114
|
+
""")
|
116
115
|
|
117
116
|
@staticmethod
|
118
117
|
def _get_serialized_module_input(args=None, stdin=None, files=None) -> bytes:
|
@@ -142,9 +141,9 @@ Example: "app.cli('--help')"
|
|
142
141
|
args[idx] = Path(arg).name
|
143
142
|
|
144
143
|
# support --myarg=file.txt
|
145
|
-
elif os.path.isfile(arg.split(
|
146
|
-
files.append(arg.split(
|
147
|
-
args[idx] = arg.split(
|
144
|
+
elif os.path.isfile(arg.split('=')[-1]) or os.path.isdir(arg.split('=')[-1]):
|
145
|
+
files.append(arg.split('=')[-1])
|
146
|
+
args[idx] = arg.split('=')[0] + '=' + Path(arg.split('=')[-1]).name
|
148
147
|
else:
|
149
148
|
pass # a normal string arg was given
|
150
149
|
else:
|
@@ -154,7 +153,7 @@ Example: "app.cli('--help')"
|
|
154
153
|
elif isinstance(arg, io.BytesIO):
|
155
154
|
file_data = arg.getvalue()
|
156
155
|
else:
|
157
|
-
raise Exception(f
|
156
|
+
raise Exception(f'Unexpected type of argument: {arg}')
|
158
157
|
files_dict[f'/{tmp_filename}'] = file_data
|
159
158
|
args[idx] = tmp_filename
|
160
159
|
|
@@ -192,48 +191,10 @@ Example: "app.cli('--help')"
|
|
192
191
|
)
|
193
192
|
return module_input_serialized
|
194
193
|
|
195
|
-
def _start_in_cloud(
|
196
|
-
self,
|
197
|
-
module_input_serialized: bytes,
|
198
|
-
override_command: bool = False,
|
199
|
-
machine: Optional[str] = None,
|
200
|
-
experiment_id: Optional[str] = None,
|
201
|
-
result_prefix: Optional[str] = None,
|
202
|
-
timeout: Optional[int] = None,
|
203
|
-
notify: bool = False,
|
204
|
-
) -> Job:
|
205
|
-
if len(module_input_serialized) < 500_000:
|
206
|
-
_job_dict = BiolibJobApi.create_job_with_data(
|
207
|
-
app_resource_name_prefix=parse_app_uri(self._app_uri)['resource_name_prefix'],
|
208
|
-
app_version_uuid=self._app_version['public_id'],
|
209
|
-
arguments_override_command=override_command,
|
210
|
-
experiment_uuid=experiment_id,
|
211
|
-
module_input_serialized=module_input_serialized,
|
212
|
-
notify=notify,
|
213
|
-
requested_machine=machine,
|
214
|
-
requested_timeout_seconds=timeout,
|
215
|
-
result_name_prefix=result_prefix,
|
216
|
-
)
|
217
|
-
return Job(cast(JobDict, _job_dict))
|
218
|
-
|
219
|
-
job_dict: CreatedJobDict = BiolibJobApi.create(
|
220
|
-
app_resource_name_prefix=parse_app_uri(self._app_uri)['resource_name_prefix'],
|
221
|
-
app_version_id=self._app_version['public_id'],
|
222
|
-
experiment_uuid=experiment_id,
|
223
|
-
machine=machine,
|
224
|
-
notify=notify,
|
225
|
-
override_command=override_command,
|
226
|
-
timeout=timeout,
|
227
|
-
)
|
228
|
-
JobStorage.upload_module_input(job=job_dict, module_input_serialized=module_input_serialized)
|
229
|
-
cloud_job = BiolibJobApi.create_cloud_job(job_id=job_dict['public_id'], result_name_prefix=result_prefix)
|
230
|
-
logger.debug(f"Cloud: Job created with id {cloud_job['public_id']}")
|
231
|
-
return Job(cast(JobDict, job_dict))
|
232
|
-
|
233
194
|
def _run_locally(self, module_input_serialized: bytes) -> Job:
|
234
195
|
job_dict = BiolibJobApi.create(
|
235
196
|
app_version_id=self._app_version['public_id'],
|
236
|
-
app_resource_name_prefix=parse_app_uri(self._app_uri)['resource_name_prefix']
|
197
|
+
app_resource_name_prefix=parse_app_uri(self._app_uri)['resource_name_prefix'],
|
237
198
|
)
|
238
199
|
job = Job(job_dict)
|
239
200
|
|
@@ -1,25 +1,27 @@
|
|
1
1
|
from datetime import datetime, timedelta
|
2
|
-
# from urllib.parse import urlparse, parse_qs
|
3
|
-
|
4
|
-
from biolib.biolib_logging import logger
|
5
2
|
|
6
3
|
from biolib.biolib_api_client.biolib_job_api import BiolibJobApi
|
7
4
|
from biolib.biolib_binary_format.utils import RemoteEndpoint
|
8
5
|
|
6
|
+
# from urllib.parse import urlparse, parse_qs
|
7
|
+
from biolib.biolib_logging import logger
|
8
|
+
from biolib.typing_utils import Literal
|
9
|
+
|
9
10
|
|
10
|
-
class
|
11
|
-
def __init__(self,
|
12
|
-
self._job_id = job_id
|
13
|
-
self._job_auth_token = job_auth_token
|
11
|
+
class RemoteJobStorageEndpoint(RemoteEndpoint):
|
12
|
+
def __init__(self, job_uuid: str, job_auth_token: str, storage_type: Literal['input', 'output']):
|
14
13
|
self._expires_at = None
|
14
|
+
self._job_auth_token = job_auth_token
|
15
|
+
self._job_uuid = job_uuid
|
15
16
|
self._presigned_url = None
|
17
|
+
self._storage_type: Literal['input', 'output'] = storage_type
|
16
18
|
|
17
19
|
def get_remote_url(self):
|
18
20
|
if not self._presigned_url or datetime.utcnow() > self._expires_at:
|
19
21
|
self._presigned_url = BiolibJobApi.get_job_storage_download_url(
|
20
22
|
job_auth_token=self._job_auth_token,
|
21
|
-
job_uuid=self.
|
22
|
-
storage_type='results'
|
23
|
+
job_uuid=self._job_uuid,
|
24
|
+
storage_type='results' if self._storage_type == 'output' else 'input',
|
23
25
|
)
|
24
26
|
self._expires_at = datetime.utcnow() + timedelta(minutes=8)
|
25
27
|
# TODO: Use expires at from url
|
@@ -27,6 +29,6 @@ class RemoteJobStorageResultEndpoint(RemoteEndpoint):
|
|
27
29
|
# query_params = parse_qs(parsed_url.query)
|
28
30
|
# time_at_generation = datetime.datetime.strptime(query_params['X-Amz-Date'][0], '%Y%m%dT%H%M%SZ')
|
29
31
|
# self._expires_at = time_at_generation + timedelta(seconds=int(query_params['X-Amz-Expires'][0]))
|
30
|
-
logger.debug(f'Job "{self.
|
32
|
+
logger.debug(f'Job "{self._job_uuid}" fetched presigned URL with expiry at {self._expires_at.isoformat()}')
|
31
33
|
|
32
34
|
return self._presigned_url
|
@@ -52,7 +52,7 @@ def whoami() -> None:
|
|
52
52
|
email = user_dict['email']
|
53
53
|
intrinsic_account = [account for account in user_dict['accounts'] if account['role'] == 'intrinsic'][0]
|
54
54
|
display_name = intrinsic_account['display_name']
|
55
|
-
print(f'Name: {display_name}\nEmail: {email}')
|
55
|
+
print(f'Name: {display_name}\nEmail: {email}\nLogged into: {client.base_url}')
|
56
56
|
else:
|
57
57
|
print('Not logged in', file=sys.stderr)
|
58
58
|
exit(1)
|
@@ -9,18 +9,22 @@ from urllib.parse import urlparse
|
|
9
9
|
from biolib import api, utils
|
10
10
|
from biolib._internal.http_client import HttpClient
|
11
11
|
from biolib._internal.utils import open_browser_window_from_notebook
|
12
|
-
from biolib.biolib_api_client import BiolibApiClient
|
12
|
+
from biolib.biolib_api_client import BiolibApiClient, CreatedJobDict
|
13
|
+
from biolib.biolib_api_client.biolib_app_api import BiolibAppApi
|
13
14
|
from biolib.biolib_api_client.biolib_job_api import BiolibJobApi
|
14
15
|
from biolib.biolib_binary_format import LazyLoadedFile, ModuleInput, ModuleInputDict, ModuleOutputV2
|
16
|
+
from biolib.biolib_binary_format.remote_endpoints import RemoteJobStorageEndpoint
|
15
17
|
from biolib.biolib_binary_format.stdout_and_stderr import StdoutAndStderr
|
16
18
|
from biolib.biolib_errors import BioLibError, CloudJobFinishedError
|
17
19
|
from biolib.biolib_logging import logger, logger_no_user_data
|
20
|
+
from biolib.compute_node.job_worker.job_storage import JobStorage
|
18
21
|
from biolib.compute_node.utils import SystemExceptionCodeMap, SystemExceptionCodes
|
19
22
|
from biolib.jobs.job_result import JobResult
|
20
23
|
from biolib.jobs.types import CloudJobDict, CloudJobStartedDict, JobDict
|
21
24
|
from biolib.tables import BioLibTable
|
22
25
|
from biolib.typing_utils import Dict, List, Optional, cast
|
23
26
|
from biolib.utils import IS_RUNNING_IN_NOTEBOOK
|
27
|
+
from biolib.utils.app_uri import parse_app_uri
|
24
28
|
|
25
29
|
|
26
30
|
class Job:
|
@@ -198,6 +202,28 @@ class Job:
|
|
198
202
|
except Exception as error:
|
199
203
|
logger.error(f'Failed to cancel job {self._uuid} due to: {error}')
|
200
204
|
|
205
|
+
def recompute(self, app_uri: Optional[str] = None, machine: Optional[str] = None, blocking: bool = True) -> 'Job':
|
206
|
+
app_response = BiolibAppApi.get_by_uri(uri=app_uri or self._job_dict['app_uri'])
|
207
|
+
|
208
|
+
job_storage_input = RemoteJobStorageEndpoint(
|
209
|
+
job_auth_token=self._auth_token,
|
210
|
+
job_uuid=self._uuid,
|
211
|
+
storage_type='input',
|
212
|
+
)
|
213
|
+
http_response = HttpClient.request(url=job_storage_input.get_remote_url())
|
214
|
+
module_input_serialized = http_response.content
|
215
|
+
|
216
|
+
job = self._start_job_in_cloud(
|
217
|
+
app_uri=app_response['app_uri'],
|
218
|
+
app_version_uuid=app_response['app_version']['public_id'],
|
219
|
+
module_input_serialized=module_input_serialized,
|
220
|
+
machine=machine,
|
221
|
+
)
|
222
|
+
if blocking:
|
223
|
+
job.stream_logs()
|
224
|
+
|
225
|
+
return job
|
226
|
+
|
201
227
|
def _get_cloud_job(self) -> CloudJobDict:
|
202
228
|
self._refetch_job_dict(force_refetch=True)
|
203
229
|
if self._job_dict['cloud_job'] is None:
|
@@ -377,3 +403,43 @@ class Job:
|
|
377
403
|
|
378
404
|
self._job_dict = self._get_job_dict(self._uuid, self._auth_token)
|
379
405
|
self._job_dict_last_fetched_at = datetime.utcnow()
|
406
|
+
|
407
|
+
@staticmethod
|
408
|
+
def _start_job_in_cloud(
|
409
|
+
app_uri: str,
|
410
|
+
app_version_uuid: str,
|
411
|
+
module_input_serialized: bytes,
|
412
|
+
override_command: bool = False,
|
413
|
+
machine: Optional[str] = None,
|
414
|
+
experiment_id: Optional[str] = None,
|
415
|
+
result_prefix: Optional[str] = None,
|
416
|
+
timeout: Optional[int] = None,
|
417
|
+
notify: bool = False,
|
418
|
+
) -> 'Job':
|
419
|
+
if len(module_input_serialized) < 500_000:
|
420
|
+
_job_dict = BiolibJobApi.create_job_with_data(
|
421
|
+
app_resource_name_prefix=parse_app_uri(app_uri)['resource_name_prefix'],
|
422
|
+
app_version_uuid=app_version_uuid,
|
423
|
+
arguments_override_command=override_command,
|
424
|
+
experiment_uuid=experiment_id,
|
425
|
+
module_input_serialized=module_input_serialized,
|
426
|
+
notify=notify,
|
427
|
+
requested_machine=machine,
|
428
|
+
requested_timeout_seconds=timeout,
|
429
|
+
result_name_prefix=result_prefix,
|
430
|
+
)
|
431
|
+
return Job(cast(JobDict, _job_dict))
|
432
|
+
|
433
|
+
job_dict: CreatedJobDict = BiolibJobApi.create(
|
434
|
+
app_resource_name_prefix=parse_app_uri(app_uri)['resource_name_prefix'],
|
435
|
+
app_version_id=app_version_uuid,
|
436
|
+
experiment_uuid=experiment_id,
|
437
|
+
machine=machine,
|
438
|
+
notify=notify,
|
439
|
+
override_command=override_command,
|
440
|
+
timeout=timeout,
|
441
|
+
)
|
442
|
+
JobStorage.upload_module_input(job=job_dict, module_input_serialized=module_input_serialized)
|
443
|
+
cloud_job = BiolibJobApi.create_cloud_job(job_id=job_dict['public_id'], result_name_prefix=result_prefix)
|
444
|
+
logger.debug(f"Cloud: Job created with id {cloud_job['public_id']}")
|
445
|
+
return Job(cast(JobDict, job_dict))
|
@@ -3,7 +3,7 @@ from fnmatch import fnmatch
|
|
3
3
|
from pathlib import Path
|
4
4
|
|
5
5
|
from biolib.biolib_binary_format import ModuleOutputV2
|
6
|
-
from biolib.biolib_binary_format.remote_endpoints import
|
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
|
@@ -109,9 +109,10 @@ class JobResult:
|
|
109
109
|
|
110
110
|
def _get_module_output(self) -> ModuleOutputV2:
|
111
111
|
if self._module_output is None:
|
112
|
-
remote_job_storage_endpoint =
|
113
|
-
job_id=self._job_uuid,
|
112
|
+
remote_job_storage_endpoint = RemoteJobStorageEndpoint(
|
114
113
|
job_auth_token=self._job_auth_token,
|
114
|
+
job_uuid=self._job_uuid,
|
115
|
+
storage_type='output',
|
115
116
|
)
|
116
117
|
buffer = RemoteIndexableBuffer(endpoint=remote_job_storage_endpoint)
|
117
118
|
self._module_output = ModuleOutputV2(buffer)
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{pybiolib-1.1.1974 → pybiolib-1.1.1979}/biolib/_internal/data_record/remote_storage_endpoint.py
RENAMED
File without changes
|
File without changes
|
{pybiolib-1.1.1974 → pybiolib-1.1.1979}/biolib/_internal/fuse_mount/experiment_fuse_mount.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{pybiolib-1.1.1974 → pybiolib-1.1.1979}/biolib/compute_node/job_worker/docker_image_cache.py
RENAMED
File without changes
|
{pybiolib-1.1.1974 → pybiolib-1.1.1979}/biolib/compute_node/job_worker/executors/__init__.py
RENAMED
File without changes
|
{pybiolib-1.1.1974 → pybiolib-1.1.1979}/biolib/compute_node/job_worker/executors/docker_executor.py
RENAMED
File without changes
|
{pybiolib-1.1.1974 → pybiolib-1.1.1979}/biolib/compute_node/job_worker/executors/docker_types.py
RENAMED
File without changes
|
{pybiolib-1.1.1974 → pybiolib-1.1.1979}/biolib/compute_node/job_worker/executors/tars/__init__.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{pybiolib-1.1.1974 → pybiolib-1.1.1979}/biolib/compute_node/webserver/gunicorn_flask_application.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|