pybiolib 1.1.1412__py3-none-any.whl → 1.1.1420__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,4 +1,11 @@
1
1
  from biolib.biolib_binary_format.base_bbf_package import BioLibBinaryFormatBasePackage
2
+ from biolib.typing_utils import TypedDict, Dict, List
3
+
4
+
5
+ class ModuleInputDict(TypedDict):
6
+ stdin: bytes
7
+ files: Dict[str, bytes]
8
+ arguments: List[str]
2
9
 
3
10
 
4
11
  class ModuleInput(BioLibBinaryFormatBasePackage):
@@ -36,7 +43,7 @@ class ModuleInput(BioLibBinaryFormatBasePackage):
36
43
 
37
44
  return bbf_data
38
45
 
39
- def deserialize(self):
46
+ def deserialize(self) -> ModuleInputDict:
40
47
  version = self.get_data(1, output_type='int')
41
48
  package_type = self.get_data(1, output_type='int')
42
49
  self.check_version_and_type(version=version, package_type=package_type, expected_package_type=self.package_type)
@@ -62,4 +69,4 @@ class ModuleInput(BioLibBinaryFormatBasePackage):
62
69
  data = self.get_data(data_len)
63
70
  files[path] = bytes(data)
64
71
 
65
- return {'stdin': stdin, 'arguments': arguments, 'files': files}
72
+ return ModuleInputDict(stdin=stdin, arguments=arguments, files=files)
biolib/jobs/job.py CHANGED
@@ -9,7 +9,7 @@ from urllib.parse import urlparse
9
9
  import requests
10
10
  from biolib import api, utils
11
11
  from biolib.biolib_api_client.biolib_job_api import BiolibJobApi
12
- from biolib.biolib_binary_format import LazyLoadedFile, ModuleOutputV2, ModuleInput
12
+ from biolib.biolib_binary_format import LazyLoadedFile, ModuleOutputV2, ModuleInput, ModuleInputDict
13
13
  from biolib.biolib_binary_format.stdout_and_stderr import StdoutAndStderr
14
14
  from biolib.biolib_errors import BioLibError, CloudJobFinishedError
15
15
  from biolib.biolib_logging import logger, logger_no_user_data
@@ -37,6 +37,7 @@ class Job:
37
37
  self._job_dict: JobDict = job_dict
38
38
  self._job_dict_last_fetched_at: datetime = datetime.utcnow()
39
39
  self._result: Optional[JobResult] = None
40
+ self._cached_input_arguments: Optional[List[str]] = None
40
41
 
41
42
  def __str__(self):
42
43
  return f"Job for {self._job_dict['app_uri']} created at {self._job_dict['created_at']} ({self._uuid})"
@@ -114,27 +115,29 @@ class Job:
114
115
  def get_exit_code(self) -> int:
115
116
  return self.result.get_exit_code()
116
117
 
117
- def save_input_files(self, output_dir: str) -> None:
118
+ def _get_module_input(self) -> ModuleInputDict:
118
119
  self._refetch_job_dict()
119
- logger.info('Downloading input files...')
120
- try:
121
- presigned_download_url = BiolibJobApi.get_job_storage_download_url(
122
- job_uuid=self._job_dict['uuid'],
123
- job_auth_token=self._job_dict['auth_token'],
124
- storage_type='input',
125
- )
126
- response = requests.get(url=presigned_download_url)
127
- response.raise_for_status()
128
- module_input_serialized: bytes = response.content
129
- except Exception as error:
130
- # TODO: Improve error handling and messages
131
- raise error
120
+ presigned_download_url = BiolibJobApi.get_job_storage_download_url(
121
+ job_uuid=self._job_dict['uuid'],
122
+ job_auth_token=self._job_dict['auth_token'],
123
+ storage_type='input',
124
+ )
125
+ response = requests.get(url=presigned_download_url)
126
+ response.raise_for_status()
127
+ module_input_serialized: bytes = response.content
128
+ return ModuleInput(module_input_serialized).deserialize()
132
129
 
133
- try:
134
- module_input = ModuleInput(module_input_serialized).deserialize()
135
- except Exception as error:
136
- # TODO: Improve error handling and messages
137
- raise error
130
+ def get_input_arguments(self) -> List[str]:
131
+ if self._cached_input_arguments is None:
132
+ logger.debug('Fetching input arguments...')
133
+ module_input = self._get_module_input()
134
+ self._cached_input_arguments = module_input['arguments']
135
+
136
+ return self._cached_input_arguments
137
+
138
+ def save_input_files(self, output_dir: str) -> None:
139
+ logger.info('Downloading input files...')
140
+ module_input = self._get_module_input()
138
141
 
139
142
  files = module_input['files'].items()
140
143
  logger.info(f'Saving input {len(files)} files to "{output_dir}"...')
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pybiolib
3
- Version: 1.1.1412
3
+ Version: 1.1.1420
4
4
  Summary: BioLib Python Client
5
5
  Home-page: https://github.com/biolib
6
6
  License: MIT
@@ -21,7 +21,7 @@ biolib/biolib_api_client/user_state.py,sha256=XcgWV-MgVk88mIlMmnu8yHxMu8OCaw8o0t
21
21
  biolib/biolib_binary_format/__init__.py,sha256=HMl5SdX_VUWE4OQzi4Jf_yFvC7b0bSPOGPHYi9dWM2Q,185
22
22
  biolib/biolib_binary_format/base_bbf_package.py,sha256=vxRV4iKy0dXeDOlFWnMFI0hGnDBYDH5Cgh5gAfuObt8,959
23
23
  biolib/biolib_binary_format/file_in_container.py,sha256=sgj0YWPuWhNOiFsVf4X7Sf2AYO4kGCHj4DSUceCifJ0,2753
24
- biolib/biolib_binary_format/module_input.py,sha256=E-mvq26NFpYM7fqMMj8Nrpqxezy4CWRA1OS3hJK1kk0,2603
24
+ biolib/biolib_binary_format/module_input.py,sha256=led2QhHeec_ymBPw5uEn3_3vJKI-1T8zrFQGqwEWLMY,2788
25
25
  biolib/biolib_binary_format/module_output_v2.py,sha256=J5ZO5gCSeudpE12EVDrjYrNTS2DwgszY-SVXT7Qjuyg,5913
26
26
  biolib/biolib_binary_format/remote_endpoints.py,sha256=LgWd_cewZK4ncPR8303GM_PmIEZZJ5RQatJ_NSXUgbU,1306
27
27
  biolib/biolib_binary_format/remote_stream_seeker.py,sha256=uyi6kJBU1C1DWfiuR0kRUQIY7nalG7ocgwgngd3Ul4U,1999
@@ -76,7 +76,7 @@ biolib/experiments/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuF
76
76
  biolib/experiments/experiment.py,sha256=NjJOFktfTbgHNtIDavyQP_uL_-gSGwYHfycybPLJRKU,5939
77
77
  biolib/experiments/types.py,sha256=n9GxdFA7cLMfHvLLqLmZzX31ELeSSkMXFoEEdFsdWGY,171
78
78
  biolib/jobs/__init__.py,sha256=aIb2H2DHjQbM2Bs-dysFijhwFcL58Blp0Co0gimED3w,32
79
- biolib/jobs/job.py,sha256=Rthdl-t8Md8z1NohkHr9E6SYoWNTw1GLakCo0FXeC2M,14708
79
+ biolib/jobs/job.py,sha256=Alshkwmpnv_15zKY2hZ_lFeFV2ShycJO5C3dhZsgKD4,14910
80
80
  biolib/jobs/job_result.py,sha256=8GasUmUXD8SjUYrE2N-HrDx7-AI6TEkFONH8H91t01Q,4913
81
81
  biolib/jobs/types.py,sha256=kn4Vc0fDi6jFVcjpcKH6AYFKXkVA_CaRvtmsJoSyr0c,905
82
82
  biolib/lfs/__init__.py,sha256=wspftSqe_x7xPMZbeW8mcIBuxbHFCiFI3V4TuZU4nZ4,193
@@ -96,8 +96,8 @@ biolib/utils/cache_state.py,sha256=BFrZlV4XZIueIFzAFiPidX4hmwADKY5Y5ZuqlerF5l0,3
96
96
  biolib/utils/multipart_uploader.py,sha256=Bf09MJcIOBwzG8L1i5UeQ2cNcYohxklhhWWAMpnE41I,9671
97
97
  biolib/utils/seq_util.py,sha256=QRLYIPg1yM_LF9bFuM-Ow14gTHoG3rOK6CeGHD705qw,2612
98
98
  biolib/utils/zip/remote_zip.py,sha256=NCdUnVbGCv7SfXCI-yVU-is_OnyWmLAnVpIdSvo-W4k,23500
99
- pybiolib-1.1.1412.dist-info/LICENSE,sha256=F2h7gf8i0agDIeWoBPXDMYScvQOz02pAWkKhTGOHaaw,1067
100
- pybiolib-1.1.1412.dist-info/METADATA,sha256=HmeOYQ7UPCxZbKgdzhaknb4djL7EWPzezWOrk0wVJiE,1492
101
- pybiolib-1.1.1412.dist-info/WHEEL,sha256=d2fvjOD7sXsVzChCqf0Ty0JbHKBaLYwDbGQDwQTnJ50,88
102
- pybiolib-1.1.1412.dist-info/entry_points.txt,sha256=p6DyaP_2kctxegTX23WBznnrDi4mz6gx04O5uKtRDXg,42
103
- pybiolib-1.1.1412.dist-info/RECORD,,
99
+ pybiolib-1.1.1420.dist-info/LICENSE,sha256=F2h7gf8i0agDIeWoBPXDMYScvQOz02pAWkKhTGOHaaw,1067
100
+ pybiolib-1.1.1420.dist-info/METADATA,sha256=gvld8xTOveRhdDjevpxT-qmRc4uDbWSylZjwzMdiC7U,1492
101
+ pybiolib-1.1.1420.dist-info/WHEEL,sha256=d2fvjOD7sXsVzChCqf0Ty0JbHKBaLYwDbGQDwQTnJ50,88
102
+ pybiolib-1.1.1420.dist-info/entry_points.txt,sha256=p6DyaP_2kctxegTX23WBznnrDi4mz6gx04O5uKtRDXg,42
103
+ pybiolib-1.1.1420.dist-info/RECORD,,