pybiolib 1.2.221__py3-none-any.whl → 1.2.230__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/_runtime/runtime.py +11 -0
- biolib/biolib_api_client/job_types.py +2 -1
- biolib/compute_node/job_worker/executors/docker_executor.py +27 -15
- biolib/compute_node/utils.py +6 -2
- {pybiolib-1.2.221.dist-info → pybiolib-1.2.230.dist-info}/METADATA +1 -1
- {pybiolib-1.2.221.dist-info → pybiolib-1.2.230.dist-info}/RECORD +9 -9
- {pybiolib-1.2.221.dist-info → pybiolib-1.2.230.dist-info}/LICENSE +0 -0
- {pybiolib-1.2.221.dist-info → pybiolib-1.2.230.dist-info}/WHEEL +0 -0
- {pybiolib-1.2.221.dist-info → pybiolib-1.2.230.dist-info}/entry_points.txt +0 -0
biolib/_runtime/runtime.py
CHANGED
@@ -48,6 +48,17 @@ class Runtime:
|
|
48
48
|
except BaseException as error:
|
49
49
|
raise BioLibRuntimeError(f'Unable to get system secret: {secret_name}') from error
|
50
50
|
|
51
|
+
@staticmethod
|
52
|
+
def get_temporary_client_secret(secret_name: str) -> bytes:
|
53
|
+
assert re.match(
|
54
|
+
'^[a-zA-Z0-9_-]*$', secret_name
|
55
|
+
), 'Secret name can only contain alphanumeric characters and dashes or underscores '
|
56
|
+
try:
|
57
|
+
with open(f'/biolib/temporary-client-secrets/{secret_name}', 'rb') as file:
|
58
|
+
return file.read()
|
59
|
+
except BaseException as error:
|
60
|
+
raise BioLibRuntimeError(f'Unable to get secret: {secret_name}') from error
|
61
|
+
|
51
62
|
@staticmethod
|
52
63
|
def set_main_result_prefix(result_prefix: str) -> None:
|
53
64
|
job_data = Runtime._get_job_data()
|
@@ -2,7 +2,7 @@ from enum import Enum
|
|
2
2
|
|
3
3
|
from biolib.biolib_api_client.app_types import AppVersionOnJob, RemoteHost
|
4
4
|
from biolib.compute_node.webserver.webserver_types import ComputeNodeInfo
|
5
|
-
from biolib.typing_utils import List, Optional, TypedDict
|
5
|
+
from biolib.typing_utils import Dict, List, Optional, TypedDict
|
6
6
|
|
7
7
|
|
8
8
|
class JobState(Enum):
|
@@ -31,6 +31,7 @@ class _Job(TypedDict):
|
|
31
31
|
# type optional keys with total=False
|
32
32
|
class CreatedJobDict(_Job, total=False):
|
33
33
|
custom_compute_node_url: str
|
34
|
+
temporary_client_secrets: Dict[str, str]
|
34
35
|
|
35
36
|
|
36
37
|
class CloudJob(TypedDict):
|
@@ -69,7 +69,9 @@ class DockerExecutor:
|
|
69
69
|
|
70
70
|
# If BIOLIB_SECRETS_TMPFS_PATH is set create the temporary directory there
|
71
71
|
self._tmp_secrets_dir = tempfile.TemporaryDirectory(dir=utils.BIOLIB_SECRETS_TMPFS_PATH or None)
|
72
|
+
self._tmp_client_secrets_dir = tempfile.TemporaryDirectory(dir=utils.BIOLIB_SECRETS_TMPFS_PATH or None)
|
72
73
|
os.chmod(self._tmp_secrets_dir.name, 0o755)
|
74
|
+
os.chmod(self._tmp_client_secrets_dir.name, 0o755)
|
73
75
|
|
74
76
|
@property
|
75
77
|
def _container(self) -> Container:
|
@@ -263,6 +265,7 @@ class DockerExecutor:
|
|
263
265
|
|
264
266
|
logger_no_user_data.debug(f'Deleted compute container in: {time.time() - container_time}')
|
265
267
|
self._tmp_secrets_dir.cleanup()
|
268
|
+
self._tmp_client_secrets_dir.cleanup()
|
266
269
|
|
267
270
|
# TODO: type this method
|
268
271
|
def _initialize_docker_container(self, module_input):
|
@@ -285,11 +288,23 @@ class DockerExecutor:
|
|
285
288
|
app_uri=self._options['job']['app_uri'],
|
286
289
|
is_environment_biolib_cloud=bool(utils.IS_RUNNING_IN_CLOUD),
|
287
290
|
)
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
+
docker_volume_mounts.append(
|
292
|
+
self._create_secrets_mount(
|
293
|
+
source_dir=self._tmp_secrets_dir.name + '/',
|
294
|
+
target_dir='/biolib/secrets/',
|
295
|
+
secrets=dict(
|
296
|
+
**module.get('secrets', {}),
|
297
|
+
biolib_system_secret=json.dumps(biolib_system_secret, indent=4),
|
298
|
+
),
|
299
|
+
)
|
300
|
+
)
|
301
|
+
docker_volume_mounts.append(
|
302
|
+
self._create_secrets_mount(
|
303
|
+
source_dir=self._tmp_client_secrets_dir.name + '/',
|
304
|
+
target_dir='/biolib/temporary-client-secrets/',
|
305
|
+
secrets=self._options['job'].get('temporary_client_secrets', {}),
|
306
|
+
)
|
291
307
|
)
|
292
|
-
docker_volume_mounts.append(self._create_secrets_mount(secrets))
|
293
308
|
|
294
309
|
environment_vars = {}
|
295
310
|
|
@@ -498,8 +513,8 @@ class DockerExecutor:
|
|
498
513
|
stdout=stdout,
|
499
514
|
)
|
500
515
|
except Exception as exception:
|
501
|
-
logger.error(
|
502
|
-
logger.exception(
|
516
|
+
logger.error('Hit Error 23')
|
517
|
+
logger.exception('Error')
|
503
518
|
logger.error(str(exception))
|
504
519
|
time.sleep(3)
|
505
520
|
raise ComputeProcessException(
|
@@ -586,19 +601,16 @@ class DockerExecutor:
|
|
586
601
|
|
587
602
|
return files_and_empty_dirs
|
588
603
|
|
589
|
-
def _create_secrets_mount(self, secrets: Dict[str, str]) -> docker.types.Mount:
|
590
|
-
|
604
|
+
def _create_secrets_mount(self, source_dir: str, target_dir: str, secrets: Dict[str, str]) -> docker.types.Mount:
|
605
|
+
assert source_dir.startswith('/') and source_dir.endswith('/'), 'source_dir must start and end with slash'
|
606
|
+
assert target_dir.startswith('/') and target_dir.endswith('/'), 'target_dir must start and end with slash'
|
591
607
|
|
608
|
+
job_uuid = self._options['job']['public_id']
|
592
609
|
for key, value in secrets.items():
|
593
610
|
if re.match(r'^[a-zA-Z0-9-_]+$', key):
|
594
|
-
with open(f'{
|
611
|
+
with open(f'{source_dir}{key}', 'w') as secret_file:
|
595
612
|
secret_file.write(value)
|
596
613
|
else:
|
597
614
|
logger_no_user_data.warning(f'Job {job_uuid} uses secret with a key not matching validation regex')
|
598
615
|
|
599
|
-
return docker.types.Mount(
|
600
|
-
read_only=True,
|
601
|
-
source=f'{self._tmp_secrets_dir.name}/',
|
602
|
-
target='/biolib/secrets/',
|
603
|
-
type='bind',
|
604
|
-
)
|
616
|
+
return docker.types.Mount(read_only=True, source=source_dir, target=target_dir, type='bind')
|
biolib/compute_node/utils.py
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
from enum import Enum
|
2
1
|
import random
|
3
2
|
import string
|
3
|
+
from enum import Enum
|
4
4
|
|
5
5
|
from biolib.biolib_logging import logger
|
6
6
|
|
@@ -29,7 +29,7 @@ def get_package_type(package):
|
|
29
29
|
return 'StdoutAndStderr'
|
30
30
|
|
31
31
|
else:
|
32
|
-
raise Exception(f
|
32
|
+
raise Exception(f'Unexpected package type {package_type}')
|
33
33
|
|
34
34
|
|
35
35
|
class SystemExceptionCodes(Enum):
|
@@ -68,6 +68,8 @@ class SystemExceptionCodes(Enum):
|
|
68
68
|
FAILED_TO_ALLOCATE_JOB_TO_COMPUTE_NODE = 32
|
69
69
|
NO_MODULES_FOUND_ON_JOB = 33
|
70
70
|
FAILED_TO_INITIALIZE_DOCKER_EXECUTOR = 34
|
71
|
+
COMPUTE_NODE_SHUTDOWN = 35
|
72
|
+
COMPUTE_NODE_SHUTDOWN_DUE_TO_HEALTH_CHECK_FAILURE = 36
|
71
73
|
|
72
74
|
|
73
75
|
SystemExceptionCodeMap = {
|
@@ -106,6 +108,8 @@ SystemExceptionCodeMap = {
|
|
106
108
|
32: 'Failed to allocate job to compute node',
|
107
109
|
33: 'No modules found on job',
|
108
110
|
34: 'Failed to initialize docker executor',
|
111
|
+
35: 'Compute node shutdown',
|
112
|
+
36: 'Compute node shutdown due to health check failure',
|
109
113
|
}
|
110
114
|
|
111
115
|
|
@@ -27,7 +27,7 @@ biolib/_internal/types/resource_version.py,sha256=sLxViYXloDDUhTDFgjegiQCj097OM1
|
|
27
27
|
biolib/_internal/types/typing.py,sha256=D4EKKEe7kDx0K6lJi-H_XLtk-8w6nu2fdqn9bvzI-Xo,288
|
28
28
|
biolib/_internal/utils/__init__.py,sha256=p5vsIFyu-zYqBgdSMfwW9NC_jk7rXvvCbV4Bzd3As7c,630
|
29
29
|
biolib/_internal/utils/multinode.py,sha256=zWrQhcVK5u_xdWX2oIM-D_2fINqNPlqF_h71fu4K8LY,8279
|
30
|
-
biolib/_runtime/runtime.py,sha256=
|
30
|
+
biolib/_runtime/runtime.py,sha256=bZQ0m39R9jOBVAtlyvzDnOobKueOAQUCwMUZjDQnO7E,4439
|
31
31
|
biolib/api/__init__.py,sha256=mQ4u8FijqyLzjYMezMUUbbBGNB3iFmkNdjXnWPZ7Jlw,138
|
32
32
|
biolib/api/client.py,sha256=FRpdH5aI187b_I_4HUNi680v4iOP65z5f2RcUo8D8MA,3559
|
33
33
|
biolib/app/__init__.py,sha256=cdPtcfb_U-bxb9iSL4fCEq2rpD9OjkyY4W-Zw60B0LI,37
|
@@ -40,7 +40,7 @@ biolib/biolib_api_client/auth.py,sha256=kjm0ZHnH3I8so3su2sZbBxNHYp-ZUdrZ5lwQ0K36
|
|
40
40
|
biolib/biolib_api_client/biolib_app_api.py,sha256=i5KPZNpopU7cqcjVfICml-31ca-1-CU_rdZgKiZt0Vs,4343
|
41
41
|
biolib/biolib_api_client/biolib_job_api.py,sha256=7bKfav3-12ewXkEUoLdCmbWdebW8148kxfGJW9SsXZI,7125
|
42
42
|
biolib/biolib_api_client/common_types.py,sha256=RH-1KNHqUF-EkTpfPOSTt5Mq1GPdfju_cqXDesscO1I,123
|
43
|
-
biolib/biolib_api_client/job_types.py,sha256=
|
43
|
+
biolib/biolib_api_client/job_types.py,sha256=yBdBwjharbQJuXCi2xKMi0t_r6XxnbWnkchHekTpCJY,1351
|
44
44
|
biolib/biolib_api_client/lfs_types.py,sha256=joZWP6-sa5_Ug_6xIp5fHAgEo_bqLE3rbleQocZtDcg,339
|
45
45
|
biolib/biolib_api_client/user_state.py,sha256=XcgWV-MgVk88mIlMmnu8yHxMu8OCaw8o0tk7TVo5Hcg,637
|
46
46
|
biolib/biolib_binary_format/__init__.py,sha256=HMl5SdX_VUWE4OQzi4Jf_yFvC7b0bSPOGPHYi9dWM2Q,185
|
@@ -78,7 +78,7 @@ biolib/compute_node/job_worker/cache_state.py,sha256=MwjSRzcJJ_4jybqvBL4xdgnDYSI
|
|
78
78
|
biolib/compute_node/job_worker/cache_types.py,sha256=ajpLy8i09QeQS9dEqTn3T6NVNMY_YsHQkSD5nvIHccQ,818
|
79
79
|
biolib/compute_node/job_worker/docker_image_cache.py,sha256=ansHIkJIq_EMW1nZNlW-RRLVVeKWTbzNICYaOHpKiRE,7460
|
80
80
|
biolib/compute_node/job_worker/executors/__init__.py,sha256=bW6t1qi3PZTlHM4quaTLa8EI4ALTCk83cqcVJfJfJfE,145
|
81
|
-
biolib/compute_node/job_worker/executors/docker_executor.py,sha256=
|
81
|
+
biolib/compute_node/job_worker/executors/docker_executor.py,sha256=HiAenSATWY7DApAKSBQU74jvA-JF42x5dBV8JxQ_eQ0,28829
|
82
82
|
biolib/compute_node/job_worker/executors/docker_types.py,sha256=VhsU1DKtJjx_BbCkVmiPZPH4ROiL1ygW1Y_s1Kbpa2o,216
|
83
83
|
biolib/compute_node/job_worker/executors/tars/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
84
84
|
biolib/compute_node/job_worker/executors/types.py,sha256=yP5gG39hr-DLnw9bOE--VHi-1arDbIYiGuV1rlTbbHI,1466
|
@@ -93,7 +93,7 @@ biolib/compute_node/job_worker/utils.py,sha256=wgxcIA8yAhUPdCwyvuuJ0JmreyWmmUoBO
|
|
93
93
|
biolib/compute_node/remote_host_proxy.py,sha256=1EZnB0WWG359Yy22xBoqRqGEmmlA12rpiG5u8B2381M,16533
|
94
94
|
biolib/compute_node/socker_listener_thread.py,sha256=T5_UikA3MB9bD5W_dckYLPTgixh72vKUlgbBvj9dbM0,1601
|
95
95
|
biolib/compute_node/socket_sender_thread.py,sha256=YgamPHeUm2GjMFGx8qk-99WlZhEs-kAb3q_2O6qByig,971
|
96
|
-
biolib/compute_node/utils.py,sha256=
|
96
|
+
biolib/compute_node/utils.py,sha256=fWtFIcGatek1NaVOT9Vaey6UFp8GKLYGLAVu8jgOwi8,4861
|
97
97
|
biolib/compute_node/webserver/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
98
98
|
biolib/compute_node/webserver/gunicorn_flask_application.py,sha256=jPfR_YvNBekLUXWo_vHFV-FIwlb8s8tacKmGHvh93qc,914
|
99
99
|
biolib/compute_node/webserver/webserver.py,sha256=o4kOAStsqThUtKlnRE-U5TP0JIYntuySDjU7PH310xg,6620
|
@@ -120,8 +120,8 @@ biolib/utils/cache_state.py,sha256=u256F37QSRIVwqKlbnCyzAX4EMI-kl6Dwu6qwj-Qmag,3
|
|
120
120
|
biolib/utils/multipart_uploader.py,sha256=XvGP1I8tQuKhAH-QugPRoEsCi9qvbRk-DVBs5PNwwJo,8452
|
121
121
|
biolib/utils/seq_util.py,sha256=Ozk0blGtPur_D9MwShD02r_mphyQmgZkx-lOHOwnlIM,6730
|
122
122
|
biolib/utils/zip/remote_zip.py,sha256=0wErYlxir5921agfFeV1xVjf29l9VNgGQvNlWOlj2Yc,23232
|
123
|
-
pybiolib-1.2.
|
124
|
-
pybiolib-1.2.
|
125
|
-
pybiolib-1.2.
|
126
|
-
pybiolib-1.2.
|
127
|
-
pybiolib-1.2.
|
123
|
+
pybiolib-1.2.230.dist-info/LICENSE,sha256=F2h7gf8i0agDIeWoBPXDMYScvQOz02pAWkKhTGOHaaw,1067
|
124
|
+
pybiolib-1.2.230.dist-info/METADATA,sha256=pHStJR-mwTW8Plixvbbd1rtb8Msj8BmiCBOi6-ORvnY,1558
|
125
|
+
pybiolib-1.2.230.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
|
126
|
+
pybiolib-1.2.230.dist-info/entry_points.txt,sha256=p6DyaP_2kctxegTX23WBznnrDi4mz6gx04O5uKtRDXg,42
|
127
|
+
pybiolib-1.2.230.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|