pybiolib 1.2.1126__py3-none-any.whl → 1.2.1133__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/compute_node/webserver/compute_node_results_proxy.py +24 -8
- biolib/compute_node/webserver/webserver.py +2 -2
- {pybiolib-1.2.1126.dist-info → pybiolib-1.2.1133.dist-info}/METADATA +1 -1
- {pybiolib-1.2.1126.dist-info → pybiolib-1.2.1133.dist-info}/RECORD +7 -7
- {pybiolib-1.2.1126.dist-info → pybiolib-1.2.1133.dist-info}/LICENSE +0 -0
- {pybiolib-1.2.1126.dist-info → pybiolib-1.2.1133.dist-info}/WHEEL +0 -0
- {pybiolib-1.2.1126.dist-info → pybiolib-1.2.1133.dist-info}/entry_points.txt +0 -0
@@ -1,4 +1,5 @@
|
|
1
1
|
import io
|
2
|
+
import os
|
2
3
|
import tarfile
|
3
4
|
import threading
|
4
5
|
import time
|
@@ -7,10 +8,10 @@ from docker.models.containers import Container
|
|
7
8
|
|
8
9
|
from biolib.biolib_docker_client import BiolibDockerClient
|
9
10
|
from biolib.biolib_errors import BioLibError
|
10
|
-
from biolib.biolib_logging import
|
11
|
+
from biolib.biolib_logging import logger, logger_no_user_data
|
11
12
|
from biolib.compute_node.utils import BIOLIB_PROXY_NETWORK_NAME
|
12
|
-
from biolib.typing_utils import Optional
|
13
13
|
from biolib.compute_node.webserver.proxy_utils import get_biolib_nginx_proxy_image
|
14
|
+
from biolib.typing_utils import Optional
|
14
15
|
|
15
16
|
|
16
17
|
class LogStreamingThread(threading.Thread):
|
@@ -28,7 +29,7 @@ class LogStreamingThread(threading.Thread):
|
|
28
29
|
if self._stop_event.is_set():
|
29
30
|
break
|
30
31
|
if log_line:
|
31
|
-
logger.debug(f'ComputeNodeResultsProxy | {log_line.decode("utf-8").rstrip()}')
|
32
|
+
logger.debug(f'ComputeNodeResultsProxy | {log_line.decode("utf-8", errors="replace").rstrip()}')
|
32
33
|
except Exception as error:
|
33
34
|
logger_no_user_data.debug(f'Log streaming for container "{self._container_name}" ended: {error}')
|
34
35
|
|
@@ -40,8 +41,8 @@ class ComputeNodeResultsProxy:
|
|
40
41
|
_instance: Optional['ComputeNodeResultsProxy'] = None
|
41
42
|
|
42
43
|
def __init__(self, tls_pem_certificate_path: str, tls_pem_key_path: str):
|
43
|
-
assert tls_pem_certificate_path,
|
44
|
-
assert tls_pem_key_path,
|
44
|
+
assert tls_pem_certificate_path, 'tls_pem_certificate_path is required'
|
45
|
+
assert tls_pem_key_path, 'tls_pem_key_path is required'
|
45
46
|
self._name = 'biolib-compute-node-results-proxy'
|
46
47
|
self._container: Optional[Container] = None
|
47
48
|
self._docker = BiolibDockerClient().get_docker_client()
|
@@ -51,8 +52,16 @@ class ComputeNodeResultsProxy:
|
|
51
52
|
|
52
53
|
@staticmethod
|
53
54
|
def start_proxy(tls_pem_certificate_path: str, tls_pem_key_path: str) -> None:
|
55
|
+
abs_cert_path = os.path.abspath(tls_pem_certificate_path)
|
56
|
+
abs_key_path = os.path.abspath(tls_pem_key_path)
|
57
|
+
assert os.path.exists(abs_cert_path), f'TLS certificate file does not exist: {abs_cert_path}'
|
58
|
+
assert os.path.exists(abs_key_path), f'TLS key file does not exist: {abs_key_path}'
|
59
|
+
|
54
60
|
if ComputeNodeResultsProxy._instance is None:
|
55
|
-
|
61
|
+
logger_no_user_data.debug(
|
62
|
+
f'Creating ComputeNodeResultsProxy instance with cert: {abs_cert_path}, key: {abs_key_path}'
|
63
|
+
)
|
64
|
+
ComputeNodeResultsProxy._instance = ComputeNodeResultsProxy(abs_cert_path, abs_key_path)
|
56
65
|
ComputeNodeResultsProxy._instance._start() # pylint: disable=protected-access
|
57
66
|
|
58
67
|
@staticmethod
|
@@ -93,6 +102,7 @@ class ComputeNodeResultsProxy:
|
|
93
102
|
self._write_nginx_config_to_container()
|
94
103
|
self._container.start()
|
95
104
|
|
105
|
+
logger_no_user_data.debug(f'Waiting for container "{self._name}" to be ready...')
|
96
106
|
proxy_is_ready = False
|
97
107
|
for retry_count in range(1, 5):
|
98
108
|
time.sleep(0.5 * retry_count)
|
@@ -102,22 +112,27 @@ class ComputeNodeResultsProxy:
|
|
102
112
|
break
|
103
113
|
|
104
114
|
if not proxy_is_ready:
|
115
|
+
logger_no_user_data.error('ComputeNodeResultsProxy did not start properly.')
|
105
116
|
self._terminate()
|
106
117
|
raise Exception('ComputeNodeResultsProxy did not start properly')
|
107
118
|
|
108
119
|
self._container.reload()
|
120
|
+
logger.debug(f'ComputeNodeResultsProxy container "{self._name}" started with ID: {self._container.id}')
|
109
121
|
|
110
122
|
self._log_streaming_thread = LogStreamingThread(self._container, self._name)
|
111
123
|
self._log_streaming_thread.start()
|
112
124
|
logger_no_user_data.debug(f'Started log streaming for container "{self._name}"')
|
113
125
|
|
114
126
|
def _terminate(self):
|
127
|
+
logger_no_user_data.debug(f'Terminating ComputeNodeResultsProxy container "{self._name}"')
|
115
128
|
if self._log_streaming_thread:
|
116
129
|
self._log_streaming_thread.stop()
|
117
130
|
self._log_streaming_thread = None
|
118
|
-
if self._container:
|
119
|
-
self._container.remove(force=True)
|
120
131
|
|
132
|
+
logger.debug(f'Docker container removal temporarily disabled for debugging purposes (container "{self._name}")')
|
133
|
+
# TODO: Figure if we need to remove the container or keep it for debugging purposes
|
134
|
+
# if self._container:
|
135
|
+
# self._container.remove(force=True)
|
121
136
|
|
122
137
|
def _write_nginx_config_to_container(self) -> None:
|
123
138
|
if not self._container:
|
@@ -170,4 +185,5 @@ http {
|
|
170
185
|
|
171
186
|
tarfile_bytes = tarfile_in_memory.getvalue()
|
172
187
|
tarfile_in_memory.close()
|
188
|
+
logger_no_user_data.debug('Writing NGINX configuration to ComputeNodeResultsProxy container')
|
173
189
|
docker.api.put_archive(self._container.id, '/etc/nginx', tarfile_bytes)
|
@@ -154,7 +154,7 @@ def start_webserver(
|
|
154
154
|
|
155
155
|
if utils.IS_RUNNING_IN_CLOUD:
|
156
156
|
try:
|
157
|
-
logger_no_user_data.debug('Stopping ComputeNodeResultsProxy')
|
157
|
+
logger_no_user_data.debug('Stopping ComputeNodeResultsProxy...')
|
158
158
|
ComputeNodeResultsProxy.stop_proxy()
|
159
159
|
except BaseException:
|
160
160
|
logger_no_user_data.exception('Failed to stop ComputeNodeResultsProxy')
|
@@ -192,7 +192,7 @@ def start_webserver(
|
|
192
192
|
|
193
193
|
if biolib_proxy_network:
|
194
194
|
try:
|
195
|
-
logger_no_user_data.debug('Starting ComputeNodeResultsProxy')
|
195
|
+
logger_no_user_data.debug('Starting ComputeNodeResultsProxy...')
|
196
196
|
ComputeNodeResultsProxy.start_proxy(tls_pem_certificate_path, tls_pem_key_path)
|
197
197
|
except BaseException:
|
198
198
|
logger_no_user_data.exception('Failed to start ComputeNodeResultsProxy')
|
@@ -131,10 +131,10 @@ biolib/compute_node/socker_listener_thread.py,sha256=T5_UikA3MB9bD5W_dckYLPTgixh
|
|
131
131
|
biolib/compute_node/socket_sender_thread.py,sha256=YgamPHeUm2GjMFGx8qk-99WlZhEs-kAb3q_2O6qByig,971
|
132
132
|
biolib/compute_node/utils.py,sha256=fvdbetPKMdfHkPqNZRw6eln_i13myu-n8tuceTUcfPU,4913
|
133
133
|
biolib/compute_node/webserver/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
134
|
-
biolib/compute_node/webserver/compute_node_results_proxy.py,sha256=
|
134
|
+
biolib/compute_node/webserver/compute_node_results_proxy.py,sha256=6Li4Fm7sgNVYd_kLVChlx5aUvKtYtMa0hHmv7umECJ4,8168
|
135
135
|
biolib/compute_node/webserver/gunicorn_flask_application.py,sha256=jPfR_YvNBekLUXWo_vHFV-FIwlb8s8tacKmGHvh93qc,914
|
136
136
|
biolib/compute_node/webserver/proxy_utils.py,sha256=JNt1oqPuR5n63E5NC1l8AZN51NLuMw4lqVkocZnq72o,1164
|
137
|
-
biolib/compute_node/webserver/webserver.py,sha256=
|
137
|
+
biolib/compute_node/webserver/webserver.py,sha256=8SUGXJ0tGuUIQ3HKdac-CFFQwDVpKR6JwEINChBt-Qg,9067
|
138
138
|
biolib/compute_node/webserver/webserver_types.py,sha256=2t8EaFKESnves3BA_NBdnS2yAdo1qwamCFHiSt888nE,380
|
139
139
|
biolib/compute_node/webserver/webserver_utils.py,sha256=XWvwYPbWNR3qS0FYbLLp-MDDfVk0QdaAmg3xPrT0H2s,4234
|
140
140
|
biolib/compute_node/webserver/worker_thread.py,sha256=7uD9yQPhePYvP2HCJ27EeZ_h6psfIWFgqm1RHZxzobs,12483
|
@@ -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=Ozk0blGtPur_D9MwShD02r_mphyQmgZkx-lOHOwnlIM,6730
|
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.1133.dist-info/LICENSE,sha256=F2h7gf8i0agDIeWoBPXDMYScvQOz02pAWkKhTGOHaaw,1067
|
161
|
+
pybiolib-1.2.1133.dist-info/METADATA,sha256=YFJ8gC4dTDUNDh8H8A6Qpf9yerMrthiUH3xjUG01UZA,1571
|
162
|
+
pybiolib-1.2.1133.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
|
163
|
+
pybiolib-1.2.1133.dist-info/entry_points.txt,sha256=p6DyaP_2kctxegTX23WBznnrDi4mz6gx04O5uKtRDXg,42
|
164
|
+
pybiolib-1.2.1133.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|