pybiolib 1.1.1921__py3-none-any.whl → 1.1.1926__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.
@@ -9,6 +9,7 @@ class RuntimeJobDataDict(TypedDict):
9
9
  job_requested_machine: str
10
10
  job_uuid: str
11
11
  job_auth_token: str
12
+ app_uri: str
12
13
 
13
14
 
14
15
  class BioLibRuntimeError(Exception):
@@ -40,6 +41,10 @@ class Runtime:
40
41
  def get_job_requested_machine() -> str:
41
42
  return Runtime._get_job_data()['job_requested_machine']
42
43
 
44
+ @staticmethod
45
+ def get_app_uri() -> str:
46
+ return Runtime._get_job_data()['app_uri']
47
+
43
48
  @staticmethod
44
49
  def set_main_result_prefix(result_prefix: str) -> None:
45
50
  job_data = Runtime._get_job_data()
@@ -49,6 +54,12 @@ class Runtime:
49
54
  path=f"/jobs/{job_data['job_uuid']}/main_result/",
50
55
  )
51
56
 
57
+ @staticmethod
58
+ def create_result_note(note: str) -> None:
59
+ job_id = Runtime.get_job_id()
60
+ # Authentication is added by app caller proxy in compute node
61
+ api.client.patch(data={'note': note}, path=f'/jobs/{job_id}/notes/')
62
+
52
63
  @staticmethod
53
64
  def _try_to_get_job_data() -> Optional[RuntimeJobDataDict]:
54
65
  if not Runtime._job_data:
@@ -15,6 +15,7 @@ class JobState(Enum):
15
15
 
16
16
 
17
17
  class _Job(TypedDict):
18
+ app_uri: str
18
19
  app_version: AppVersionOnJob
19
20
  arguments_override_command: bool
20
21
  auth_token: str
@@ -22,10 +23,10 @@ class _Job(TypedDict):
22
23
  created_at: str
23
24
  federated_job_uuid: Optional[str]
24
25
  public_id: str
25
- uuid: str
26
26
  remote_hosts_with_warning: List[RemoteHost]
27
27
  state: str
28
28
  user_id: Optional[str]
29
+ uuid: str
29
30
 
30
31
 
31
32
  # type optional keys with total=False
@@ -275,6 +275,7 @@ class DockerExecutor:
275
275
  job_requested_machine=self._options['job']['requested_machine'],
276
276
  job_uuid=self._options['job']['public_id'],
277
277
  job_auth_token=self._options['job']['auth_token'],
278
+ app_uri=self._options['job']['app_uri'],
278
279
  )
279
280
  secrets: Dict[str, str] = dict(
280
281
  **module.get('secrets', {}),
@@ -1,21 +1,20 @@
1
1
  import io
2
- import tarfile
3
2
  import subprocess
3
+ import tarfile
4
4
  import time
5
5
 
6
- from docker.models.containers import Container # type: ignore
7
6
  from docker.errors import ImageNotFound # type: ignore
7
+ from docker.models.containers import Container # type: ignore
8
8
  from docker.models.images import Image # type: ignore
9
9
  from docker.models.networks import Network # type: ignore
10
10
 
11
11
  from biolib import utils
12
- from biolib.biolib_errors import BioLibError
13
- from biolib.compute_node.cloud_utils import CloudUtils
14
- from biolib.typing_utils import Optional, List
15
- from biolib.biolib_api_client import RemoteHost
12
+ from biolib.biolib_api_client import BiolibApiClient, RemoteHost
16
13
  from biolib.biolib_docker_client import BiolibDockerClient
14
+ from biolib.biolib_errors import BioLibError
17
15
  from biolib.biolib_logging import logger_no_user_data
18
- from biolib.biolib_api_client import BiolibApiClient
16
+ from biolib.compute_node.cloud_utils import CloudUtils
17
+ from biolib.typing_utils import List, Optional
19
18
 
20
19
 
21
20
  # Prepare for remote hosts with specified port
@@ -24,31 +23,25 @@ class RemoteHostExtended(RemoteHost):
24
23
 
25
24
 
26
25
  class RemoteHostProxy:
27
-
28
26
  def __init__(
29
- self,
30
- remote_host: RemoteHost,
31
- public_network: Network,
32
- internal_network: Optional[Network],
33
- job_id: str,
34
- ports: List[int],
35
- can_push_data_record_for_user: bool,
27
+ self,
28
+ remote_host: RemoteHost,
29
+ public_network: Network,
30
+ internal_network: Optional[Network],
31
+ job_id: str,
32
+ ports: List[int],
33
+ can_push_data_record_for_user: bool,
36
34
  ):
37
35
  self._can_push_data_record_for_user: bool = can_push_data_record_for_user
38
36
  self.is_app_caller_proxy = remote_host['hostname'] == 'AppCallerProxy'
39
-
40
- # Default to port 443 for now until backend serves remote_hosts with port specified
41
- self._remote_host: RemoteHostExtended = RemoteHostExtended(
42
- hostname=remote_host['hostname'],
43
- ports=ports
44
- )
37
+ self._remote_host: RemoteHostExtended = RemoteHostExtended(hostname=remote_host['hostname'], ports=ports)
45
38
  self._public_network: Network = public_network
46
39
  self._internal_network: Optional[Network] = internal_network
47
40
 
48
41
  if not job_id:
49
42
  raise Exception('RemoteHostProxy missing argument "job_id"')
50
43
 
51
- self._name = f"biolib-remote-host-proxy-{job_id}-{self.hostname}"
44
+ self._name = f'biolib-remote-host-proxy-{job_id}-{self.hostname}'
52
45
  self._job_uuid = job_id
53
46
  self._container: Optional[Container] = None
54
47
  self._enclave_traffic_forwarder_processes: List[subprocess.Popen] = []
@@ -165,15 +158,19 @@ class RemoteHostProxy:
165
158
  else:
166
159
  raise BioLibError('Calling apps inside apps is not supported in local compute environment')
167
160
 
161
+ compute_node_uuid: Optional[str] = None
162
+ compute_node_auth_token: Optional[str] = None
168
163
  if utils.IS_RUNNING_IN_CLOUD:
169
164
  config = CloudUtils.get_webserver_config()
165
+ compute_node_uuid = config['compute_node_info']['public_id']
166
+ compute_node_auth_token = config['compute_node_info']['auth_token']
170
167
  s3_results_bucket_name = config['s3_general_storage_bucket_name']
171
168
  s3_results_base_url = f'https://{s3_results_bucket_name}.s3.amazonaws.com'
172
169
  else:
173
170
  if base_url in ('https://biolib.com', 'https://staging-elb.biolib.com'):
174
171
  s3_results_base_url = 'https://biolib-cloud-api.s3.amazonaws.com'
175
172
  else:
176
- raise BioLibError("Calling apps inside apps locally is only supported on biolib.com")
173
+ raise BioLibError('Calling apps inside apps locally is only supported on biolib.com')
177
174
 
178
175
  # TODO: Get access_token from new API class instead
179
176
  access_token = BiolibApiClient.get().access_token
@@ -287,6 +284,17 @@ http {{
287
284
  proxy_ssl_server_name on;
288
285
  }}
289
286
 
287
+ location ~ "^/api/jobs/{self._job_uuid}/notes/$" {{
288
+ # Note: Using $1 here as URI part from regex must be used for proxy_pass
289
+ proxy_pass {base_url}/api/{self._job_uuid}/notes/$1;
290
+ proxy_set_header authorization "";
291
+ proxy_set_header job-auth-token "";
292
+ proxy_set_header compute-node-auth-token "{compute_node_auth_token}";
293
+ proxy_set_header compute-node-uuid "{compute_node_uuid}";
294
+ proxy_set_header cookie "";
295
+ proxy_ssl_server_name on;
296
+ }}
297
+
290
298
  location /api/lfs/ {{
291
299
  proxy_pass {base_url}/api/lfs/;
292
300
  proxy_set_header authorization {'$bearer_token_on_post_and_get' if self._can_push_data_record_for_user else '""'};
@@ -345,13 +353,13 @@ http {{
345
353
  }}
346
354
  '''
347
355
  else:
348
- nginx_config = '''
356
+ nginx_config = """
349
357
  events {}
350
358
  error_log /dev/stdout info;
351
359
  stream {
352
- resolver 127.0.0.11 valid=30s;'''
360
+ resolver 127.0.0.11 valid=30s;"""
353
361
  for idx, upstream_server_port in enumerate(upstream_server_ports):
354
- nginx_config += f'''
362
+ nginx_config += f"""
355
363
  map "" $upstream_{idx} {{
356
364
  default {upstream_server_name}:{upstream_server_port};
357
365
  }}
@@ -364,11 +372,11 @@ stream {
364
372
  server {{
365
373
  listen {self._remote_host['ports'][idx]} udp;
366
374
  proxy_pass $upstream_{idx};
367
- }}'''
375
+ }}"""
368
376
 
369
- nginx_config += '''
377
+ nginx_config += """
370
378
  }
371
- '''
379
+ """
372
380
 
373
381
  nginx_config_bytes = nginx_config.encode()
374
382
  tarfile_in_memory = io.BytesIO()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pybiolib
3
- Version: 1.1.1921
3
+ Version: 1.1.1926
4
4
  Summary: BioLib Python Client
5
5
  Home-page: https://github.com/biolib
6
6
  License: MIT
@@ -7,7 +7,7 @@ biolib/_internal/data_record/data_record.py,sha256=ctijrrZ-LfUxtwzS8PEVa1VBuBLVW
7
7
  biolib/_internal/data_record/remote_storage_endpoint.py,sha256=LPq8Lr5FhKF9_o5K-bUdT7TeLe5XFUD0AAeTkNEVZug,1133
8
8
  biolib/_internal/http_client.py,sha256=38PHvRkqdjcOgRXkWU7UoYCQxHMX0eKpuwKhudDupII,4525
9
9
  biolib/_internal/push_application.py,sha256=H1PGNtVJ0vRC0li39gFMpPpjm6QeZ8Ob-7cLkLmxS_Y,10009
10
- biolib/_internal/runtime.py,sha256=un18gmB2wFOXVjKca1Oe6mZI-xGydz8C8seScNvnC2s,2197
10
+ biolib/_internal/runtime.py,sha256=UbRGWLQHB5-OrPGgKDGpXFchB35jc02IdjgNUWkoW1E,2564
11
11
  biolib/_internal/utils/__init__.py,sha256=p5vsIFyu-zYqBgdSMfwW9NC_jk7rXvvCbV4Bzd3As7c,630
12
12
  biolib/api/__init__.py,sha256=iIO8ZRdn7YDhY5cR47-Wo1YsNOK8H6RN6jn8yor5WJI,137
13
13
  biolib/api/client.py,sha256=MtDkH2Amr2Fko-bCR5DdookJu0yZ1q-6K_PPg4KK_Ek,2941
@@ -21,7 +21,7 @@ biolib/biolib_api_client/auth.py,sha256=kjm0ZHnH3I8so3su2sZbBxNHYp-ZUdrZ5lwQ0K36
21
21
  biolib/biolib_api_client/biolib_app_api.py,sha256=DndlVxrNTes6DOaWyMINLGZQCRMWVvR7gwt5HVlyf5Y,4240
22
22
  biolib/biolib_api_client/biolib_job_api.py,sha256=IpFahcRzm7GNy8DJ-XHYe-x7r4Voba8o22IXw5puHn8,6782
23
23
  biolib/biolib_api_client/common_types.py,sha256=RH-1KNHqUF-EkTpfPOSTt5Mq1GPdfju_cqXDesscO1I,123
24
- biolib/biolib_api_client/job_types.py,sha256=XlDIxijxymLoJcClXhl91h1E4b2fT3pszO9wjlssD4A,1284
24
+ biolib/biolib_api_client/job_types.py,sha256=MUzXv7nCsoLiPxdC3D4mZe9a4xTeq7FgxTElLVwVhnw,1301
25
25
  biolib/biolib_api_client/lfs_types.py,sha256=xaGjE-yUyNVM3LyKdslJn5ZXWp6_kVCd4o-ch8Czfm4,227
26
26
  biolib/biolib_api_client/user_state.py,sha256=XcgWV-MgVk88mIlMmnu8yHxMu8OCaw8o0tk7TVo5Hcg,637
27
27
  biolib/biolib_binary_format/__init__.py,sha256=HMl5SdX_VUWE4OQzi4Jf_yFvC7b0bSPOGPHYi9dWM2Q,185
@@ -59,7 +59,7 @@ biolib/compute_node/job_worker/cache_state.py,sha256=MwjSRzcJJ_4jybqvBL4xdgnDYSI
59
59
  biolib/compute_node/job_worker/cache_types.py,sha256=ajpLy8i09QeQS9dEqTn3T6NVNMY_YsHQkSD5nvIHccQ,818
60
60
  biolib/compute_node/job_worker/docker_image_cache.py,sha256=ansHIkJIq_EMW1nZNlW-RRLVVeKWTbzNICYaOHpKiRE,7460
61
61
  biolib/compute_node/job_worker/executors/__init__.py,sha256=bW6t1qi3PZTlHM4quaTLa8EI4ALTCk83cqcVJfJfJfE,145
62
- biolib/compute_node/job_worker/executors/docker_executor.py,sha256=n4BEn-bdL10uVvMDwBazK14NY25Fy_IhKY1fNRoX8LI,26455
62
+ biolib/compute_node/job_worker/executors/docker_executor.py,sha256=Mh1Vnamq68iE_Vvd4WlrmY0CnDVW_4QTdVJoTJJyGsE,26512
63
63
  biolib/compute_node/job_worker/executors/docker_types.py,sha256=VhsU1DKtJjx_BbCkVmiPZPH4ROiL1ygW1Y_s1Kbpa2o,216
64
64
  biolib/compute_node/job_worker/executors/tars/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
65
65
  biolib/compute_node/job_worker/executors/types.py,sha256=yP5gG39hr-DLnw9bOE--VHi-1arDbIYiGuV1rlTbbHI,1466
@@ -71,7 +71,7 @@ biolib/compute_node/job_worker/large_file_system.py,sha256=XXqRlVtYhs-Ji9zQGIk5K
71
71
  biolib/compute_node/job_worker/mappings.py,sha256=Z48Kg4nbcOvsT2-9o3RRikBkqflgO4XeaWxTGz-CNvI,2499
72
72
  biolib/compute_node/job_worker/utilization_reporter_thread.py,sha256=7tm5Yk9coqJ9VbEdnO86tSXI0iM0omwIyKENxdxiVXk,8575
73
73
  biolib/compute_node/job_worker/utils.py,sha256=wgxcIA8yAhUPdCwyvuuJ0JmreyWmmUoBO33vWtG60xg,1282
74
- biolib/compute_node/remote_host_proxy.py,sha256=spjYghbqwX3dFrmedGvXZGXEsnwop1IbbyrXTv1PWz0,15080
74
+ biolib/compute_node/remote_host_proxy.py,sha256=OjMtBePFyfDwMy9TKEiJcHc1eVyg_aDfwHxS6UZ3VCw,15763
75
75
  biolib/compute_node/socker_listener_thread.py,sha256=T5_UikA3MB9bD5W_dckYLPTgixh72vKUlgbBvj9dbM0,1601
76
76
  biolib/compute_node/socket_sender_thread.py,sha256=YgamPHeUm2GjMFGx8qk-99WlZhEs-kAb3q_2O6qByig,971
77
77
  biolib/compute_node/utils.py,sha256=M7i_WTyxbFM3Lri9RWZ_8FeQNYrQIWpKGLfp2I55oeY,4677
@@ -105,8 +105,8 @@ biolib/utils/cache_state.py,sha256=u256F37QSRIVwqKlbnCyzAX4EMI-kl6Dwu6qwj-Qmag,3
105
105
  biolib/utils/multipart_uploader.py,sha256=XvGP1I8tQuKhAH-QugPRoEsCi9qvbRk-DVBs5PNwwJo,8452
106
106
  biolib/utils/seq_util.py,sha256=jC5WhH63FTD7SLFJbxQGA2hOt9NTwq9zHl_BEec1Z0c,4907
107
107
  biolib/utils/zip/remote_zip.py,sha256=0wErYlxir5921agfFeV1xVjf29l9VNgGQvNlWOlj2Yc,23232
108
- pybiolib-1.1.1921.dist-info/LICENSE,sha256=F2h7gf8i0agDIeWoBPXDMYScvQOz02pAWkKhTGOHaaw,1067
109
- pybiolib-1.1.1921.dist-info/METADATA,sha256=quYP4m07RNqDCIBxj-UafoDq46C2e63zXhXD1QLGhiQ,1508
110
- pybiolib-1.1.1921.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
111
- pybiolib-1.1.1921.dist-info/entry_points.txt,sha256=p6DyaP_2kctxegTX23WBznnrDi4mz6gx04O5uKtRDXg,42
112
- pybiolib-1.1.1921.dist-info/RECORD,,
108
+ pybiolib-1.1.1926.dist-info/LICENSE,sha256=F2h7gf8i0agDIeWoBPXDMYScvQOz02pAWkKhTGOHaaw,1067
109
+ pybiolib-1.1.1926.dist-info/METADATA,sha256=zQeAwzfJS-WmGU11lXt6XUKjuTccoiGj6yIwDY5Fm5U,1508
110
+ pybiolib-1.1.1926.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
111
+ pybiolib-1.1.1926.dist-info/entry_points.txt,sha256=p6DyaP_2kctxegTX23WBznnrDi4mz6gx04O5uKtRDXg,42
112
+ pybiolib-1.1.1926.dist-info/RECORD,,