pybiolib 1.2.322.dev1__py3-none-any.whl → 1.2.334.dev1__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.
@@ -71,7 +71,7 @@ def run_locally(command_list, args):
71
71
  print(f'Error: {result.stderr}')
72
72
 
73
73
 
74
- def fasta_batch_records(fasta_file, work_per_batch_min, work_per_residue=1, verbose=False):
74
+ def fasta_batch_records(records, work_per_batch_min, work_per_residue=1, verbose=False):
75
75
  """Converts FASTA records to batches of records, based on thresholds"""
76
76
 
77
77
  def log_batches(batches):
@@ -84,7 +84,7 @@ def fasta_batch_records(fasta_file, work_per_batch_min, work_per_residue=1, verb
84
84
  n_seqs, n_res = batch_dict['records'], batch_dict['residues']
85
85
  print(f'Batch {i+1}: {n_res} residues from {n_seqs} sequences')
86
86
 
87
- records = SeqUtil.parse_fasta(fasta_file)
87
+ # records = SeqUtil.parse_fasta(fasta_file)
88
88
 
89
89
  batches = []
90
90
  batch = []
@@ -7,6 +7,7 @@ import sys
7
7
  import threading
8
8
  import time
9
9
  from queue import Queue
10
+ from typing import Optional
10
11
 
11
12
  from biolib import api, utils
12
13
  from biolib.biolib_binary_format import ModuleOutputV2, SystemException, SystemStatusUpdate
@@ -55,6 +56,26 @@ class WorkerThread(threading.Thread):
55
56
  def _job_temporary_dir(self):
56
57
  return self.compute_state['job_temporary_dir']
57
58
 
59
+ def _upload_module_output_and_get_exit_code(self) -> Optional[int]:
60
+ exit_code = None
61
+ try:
62
+ module_output_path = os.path.join(
63
+ self._job_temporary_dir,
64
+ JobStorage.module_output_file_name,
65
+ )
66
+ if os.path.exists(module_output_path):
67
+ module_output = ModuleOutputV2(buffer=LocalFileIndexableBuffer(filename=module_output_path))
68
+ exit_code = module_output.get_exit_code()
69
+ logger_no_user_data.debug(f'Got exit code: {exit_code}')
70
+ if utils.IS_RUNNING_IN_CLOUD:
71
+ JobStorage.upload_module_output(
72
+ job_temporary_dir=self._job_temporary_dir,
73
+ job_uuid=self._job_uuid,
74
+ )
75
+ except Exception as error:
76
+ logger_no_user_data.error(f'Could not upload module output or get exit code: {error}')
77
+ return exit_code
78
+
58
79
  def run(self):
59
80
  try:
60
81
  while True:
@@ -77,25 +98,7 @@ class WorkerThread(threading.Thread):
77
98
 
78
99
  # If 'Computation Finished'
79
100
  if progress == 94:
80
- # Get Job exit code
81
- try:
82
- module_output_path = os.path.join(
83
- self._job_temporary_dir,
84
- JobStorage.module_output_file_name,
85
- )
86
- module_output = ModuleOutputV2(buffer=LocalFileIndexableBuffer(filename=module_output_path))
87
- self.compute_state['exit_code'] = module_output.get_exit_code()
88
- logger_no_user_data.debug(f"Got exit code: {self.compute_state['exit_code']}")
89
-
90
- except Exception as error: # pylint: disable=broad-except
91
- logger_no_user_data.error(f'Could not get exit_code from module output due to: {error}')
92
-
93
- if utils.IS_RUNNING_IN_CLOUD:
94
- JobStorage.upload_module_output(
95
- job_temporary_dir=self._job_temporary_dir,
96
- job_uuid=self._job_uuid,
97
- )
98
-
101
+ self.compute_state['exit_code'] = self._upload_module_output_and_get_exit_code()
99
102
  self._set_status_update(progress=95, log_message='Result Ready')
100
103
  self.compute_state['is_completed'] = True
101
104
  self.terminate()
@@ -174,13 +177,16 @@ class WorkerThread(threading.Thread):
174
177
 
175
178
  def terminate(self) -> None:
176
179
  cloud_job_uuid = self.compute_state['cloud_job_id']
177
- exit_code = self.compute_state.get('exit_code')
178
180
  system_exception_code = self.compute_state['status'].get('error_code')
181
+
179
182
  if utils.IS_RUNNING_IN_CLOUD:
183
+ if system_exception_code == SystemExceptionCodes.CANCELLED_BY_USER.value:
184
+ self.compute_state['exit_code'] = self._upload_module_output_and_get_exit_code()
185
+
180
186
  CloudUtils.finish_cloud_job(
181
187
  cloud_job_id=cloud_job_uuid,
182
188
  system_exception_code=system_exception_code,
183
- exit_code=exit_code,
189
+ exit_code=self.compute_state.get('exit_code', None),
184
190
  )
185
191
 
186
192
  deregistered_due_to_error = False
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: pybiolib
3
- Version: 1.2.322.dev1
3
+ Version: 1.2.334.dev1
4
4
  Summary: BioLib Python Client
5
5
  License: MIT
6
6
  Keywords: biolib
@@ -24,7 +24,7 @@ biolib/_internal/types/resource.py,sha256=G-vPkZoe4Um6FPxsQZtRzAlbSW5sDW4NFkbjn2
24
24
  biolib/_internal/types/resource_version.py,sha256=sLxViYXloDDUhTDFgjegiQCj097OM1Ih1-uqlC_4ULA,174
25
25
  biolib/_internal/types/typing.py,sha256=D4EKKEe7kDx0K6lJi-H_XLtk-8w6nu2fdqn9bvzI-Xo,288
26
26
  biolib/_internal/utils/__init__.py,sha256=p5vsIFyu-zYqBgdSMfwW9NC_jk7rXvvCbV4Bzd3As7c,630
27
- biolib/_internal/utils/multinode.py,sha256=zWrQhcVK5u_xdWX2oIM-D_2fINqNPlqF_h71fu4K8LY,8279
27
+ biolib/_internal/utils/multinode.py,sha256=G0t7dkHtoxIfdCD0vjG8eyQwRxQ0zWazOWZUFQ3hQxw,8278
28
28
  biolib/_runtime/runtime.py,sha256=bZQ0m39R9jOBVAtlyvzDnOobKueOAQUCwMUZjDQnO7E,4439
29
29
  biolib/api/__init__.py,sha256=mQ4u8FijqyLzjYMezMUUbbBGNB3iFmkNdjXnWPZ7Jlw,138
30
30
  biolib/api/client.py,sha256=_kmwaGI_-u7kOeWVCYmo-pD2K1imwEv9n2gNZRb5F-I,3790
@@ -97,7 +97,7 @@ biolib/compute_node/webserver/gunicorn_flask_application.py,sha256=jPfR_YvNBekLU
97
97
  biolib/compute_node/webserver/webserver.py,sha256=o4kOAStsqThUtKlnRE-U5TP0JIYntuySDjU7PH310xg,6620
98
98
  biolib/compute_node/webserver/webserver_types.py,sha256=2t8EaFKESnves3BA_NBdnS2yAdo1qwamCFHiSt888nE,380
99
99
  biolib/compute_node/webserver/webserver_utils.py,sha256=XWvwYPbWNR3qS0FYbLLp-MDDfVk0QdaAmg3xPrT0H2s,4234
100
- biolib/compute_node/webserver/worker_thread.py,sha256=GRRBUqXdMKvbjyLQhYlqGIbFKeU2iiEXIe5IXi9wgdg,11806
100
+ biolib/compute_node/webserver/worker_thread.py,sha256=jakGi-libQJfD7rcB525XbTVIAmI4uZ-xwvzvqFSWgw,11961
101
101
  biolib/experiments/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
102
102
  biolib/experiments/experiment.py,sha256=m7FB7hot8CMOVrNyWGPB6FTkWQJwI0ytpIvtPxfoPME,7684
103
103
  biolib/jobs/__init__.py,sha256=aIb2H2DHjQbM2Bs-dysFijhwFcL58Blp0Co0gimED3w,32
@@ -118,8 +118,8 @@ biolib/utils/cache_state.py,sha256=u256F37QSRIVwqKlbnCyzAX4EMI-kl6Dwu6qwj-Qmag,3
118
118
  biolib/utils/multipart_uploader.py,sha256=XvGP1I8tQuKhAH-QugPRoEsCi9qvbRk-DVBs5PNwwJo,8452
119
119
  biolib/utils/seq_util.py,sha256=Ozk0blGtPur_D9MwShD02r_mphyQmgZkx-lOHOwnlIM,6730
120
120
  biolib/utils/zip/remote_zip.py,sha256=0wErYlxir5921agfFeV1xVjf29l9VNgGQvNlWOlj2Yc,23232
121
- pybiolib-1.2.322.dev1.dist-info/LICENSE,sha256=F2h7gf8i0agDIeWoBPXDMYScvQOz02pAWkKhTGOHaaw,1067
122
- pybiolib-1.2.322.dev1.dist-info/METADATA,sha256=WDLf3UFbGCBrYk9XZwtFOe8DyTiBltMdpI98sWlqaS8,1575
123
- pybiolib-1.2.322.dev1.dist-info/WHEEL,sha256=IYZQI976HJqqOpQU6PHkJ8fb3tMNBFjg-Cn-pwAbaFM,88
124
- pybiolib-1.2.322.dev1.dist-info/entry_points.txt,sha256=p6DyaP_2kctxegTX23WBznnrDi4mz6gx04O5uKtRDXg,42
125
- pybiolib-1.2.322.dev1.dist-info/RECORD,,
121
+ pybiolib-1.2.334.dev1.dist-info/LICENSE,sha256=F2h7gf8i0agDIeWoBPXDMYScvQOz02pAWkKhTGOHaaw,1067
122
+ pybiolib-1.2.334.dev1.dist-info/METADATA,sha256=AXuQRU7aU2ktbCRoVoprdenRGFhL6B5pJ4zQhVH3lu4,1575
123
+ pybiolib-1.2.334.dev1.dist-info/WHEEL,sha256=IYZQI976HJqqOpQU6PHkJ8fb3tMNBFjg-Cn-pwAbaFM,88
124
+ pybiolib-1.2.334.dev1.dist-info/entry_points.txt,sha256=p6DyaP_2kctxegTX23WBznnrDi4mz6gx04O5uKtRDXg,42
125
+ pybiolib-1.2.334.dev1.dist-info/RECORD,,