pybiolib 1.2.144.dev1__py3-none-any.whl → 1.2.158.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.
@@ -1,10 +1,13 @@
1
1
  import json
2
+ import logging
3
+ import os
2
4
  import re
3
5
  from typing import Optional
4
6
 
5
7
  from biolib import api
6
8
  from biolib._internal.runtime import BioLibRuntimeError, BioLibRuntimeNotRecognizedError, RuntimeJobDataDict
7
9
  from biolib.typing_utils import cast
10
+ from biolib.utils.seq_util import SeqUtil
8
11
 
9
12
 
10
13
  class Runtime:
@@ -54,6 +57,32 @@ class Runtime:
54
57
  path=f"/jobs/{job_data['job_uuid']}/main_result/",
55
58
  )
56
59
 
60
+ @staticmethod
61
+ def set_result_name_prefix(result_prefix: str) -> None:
62
+ Runtime.set_main_result_prefix(result_prefix)
63
+
64
+ @staticmethod
65
+ def set_result_name_prefix_from_fasta(path_to_fasta: str) -> None:
66
+ """
67
+ Set BioLib result name to FASTA file name (excluding file extension) or,
68
+ if detecting a BioLib generated name, use ID of the first sequence in the fasta file
69
+ """
70
+
71
+ def file_path_to_stem(file_path):
72
+ return os.path.splitext(os.path.basename(file_path))[0]
73
+
74
+ # Set job name to first header if FASTA text input (random BioLib file) detected
75
+ if re.match('^input_[A-Za-z0-9]+.*', path_to_fasta):
76
+ first_id = next(SeqUtil.parse_fasta(path_to_fasta)).id
77
+ job_name = first_id.replace(' ', '_')[:60]
78
+
79
+ else:
80
+ job_name = file_path_to_stem(path_to_fasta)
81
+
82
+ logging.debug(f"Setting job name to '{job_name}' from {path_to_fasta}")
83
+
84
+ Runtime.set_result_name_prefix(job_name)
85
+
57
86
  @staticmethod
58
87
  def create_result_note(note: str) -> None:
59
88
  job_id = Runtime.get_job_id()
biolib/jobs/job.py CHANGED
@@ -210,11 +210,14 @@ class Job:
210
210
  http_response = HttpClient.request(url=job_storage_input.get_remote_url())
211
211
  module_input_serialized = http_response.content
212
212
 
213
+ original_requested_machine = (
214
+ self._job_dict['requested_machine'] if self._job_dict['requested_machine'] else None
215
+ )
213
216
  job = self._start_job_in_cloud(
214
217
  app_uri=app_response['app_uri'],
215
218
  app_version_uuid=app_response['app_version']['public_id'],
216
219
  module_input_serialized=module_input_serialized,
217
- machine=machine,
220
+ machine=machine if machine else original_requested_machine,
218
221
  )
219
222
  if blocking:
220
223
  job.stream_logs()
biolib/jobs/types.py CHANGED
@@ -29,6 +29,7 @@ class JobDict(TypedDict):
29
29
  auth_token: str
30
30
  created_at: str
31
31
  ended_at: Optional[str]
32
+ requested_machine: str
32
33
  runtime_seconds: int
33
34
  main_result: Result
34
35
  started_at: str
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pybiolib
3
- Version: 1.2.144.dev1
3
+ Version: 1.2.158.dev1
4
4
  Summary: BioLib Python Client
5
5
  Home-page: https://github.com/biolib
6
6
  License: MIT
@@ -26,7 +26,7 @@ biolib/_internal/types/resource_version.py,sha256=sLxViYXloDDUhTDFgjegiQCj097OM1
26
26
  biolib/_internal/types/typing.py,sha256=D4EKKEe7kDx0K6lJi-H_XLtk-8w6nu2fdqn9bvzI-Xo,288
27
27
  biolib/_internal/utils/__init__.py,sha256=p5vsIFyu-zYqBgdSMfwW9NC_jk7rXvvCbV4Bzd3As7c,630
28
28
  biolib/_internal/utils/multinode.py,sha256=zWrQhcVK5u_xdWX2oIM-D_2fINqNPlqF_h71fu4K8LY,8279
29
- biolib/_runtime/runtime.py,sha256=oVgTnDDJv9L4BUP1_sd0oAj4LLyyiPSQdhp7ixWARvw,2923
29
+ biolib/_runtime/runtime.py,sha256=qV706-ZaBihrxSzD9ks62mbllJ3ruCoa6Ecf2zF7naA,3997
30
30
  biolib/api/__init__.py,sha256=mQ4u8FijqyLzjYMezMUUbbBGNB3iFmkNdjXnWPZ7Jlw,138
31
31
  biolib/api/client.py,sha256=FRpdH5aI187b_I_4HUNi680v4iOP65z5f2RcUo8D8MA,3559
32
32
  biolib/app/__init__.py,sha256=cdPtcfb_U-bxb9iSL4fCEq2rpD9OjkyY4W-Zw60B0LI,37
@@ -102,9 +102,9 @@ biolib/compute_node/webserver/worker_thread.py,sha256=GRRBUqXdMKvbjyLQhYlqGIbFKe
102
102
  biolib/experiments/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
103
103
  biolib/experiments/experiment.py,sha256=jIRixmQm3Gq9YdJ3I0-rE1vFukXqq6U4zXehFOJ1yZk,7614
104
104
  biolib/jobs/__init__.py,sha256=aIb2H2DHjQbM2Bs-dysFijhwFcL58Blp0Co0gimED3w,32
105
- biolib/jobs/job.py,sha256=ej-dxt1hMBQXzTfUZ2SLqIV8dtTbMSMn_q2rjIA7oN4,19903
105
+ biolib/jobs/job.py,sha256=k9uksoA7BgSU-Mw5jHtuLHdTlg-G_d_89nVoPYcUnbg,20092
106
106
  biolib/jobs/job_result.py,sha256=rALHiKYNaC9lHi_JJqBob1RubzNLwG9Z386kwRJjd2M,5885
107
- biolib/jobs/types.py,sha256=qhadtH2KDC2WUOOqPiwke0YgtQY4FtuB71Stekq1k48,970
107
+ biolib/jobs/types.py,sha256=ezvaoTANsWazK6PmfpYcqezdfjP7MNBEBfqIZGoZhz8,997
108
108
  biolib/runtime/__init__.py,sha256=MlRepA11n2H-3plB5rzWyyHK2JmP6PiaP3i6x3vt0mg,506
109
109
  biolib/sdk/__init__.py,sha256=8uyOAKt8-Xo11jAWXCg14NkE1u0FkOBC07L3V7wGsCg,1960
110
110
  biolib/tables.py,sha256=acH7VjwAbadLo8P84FSnKEZxCTVsF5rEg9VPuxElNs8,872
@@ -119,8 +119,8 @@ biolib/utils/cache_state.py,sha256=u256F37QSRIVwqKlbnCyzAX4EMI-kl6Dwu6qwj-Qmag,3
119
119
  biolib/utils/multipart_uploader.py,sha256=XvGP1I8tQuKhAH-QugPRoEsCi9qvbRk-DVBs5PNwwJo,8452
120
120
  biolib/utils/seq_util.py,sha256=WJnU9vZdwY8RHXvzATyV80OXzyJ7w9EkG33Tna9Nr6A,5698
121
121
  biolib/utils/zip/remote_zip.py,sha256=0wErYlxir5921agfFeV1xVjf29l9VNgGQvNlWOlj2Yc,23232
122
- pybiolib-1.2.144.dev1.dist-info/LICENSE,sha256=F2h7gf8i0agDIeWoBPXDMYScvQOz02pAWkKhTGOHaaw,1067
123
- pybiolib-1.2.144.dev1.dist-info/METADATA,sha256=xXVO2tJLTCb1AV2U-KwCZBkGYelDWpZMNaIedHGM9Qg,1512
124
- pybiolib-1.2.144.dev1.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
125
- pybiolib-1.2.144.dev1.dist-info/entry_points.txt,sha256=p6DyaP_2kctxegTX23WBznnrDi4mz6gx04O5uKtRDXg,42
126
- pybiolib-1.2.144.dev1.dist-info/RECORD,,
122
+ pybiolib-1.2.158.dev1.dist-info/LICENSE,sha256=F2h7gf8i0agDIeWoBPXDMYScvQOz02pAWkKhTGOHaaw,1067
123
+ pybiolib-1.2.158.dev1.dist-info/METADATA,sha256=7gYFVnp6YM8fLfHzg0S_XDeC6DxdTzeDX6dfWesenm0,1512
124
+ pybiolib-1.2.158.dev1.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
125
+ pybiolib-1.2.158.dev1.dist-info/entry_points.txt,sha256=p6DyaP_2kctxegTX23WBznnrDi4mz6gx04O5uKtRDXg,42
126
+ pybiolib-1.2.158.dev1.dist-info/RECORD,,