pybiolib 0.2.951__py3-none-any.whl → 1.2.1890__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.
Files changed (262) hide show
  1. biolib/__init__.py +357 -11
  2. biolib/_data_record/data_record.py +380 -0
  3. biolib/_index/__init__.py +0 -0
  4. biolib/_index/index.py +55 -0
  5. biolib/_index/query_result.py +103 -0
  6. biolib/_internal/__init__.py +0 -0
  7. biolib/_internal/add_copilot_prompts.py +58 -0
  8. biolib/_internal/add_gui_files.py +81 -0
  9. biolib/_internal/data_record/__init__.py +1 -0
  10. biolib/_internal/data_record/data_record.py +85 -0
  11. biolib/_internal/data_record/push_data.py +116 -0
  12. biolib/_internal/data_record/remote_storage_endpoint.py +43 -0
  13. biolib/_internal/errors.py +5 -0
  14. biolib/_internal/file_utils.py +125 -0
  15. biolib/_internal/fuse_mount/__init__.py +1 -0
  16. biolib/_internal/fuse_mount/experiment_fuse_mount.py +209 -0
  17. biolib/_internal/http_client.py +159 -0
  18. biolib/_internal/lfs/__init__.py +1 -0
  19. biolib/_internal/lfs/cache.py +51 -0
  20. biolib/_internal/libs/__init__.py +1 -0
  21. biolib/_internal/libs/fusepy/__init__.py +1257 -0
  22. biolib/_internal/push_application.py +488 -0
  23. biolib/_internal/runtime.py +22 -0
  24. biolib/_internal/string_utils.py +13 -0
  25. biolib/_internal/templates/__init__.py +1 -0
  26. biolib/_internal/templates/copilot_template/.github/instructions/general-app-knowledge.instructions.md +10 -0
  27. biolib/_internal/templates/copilot_template/.github/instructions/style-general.instructions.md +20 -0
  28. biolib/_internal/templates/copilot_template/.github/instructions/style-python.instructions.md +16 -0
  29. biolib/_internal/templates/copilot_template/.github/instructions/style-react-ts.instructions.md +47 -0
  30. biolib/_internal/templates/copilot_template/.github/prompts/biolib_app_inputs.prompt.md +11 -0
  31. biolib/_internal/templates/copilot_template/.github/prompts/biolib_onboard_repo.prompt.md +19 -0
  32. biolib/_internal/templates/copilot_template/.github/prompts/biolib_run_apps.prompt.md +12 -0
  33. biolib/_internal/templates/dashboard_template/.biolib/config.yml +5 -0
  34. biolib/_internal/templates/github_workflow_template/.github/workflows/biolib.yml +21 -0
  35. biolib/_internal/templates/gitignore_template/.gitignore +10 -0
  36. biolib/_internal/templates/gui_template/.yarnrc.yml +1 -0
  37. biolib/_internal/templates/gui_template/App.tsx +53 -0
  38. biolib/_internal/templates/gui_template/Dockerfile +27 -0
  39. biolib/_internal/templates/gui_template/biolib-sdk.ts +82 -0
  40. biolib/_internal/templates/gui_template/dev-data/output.json +7 -0
  41. biolib/_internal/templates/gui_template/index.css +5 -0
  42. biolib/_internal/templates/gui_template/index.html +13 -0
  43. biolib/_internal/templates/gui_template/index.tsx +10 -0
  44. biolib/_internal/templates/gui_template/package.json +27 -0
  45. biolib/_internal/templates/gui_template/tsconfig.json +24 -0
  46. biolib/_internal/templates/gui_template/vite-plugin-dev-data.ts +50 -0
  47. biolib/_internal/templates/gui_template/vite.config.mts +10 -0
  48. biolib/_internal/templates/init_template/.biolib/config.yml +19 -0
  49. biolib/_internal/templates/init_template/Dockerfile +14 -0
  50. biolib/_internal/templates/init_template/requirements.txt +1 -0
  51. biolib/_internal/templates/init_template/run.py +12 -0
  52. biolib/_internal/templates/init_template/run.sh +4 -0
  53. biolib/_internal/templates/templates.py +25 -0
  54. biolib/_internal/tree_utils.py +106 -0
  55. biolib/_internal/utils/__init__.py +65 -0
  56. biolib/_internal/utils/auth.py +46 -0
  57. biolib/_internal/utils/job_url.py +33 -0
  58. biolib/_internal/utils/multinode.py +263 -0
  59. biolib/_runtime/runtime.py +157 -0
  60. biolib/_session/session.py +44 -0
  61. biolib/_shared/__init__.py +0 -0
  62. biolib/_shared/types/__init__.py +74 -0
  63. biolib/_shared/types/account.py +12 -0
  64. biolib/_shared/types/account_member.py +8 -0
  65. biolib/_shared/types/app.py +9 -0
  66. biolib/_shared/types/data_record.py +40 -0
  67. biolib/_shared/types/experiment.py +32 -0
  68. biolib/_shared/types/file_node.py +17 -0
  69. biolib/_shared/types/push.py +6 -0
  70. biolib/_shared/types/resource.py +37 -0
  71. biolib/_shared/types/resource_deploy_key.py +11 -0
  72. biolib/_shared/types/resource_permission.py +14 -0
  73. biolib/_shared/types/resource_version.py +19 -0
  74. biolib/_shared/types/result.py +14 -0
  75. biolib/_shared/types/typing.py +10 -0
  76. biolib/_shared/types/user.py +19 -0
  77. biolib/_shared/utils/__init__.py +7 -0
  78. biolib/_shared/utils/resource_uri.py +75 -0
  79. biolib/api/__init__.py +6 -0
  80. biolib/api/client.py +168 -0
  81. biolib/app/app.py +252 -49
  82. biolib/app/search_apps.py +45 -0
  83. biolib/biolib_api_client/api_client.py +126 -31
  84. biolib/biolib_api_client/app_types.py +24 -4
  85. biolib/biolib_api_client/auth.py +31 -8
  86. biolib/biolib_api_client/biolib_app_api.py +147 -52
  87. biolib/biolib_api_client/biolib_job_api.py +161 -141
  88. biolib/biolib_api_client/job_types.py +21 -5
  89. biolib/biolib_api_client/lfs_types.py +7 -23
  90. biolib/biolib_api_client/user_state.py +56 -0
  91. biolib/biolib_binary_format/__init__.py +1 -4
  92. biolib/biolib_binary_format/file_in_container.py +105 -0
  93. biolib/biolib_binary_format/module_input.py +24 -7
  94. biolib/biolib_binary_format/module_output_v2.py +149 -0
  95. biolib/biolib_binary_format/remote_endpoints.py +34 -0
  96. biolib/biolib_binary_format/remote_stream_seeker.py +59 -0
  97. biolib/biolib_binary_format/saved_job.py +3 -2
  98. biolib/biolib_binary_format/{attestation_document.py → stdout_and_stderr.py} +8 -8
  99. biolib/biolib_binary_format/system_status_update.py +3 -2
  100. biolib/biolib_binary_format/utils.py +175 -0
  101. biolib/biolib_docker_client/__init__.py +11 -2
  102. biolib/biolib_errors.py +36 -0
  103. biolib/biolib_logging.py +27 -10
  104. biolib/cli/__init__.py +38 -0
  105. biolib/cli/auth.py +46 -0
  106. biolib/cli/data_record.py +164 -0
  107. biolib/cli/index.py +32 -0
  108. biolib/cli/init.py +421 -0
  109. biolib/cli/lfs.py +101 -0
  110. biolib/cli/push.py +50 -0
  111. biolib/cli/run.py +63 -0
  112. biolib/cli/runtime.py +14 -0
  113. biolib/cli/sdk.py +16 -0
  114. biolib/cli/start.py +56 -0
  115. biolib/compute_node/cloud_utils/cloud_utils.py +110 -161
  116. biolib/compute_node/job_worker/cache_state.py +66 -88
  117. biolib/compute_node/job_worker/cache_types.py +1 -6
  118. biolib/compute_node/job_worker/docker_image_cache.py +112 -37
  119. biolib/compute_node/job_worker/executors/__init__.py +0 -3
  120. biolib/compute_node/job_worker/executors/docker_executor.py +532 -199
  121. biolib/compute_node/job_worker/executors/docker_types.py +9 -1
  122. biolib/compute_node/job_worker/executors/types.py +19 -9
  123. biolib/compute_node/job_worker/job_legacy_input_wait_timeout_thread.py +30 -0
  124. biolib/compute_node/job_worker/job_max_runtime_timer_thread.py +3 -5
  125. biolib/compute_node/job_worker/job_storage.py +108 -0
  126. biolib/compute_node/job_worker/job_worker.py +397 -212
  127. biolib/compute_node/job_worker/large_file_system.py +87 -38
  128. biolib/compute_node/job_worker/network_alloc.py +99 -0
  129. biolib/compute_node/job_worker/network_buffer.py +240 -0
  130. biolib/compute_node/job_worker/utilization_reporter_thread.py +197 -0
  131. biolib/compute_node/job_worker/utils.py +9 -24
  132. biolib/compute_node/remote_host_proxy.py +400 -98
  133. biolib/compute_node/utils.py +31 -9
  134. biolib/compute_node/webserver/compute_node_results_proxy.py +189 -0
  135. biolib/compute_node/webserver/proxy_utils.py +28 -0
  136. biolib/compute_node/webserver/webserver.py +130 -44
  137. biolib/compute_node/webserver/webserver_types.py +2 -6
  138. biolib/compute_node/webserver/webserver_utils.py +77 -12
  139. biolib/compute_node/webserver/worker_thread.py +183 -42
  140. biolib/experiments/__init__.py +0 -0
  141. biolib/experiments/experiment.py +356 -0
  142. biolib/jobs/__init__.py +1 -0
  143. biolib/jobs/job.py +741 -0
  144. biolib/jobs/job_result.py +185 -0
  145. biolib/jobs/types.py +50 -0
  146. biolib/py.typed +0 -0
  147. biolib/runtime/__init__.py +14 -0
  148. biolib/sdk/__init__.py +91 -0
  149. biolib/tables.py +34 -0
  150. biolib/typing_utils.py +2 -7
  151. biolib/user/__init__.py +1 -0
  152. biolib/user/sign_in.py +54 -0
  153. biolib/utils/__init__.py +162 -0
  154. biolib/utils/cache_state.py +94 -0
  155. biolib/utils/multipart_uploader.py +194 -0
  156. biolib/utils/seq_util.py +150 -0
  157. biolib/utils/zip/remote_zip.py +640 -0
  158. pybiolib-1.2.1890.dist-info/METADATA +41 -0
  159. pybiolib-1.2.1890.dist-info/RECORD +177 -0
  160. {pybiolib-0.2.951.dist-info → pybiolib-1.2.1890.dist-info}/WHEEL +1 -1
  161. pybiolib-1.2.1890.dist-info/entry_points.txt +2 -0
  162. README.md +0 -17
  163. biolib/app/app_result.py +0 -68
  164. biolib/app/utils.py +0 -62
  165. biolib/biolib-js/0-biolib.worker.js +0 -1
  166. biolib/biolib-js/1-biolib.worker.js +0 -1
  167. biolib/biolib-js/2-biolib.worker.js +0 -1
  168. biolib/biolib-js/3-biolib.worker.js +0 -1
  169. biolib/biolib-js/4-biolib.worker.js +0 -1
  170. biolib/biolib-js/5-biolib.worker.js +0 -1
  171. biolib/biolib-js/6-biolib.worker.js +0 -1
  172. biolib/biolib-js/index.html +0 -10
  173. biolib/biolib-js/main-biolib.js +0 -1
  174. biolib/biolib_api_client/biolib_account_api.py +0 -21
  175. biolib/biolib_api_client/biolib_large_file_system_api.py +0 -108
  176. biolib/biolib_binary_format/aes_encrypted_package.py +0 -42
  177. biolib/biolib_binary_format/module_output.py +0 -58
  178. biolib/biolib_binary_format/rsa_encrypted_aes_package.py +0 -57
  179. biolib/biolib_push.py +0 -114
  180. biolib/cli.py +0 -203
  181. biolib/cli_utils.py +0 -273
  182. biolib/compute_node/cloud_utils/enclave_parent_types.py +0 -7
  183. biolib/compute_node/enclave/__init__.py +0 -2
  184. biolib/compute_node/enclave/enclave_remote_hosts.py +0 -53
  185. biolib/compute_node/enclave/nitro_secure_module_utils.py +0 -64
  186. biolib/compute_node/job_worker/executors/base_executor.py +0 -18
  187. biolib/compute_node/job_worker/executors/pyppeteer_executor.py +0 -173
  188. biolib/compute_node/job_worker/executors/remote/__init__.py +0 -1
  189. biolib/compute_node/job_worker/executors/remote/nitro_enclave_utils.py +0 -81
  190. biolib/compute_node/job_worker/executors/remote/remote_executor.py +0 -51
  191. biolib/lfs.py +0 -196
  192. biolib/pyppeteer/.circleci/config.yml +0 -100
  193. biolib/pyppeteer/.coveragerc +0 -3
  194. biolib/pyppeteer/.gitignore +0 -89
  195. biolib/pyppeteer/.pre-commit-config.yaml +0 -28
  196. biolib/pyppeteer/CHANGES.md +0 -253
  197. biolib/pyppeteer/CONTRIBUTING.md +0 -26
  198. biolib/pyppeteer/LICENSE +0 -12
  199. biolib/pyppeteer/README.md +0 -137
  200. biolib/pyppeteer/docs/Makefile +0 -177
  201. biolib/pyppeteer/docs/_static/custom.css +0 -28
  202. biolib/pyppeteer/docs/_templates/layout.html +0 -10
  203. biolib/pyppeteer/docs/changes.md +0 -1
  204. biolib/pyppeteer/docs/conf.py +0 -299
  205. biolib/pyppeteer/docs/index.md +0 -21
  206. biolib/pyppeteer/docs/make.bat +0 -242
  207. biolib/pyppeteer/docs/reference.md +0 -211
  208. biolib/pyppeteer/docs/server.py +0 -60
  209. biolib/pyppeteer/poetry.lock +0 -1699
  210. biolib/pyppeteer/pyppeteer/__init__.py +0 -135
  211. biolib/pyppeteer/pyppeteer/accessibility.py +0 -286
  212. biolib/pyppeteer/pyppeteer/browser.py +0 -401
  213. biolib/pyppeteer/pyppeteer/browser_fetcher.py +0 -194
  214. biolib/pyppeteer/pyppeteer/command.py +0 -22
  215. biolib/pyppeteer/pyppeteer/connection/__init__.py +0 -242
  216. biolib/pyppeteer/pyppeteer/connection/cdpsession.py +0 -101
  217. biolib/pyppeteer/pyppeteer/coverage.py +0 -346
  218. biolib/pyppeteer/pyppeteer/device_descriptors.py +0 -787
  219. biolib/pyppeteer/pyppeteer/dialog.py +0 -79
  220. biolib/pyppeteer/pyppeteer/domworld.py +0 -597
  221. biolib/pyppeteer/pyppeteer/emulation_manager.py +0 -53
  222. biolib/pyppeteer/pyppeteer/errors.py +0 -48
  223. biolib/pyppeteer/pyppeteer/events.py +0 -63
  224. biolib/pyppeteer/pyppeteer/execution_context.py +0 -156
  225. biolib/pyppeteer/pyppeteer/frame/__init__.py +0 -299
  226. biolib/pyppeteer/pyppeteer/frame/frame_manager.py +0 -306
  227. biolib/pyppeteer/pyppeteer/helpers.py +0 -245
  228. biolib/pyppeteer/pyppeteer/input.py +0 -371
  229. biolib/pyppeteer/pyppeteer/jshandle.py +0 -598
  230. biolib/pyppeteer/pyppeteer/launcher.py +0 -683
  231. biolib/pyppeteer/pyppeteer/lifecycle_watcher.py +0 -169
  232. biolib/pyppeteer/pyppeteer/models/__init__.py +0 -103
  233. biolib/pyppeteer/pyppeteer/models/_protocol.py +0 -12460
  234. biolib/pyppeteer/pyppeteer/multimap.py +0 -82
  235. biolib/pyppeteer/pyppeteer/network_manager.py +0 -678
  236. biolib/pyppeteer/pyppeteer/options.py +0 -8
  237. biolib/pyppeteer/pyppeteer/page.py +0 -1728
  238. biolib/pyppeteer/pyppeteer/pipe_transport.py +0 -59
  239. biolib/pyppeteer/pyppeteer/target.py +0 -147
  240. biolib/pyppeteer/pyppeteer/task_queue.py +0 -24
  241. biolib/pyppeteer/pyppeteer/timeout_settings.py +0 -36
  242. biolib/pyppeteer/pyppeteer/tracing.py +0 -93
  243. biolib/pyppeteer/pyppeteer/us_keyboard_layout.py +0 -305
  244. biolib/pyppeteer/pyppeteer/util.py +0 -18
  245. biolib/pyppeteer/pyppeteer/websocket_transport.py +0 -47
  246. biolib/pyppeteer/pyppeteer/worker.py +0 -101
  247. biolib/pyppeteer/pyproject.toml +0 -97
  248. biolib/pyppeteer/spell.txt +0 -137
  249. biolib/pyppeteer/tox.ini +0 -72
  250. biolib/pyppeteer/utils/generate_protocol_types.py +0 -603
  251. biolib/start_cli.py +0 -7
  252. biolib/utils.py +0 -47
  253. biolib/validators/validate_app_version.py +0 -183
  254. biolib/validators/validate_argument.py +0 -134
  255. biolib/validators/validate_module.py +0 -323
  256. biolib/validators/validate_zip_file.py +0 -40
  257. biolib/validators/validator_utils.py +0 -103
  258. pybiolib-0.2.951.dist-info/LICENSE +0 -21
  259. pybiolib-0.2.951.dist-info/METADATA +0 -61
  260. pybiolib-0.2.951.dist-info/RECORD +0 -153
  261. pybiolib-0.2.951.dist-info/entry_points.txt +0 -3
  262. /LICENSE → /pybiolib-1.2.1890.dist-info/licenses/LICENSE +0 -0
@@ -1,7 +1,15 @@
1
- from biolib.typing_utils import TypedDict, Any
1
+ import enum
2
+
3
+ from biolib.typing_utils import Any, TypedDict
2
4
 
3
5
 
4
6
  class Proxy(TypedDict):
5
7
  container: Any
6
8
  hostname: str
7
9
  ip: str
10
+
11
+
12
+ class DockerDiffKind(enum.Enum):
13
+ CHANGED = 0
14
+ ADDED = 1
15
+ DELETED = 2
@@ -1,12 +1,11 @@
1
- from docker.models.networks import Network # type: ignore
1
+ from docker.models.networks import Network
2
2
 
3
+ from biolib.biolib_api_client.app_types import Module
4
+ from biolib.biolib_api_client.job_types import CloudJob, CreatedJobDict
3
5
  from biolib.compute_node.job_worker.large_file_system import LargeFileSystem
4
- from biolib.compute_node.webserver.webserver_types import ComputeNodeInfo
5
- from biolib.typing_utils import TypedDict, Callable, Optional, List, Dict
6
6
  from biolib.compute_node.remote_host_proxy import RemoteHostProxy
7
- from biolib.biolib_api_client.app_types import Module
8
- from biolib.biolib_api_client.job_types import Job
9
- from biolib.compute_node.utils import SystemExceptionCodes
7
+ from biolib.compute_node.webserver.webserver_types import ComputeNodeInfo
8
+ from biolib.typing_utils import Callable, Dict, List, Optional, TypedDict
10
9
 
11
10
 
12
11
  class StatusUpdate(TypedDict):
@@ -16,12 +15,14 @@ class StatusUpdate(TypedDict):
16
15
 
17
16
  class RemoteExecuteOptions(TypedDict):
18
17
  biolib_base_url: str
19
- job: Job
18
+ job: CreatedJobDict
19
+ result_name_prefix: Optional[str]
20
20
  root_job_id: str
21
21
 
22
22
 
23
23
  SendStatusUpdateType = Callable[[StatusUpdate], None]
24
- SendSystemExceptionType = Callable[[SystemExceptionCodes], None]
24
+ SendSystemExceptionType = Callable[[int], None]
25
+ SendStdoutAndStderrType = Callable[[bytes], None]
25
26
 
26
27
 
27
28
  class LocalExecutorOptions(TypedDict):
@@ -29,11 +30,20 @@ class LocalExecutorOptions(TypedDict):
29
30
  biolib_base_url: str
30
31
  compute_node_info: Optional[ComputeNodeInfo]
31
32
  internal_network: Optional[Network]
32
- job: Job
33
+ job: CreatedJobDict
34
+ cloud_job: Optional[CloudJob]
33
35
  large_file_systems: Dict[str, LargeFileSystem]
34
36
  module: Module
37
+ module_input_path: str
38
+ module_output_path: str
35
39
  remote_host_proxies: List[RemoteHostProxy]
36
40
  root_job_id: str
37
41
  runtime_zip_bytes: Optional[bytes] # TODO: replace this with a module_source_serialized
38
42
  send_status_update: SendStatusUpdateType
39
43
  send_system_exception: SendSystemExceptionType
44
+ send_stdout_and_stderr: SendStdoutAndStderrType
45
+
46
+
47
+ class MetadataToSaveOutput(TypedDict):
48
+ arguments: List[str]
49
+ startup_error_string: Optional[str]
@@ -0,0 +1,30 @@
1
+ import threading
2
+ import time
3
+
4
+ from biolib.typing_utils import Callable
5
+ from biolib.compute_node.job_worker.utils import ComputeProcessException
6
+ from biolib.compute_node.utils import SystemExceptionCodes
7
+
8
+
9
+ class JobLegacyInputWaitTimeout(threading.Thread):
10
+
11
+ def __init__(self, job_uuid: str, input_max_wait_in_seconds: int, send_system_exception: Callable[[int], None]):
12
+ threading.Thread.__init__(self, daemon=True)
13
+ self._job_uuid = job_uuid
14
+ self._input_max_wait_in_seconds = input_max_wait_in_seconds
15
+ self._send_system_exception = send_system_exception
16
+ self._stop_event = threading.Event()
17
+
18
+ def stop(self) -> None:
19
+ self._stop_event.set()
20
+
21
+ def run(self) -> None:
22
+ time.sleep(self._input_max_wait_in_seconds)
23
+
24
+ if not self._stop_event.is_set():
25
+ raise ComputeProcessException(
26
+ biolib_error_code=SystemExceptionCodes.FAILED_TO_GET_REQUIRED_DATA_FOR_COMPUTE.value,
27
+ may_contain_user_data=False,
28
+ original_error=Exception(f'Job "{self._job_uuid}" exceeded max wait time for legacy input.'),
29
+ send_system_exception=self._send_system_exception,
30
+ )
@@ -3,21 +3,19 @@ import threading
3
3
  import time
4
4
 
5
5
  from biolib.biolib_logging import logger
6
- from biolib.compute_node.cloud_utils import CloudUtils
7
6
  from biolib.compute_node.job_worker.utils import ComputeProcessException
8
7
  from biolib.compute_node.utils import SystemExceptionCodes
9
8
 
10
9
 
11
10
  class JobMaxRuntimeTimerThread(threading.Thread):
12
11
 
13
- def __init__(self, job_worker):
12
+ def __init__(self, job_worker, max_runtime_in_seconds):
14
13
  threading.Thread.__init__(self, daemon=True)
15
14
  self._job_worker = job_worker
15
+ self._max_runtime_in_seconds = max_runtime_in_seconds
16
16
 
17
17
  def run(self) -> None:
18
- config = CloudUtils.get_webserver_config()
19
- seconds_to_wait = config['shutdown_times']['job_max_runtime_shutdown_time_in_seconds']
20
- time.sleep(seconds_to_wait)
18
+ time.sleep(self._max_runtime_in_seconds)
21
19
  # Only raise exception and trigger clean up if the job has not already been cleaned up
22
20
  if not self._job_worker.is_cleaning_up:
23
21
  logger.debug("Job exceeded max run time. Raising exception")
@@ -0,0 +1,108 @@
1
+ import os
2
+
3
+ from biolib import utils
4
+ from biolib._internal.http_client import HttpClient
5
+ from biolib.biolib_api_client import CreatedJobDict
6
+ from biolib.biolib_api_client.biolib_job_api import BiolibJobApi
7
+ from biolib.compute_node.cloud_utils import CloudUtils
8
+ from biolib.biolib_logging import logger_no_user_data
9
+ from biolib.utils.multipart_uploader import get_chunk_iterator_from_file_object
10
+
11
+
12
+ class JobStorage:
13
+ module_input_file_name = 'input-output.bbf'
14
+ module_output_file_name = 'module-output.bbf'
15
+
16
+ @staticmethod
17
+ def upload_module_input(job: CreatedJobDict, module_input_serialized: bytes) -> None:
18
+ job_uuid = job['public_id']
19
+ headers = {'Job-Auth-Token': job['auth_token']}
20
+
21
+ multipart_uploader = utils.MultiPartUploader(
22
+ start_multipart_upload_request=dict(
23
+ requires_biolib_auth=False,
24
+ path=f'/jobs/{job_uuid}/storage/input/start_upload/',
25
+ headers=headers
26
+ ),
27
+ get_presigned_upload_url_request=dict(
28
+ requires_biolib_auth=False,
29
+ path=f'/jobs/{job_uuid}/storage/input/presigned_upload_url/',
30
+ headers=headers
31
+ ),
32
+ complete_upload_request=dict(
33
+ requires_biolib_auth=False,
34
+ path=f'/jobs/{job_uuid}/storage/input/complete_upload/',
35
+ headers=headers
36
+ ),
37
+ )
38
+
39
+ multipart_uploader.upload(
40
+ payload_iterator=utils.get_chunk_iterator_from_bytes(module_input_serialized),
41
+ payload_size_in_bytes=len(module_input_serialized),
42
+ )
43
+
44
+ @staticmethod
45
+ def upload_module_output(job_uuid: str, job_temporary_dir: str) -> None:
46
+ logger_no_user_data.debug(f'Job "{job_uuid}" uploading result...')
47
+ module_output_path = os.path.join(job_temporary_dir, JobStorage.module_output_file_name)
48
+ module_output_size = os.path.getsize(module_output_path)
49
+
50
+ # Calculate chunk size based on max chunk count of 10_000, using 9_000 to be on the safe side
51
+ max_chunk_count = 9_000
52
+ min_chunk_size_bytes = 50_000_000
53
+ chunk_size_in_bytes = max(min_chunk_size_bytes, module_output_size // max_chunk_count)
54
+
55
+ logger_no_user_data.debug(
56
+ f'Job "{job_uuid}" uploading result of size {module_output_size} bytes '
57
+ f'with chunk size of {chunk_size_in_bytes} bytes...'
58
+ )
59
+
60
+ with open(module_output_path, mode='rb') as module_output_file:
61
+ module_output_iterator = get_chunk_iterator_from_file_object(
62
+ file_object=module_output_file,
63
+ chunk_size_in_bytes=chunk_size_in_bytes,
64
+ )
65
+ multipart_uploader = JobStorage._get_module_output_uploader(job_uuid)
66
+ multipart_uploader.upload(
67
+ payload_iterator=module_output_iterator,
68
+ payload_size_in_bytes=module_output_size,
69
+ )
70
+
71
+ logger_no_user_data.debug(f'Job "{job_uuid}" result uploaded successfully')
72
+
73
+ @staticmethod
74
+ def _get_module_output_uploader(job_uuid: str) -> utils.MultiPartUploader:
75
+ config = CloudUtils.get_webserver_config()
76
+ compute_node_auth_token = config['compute_node_info']['auth_token'] # pylint: disable=unsubscriptable-object
77
+ headers = {'Compute-Node-Auth-Token': compute_node_auth_token}
78
+
79
+ return utils.MultiPartUploader(
80
+ start_multipart_upload_request=dict(
81
+ requires_biolib_auth=False,
82
+ path=f'/jobs/{job_uuid}/storage/results/start_upload/',
83
+ headers=headers,
84
+ ),
85
+ get_presigned_upload_url_request=dict(
86
+ requires_biolib_auth=False,
87
+ path=f'/jobs/{job_uuid}/storage/results/presigned_upload_url/',
88
+ headers=headers,
89
+ ),
90
+ complete_upload_request=dict(
91
+ requires_biolib_auth=False,
92
+ path=f'/jobs/{job_uuid}/storage/results/complete_upload/',
93
+ headers=headers,
94
+ ),
95
+ )
96
+
97
+ @staticmethod
98
+ def download_module_input(job: CreatedJobDict, path: str):
99
+ job_uuid = job['public_id']
100
+ logger_no_user_data.debug(f'Job "{job_uuid}" getting module input url...')
101
+ presigned_download_url = BiolibJobApi.get_job_storage_download_url(
102
+ job_uuid=job_uuid,
103
+ job_auth_token=job['auth_token'],
104
+ storage_type='input',
105
+ )
106
+ logger_no_user_data.debug(f'Job "{job_uuid}" downloading module input...')
107
+ HttpClient.request(url=presigned_download_url, response_path=path)
108
+ logger_no_user_data.debug(f'Job "{job_uuid}" module input downloaded')