pybiolib 1.2.1361__py3-none-any.whl → 1.2.1379__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.

Potentially problematic release.


This version of pybiolib might be problematic. Click here for more details.

biolib/app/app.py CHANGED
@@ -7,6 +7,8 @@ import string
7
7
  from pathlib import Path
8
8
 
9
9
  from biolib import utils
10
+ from biolib._internal.file_utils import path_to_renamed_path
11
+ from biolib._runtime.runtime import Runtime
10
12
  from biolib.api.client import ApiClient
11
13
  from biolib.biolib_api_client import JobState
12
14
  from biolib.biolib_api_client.app_types import App, AppVersion
@@ -20,8 +22,6 @@ from biolib.experiments.experiment import Experiment
20
22
  from biolib.jobs.job import Result
21
23
  from biolib.typing_utils import Dict, Optional
22
24
  from biolib.utils.app_uri import parse_app_uri
23
- from biolib._runtime.runtime import Runtime
24
- from biolib._internal.file_utils import path_to_renamed_path
25
25
 
26
26
 
27
27
  class BioLibApp:
@@ -95,7 +95,7 @@ class BioLibApp:
95
95
  experiment_to_use = experiment if experiment is not None else self._experiment
96
96
  experiment_instance: Optional[Experiment]
97
97
  if experiment_to_use:
98
- experiment_instance = Experiment(experiment_to_use)
98
+ experiment_instance = Experiment(experiment_to_use, _api_client=self._api_client)
99
99
  else:
100
100
  experiment_instance = Experiment.get_experiment_in_context()
101
101
  experiment_id = experiment_instance.uuid if experiment_instance else None
@@ -6,6 +6,7 @@ from biolib import api
6
6
  from biolib._internal.types.experiment import DeprecatedExperimentDict, ExperimentDict
7
7
  from biolib._internal.types.resource import ResourceDetailedDict
8
8
  from biolib._internal.utils import open_browser_window_from_notebook
9
+ from biolib.api.client import ApiClient
9
10
  from biolib.biolib_api_client import BiolibApiClient
10
11
  from biolib.biolib_errors import BioLibError
11
12
  from biolib.jobs.job import Job
@@ -28,7 +29,13 @@ class Experiment:
28
29
  }
29
30
  )
30
31
 
31
- def __init__(self, uri: str, _resource_dict: Optional[ResourceDetailedDict] = None):
32
+ def __init__(
33
+ self,
34
+ uri: str,
35
+ _resource_dict: Optional[ResourceDetailedDict] = None,
36
+ _api_client: Optional[ApiClient] = None,
37
+ ):
38
+ self._api_client = _api_client or api.client
32
39
  self._resource_dict: ResourceDetailedDict = _resource_dict or self._get_or_create_resource_dict(uri)
33
40
 
34
41
  def __enter__(self):
@@ -113,7 +120,7 @@ class Experiment:
113
120
  job_id = job
114
121
  elif job is None and job_id is None:
115
122
  raise BioLibError('A job ID or job object must be provided to add job')
116
- api.client.post(
123
+ self._api_client.post(
117
124
  path=f'/experiments/{self.uuid}/jobs/',
118
125
  data={'job_uuid': job_id},
119
126
  )
@@ -126,7 +133,7 @@ class Experiment:
126
133
  else:
127
134
  raise BioLibError('A job ID or job object must be provided to remove job')
128
135
 
129
- api.client.delete(path=f'/experiments/{self.uuid}/jobs/{job_id}/')
136
+ self._api_client.delete(path=f'/experiments/{self.uuid}/jobs/{job_id}/')
130
137
 
131
138
  def mount_files(self, mount_path: str) -> None:
132
139
  try:
@@ -175,7 +182,7 @@ class Experiment:
175
182
 
176
183
  # Prints a table listing info about the jobs in this experiment
177
184
  def show_jobs(self) -> None:
178
- response: JobsPaginatedResponse = api.client.get(
185
+ response: JobsPaginatedResponse = self._api_client.get(
179
186
  path=f'/experiments/{self.uuid}/jobs/',
180
187
  params=dict(page_size=10),
181
188
  ).json()
@@ -197,11 +204,13 @@ class Experiment:
197
204
  if status:
198
205
  params['status'] = status
199
206
 
200
- response: JobsPaginatedResponse = api.client.get(url, params=params).json()
207
+ response: JobsPaginatedResponse = self._api_client.get(url, params=params).json()
201
208
  jobs: List[Job] = [Job(job_dict) for job_dict in response['results']]
202
209
 
203
210
  for page_number in range(2, response['page_count'] + 1):
204
- page_response: JobsPaginatedResponse = api.client.get(url, params=dict(**params, page=page_number)).json()
211
+ page_response: JobsPaginatedResponse = self._api_client.get(
212
+ url, params=dict(**params, page=page_number)
213
+ ).json()
205
214
  jobs.extend([Job(job_dict) for job_dict in page_response['results']])
206
215
 
207
216
  return jobs
@@ -300,21 +309,19 @@ class Experiment:
300
309
  )
301
310
 
302
311
  def rename(self, destination: str) -> None:
303
- api.client.patch(f'/resources/{self.uuid}/', data={'uri': destination})
312
+ self._api_client.patch(f'/resources/{self.uuid}/', data={'uri': destination})
304
313
  self._refetch()
305
314
 
306
- @staticmethod
307
- def _get_resource_dict_by_uuid(uuid: str) -> ResourceDetailedDict:
308
- resource_dict: ResourceDetailedDict = api.client.get(f'/resources/{uuid}/').json()
315
+ def _get_resource_dict_by_uuid(self, uuid: str) -> ResourceDetailedDict:
316
+ resource_dict: ResourceDetailedDict = self._api_client.get(f'/resources/{uuid}/').json()
309
317
  if not resource_dict['experiment']:
310
318
  raise ValueError('Resource from URI is not an experiment')
311
319
 
312
320
  return resource_dict
313
321
 
314
- @staticmethod
315
- def _get_or_create_resource_dict(uri: str) -> ResourceDetailedDict:
316
- response_dict = api.client.post(path='/experiments/', data={'uri' if '/' in uri else 'name': uri}).json()
317
- return Experiment._get_resource_dict_by_uuid(uuid=response_dict['uuid'])
322
+ def _get_or_create_resource_dict(self, uri: str) -> ResourceDetailedDict:
323
+ response_dict = self._api_client.post(path='/experiments/', data={'uri' if '/' in uri else 'name': uri}).json()
324
+ return self._get_resource_dict_by_uuid(uuid=response_dict['uuid'])
318
325
 
319
326
  def _refetch(self) -> None:
320
327
  self._resource_dict = self._get_resource_dict_by_uuid(uuid=self._resource_dict['uuid'])
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pybiolib
3
- Version: 1.2.1361
3
+ Version: 1.2.1379
4
4
  Summary: BioLib Python Client
5
5
  License: MIT
6
6
  License-File: LICENSE
@@ -70,7 +70,7 @@ biolib/_session/session.py,sha256=Ymi9OQW_u_CfYA3JlBakPwRhNaKlb20P2G8SmtJhnzA,18
70
70
  biolib/api/__init__.py,sha256=mQ4u8FijqyLzjYMezMUUbbBGNB3iFmkNdjXnWPZ7Jlw,138
71
71
  biolib/api/client.py,sha256=2GpKE7QrPgyPdgJgrV7XnZByIJf1n26UCy3aoaHBs1M,7881
72
72
  biolib/app/__init__.py,sha256=cdPtcfb_U-bxb9iSL4fCEq2rpD9OjkyY4W-Zw60B0LI,37
73
- biolib/app/app.py,sha256=FjiqT7jCH0pSzKpG_v2Z9ysdUaPhhdPmW5gC-IbnAl0,12230
73
+ biolib/app/app.py,sha256=8k7M8G3HO1TPfBTZrE_iODKX28rxxf-7g-OsUa3x-fY,12260
74
74
  biolib/app/search_apps.py,sha256=K4a41f5XIWth2BWI7OffASgIsD0ko8elCax8YL2igaY,1470
75
75
  biolib/biolib_api_client/__init__.py,sha256=E5EMa19wJoblwSdQPYrxc_BtIeRsAuO0L_jQweWw-Yk,182
76
76
  biolib/biolib_api_client/api_client.py,sha256=IONzXeFCHl4wuct6fqOC_7NiTv_zFy6ys0hsAtvLzTA,7578
@@ -143,7 +143,7 @@ biolib/compute_node/webserver/webserver_types.py,sha256=2t8EaFKESnves3BA_NBdnS2y
143
143
  biolib/compute_node/webserver/webserver_utils.py,sha256=XWvwYPbWNR3qS0FYbLLp-MDDfVk0QdaAmg3xPrT0H2s,4234
144
144
  biolib/compute_node/webserver/worker_thread.py,sha256=7uD9yQPhePYvP2HCJ27EeZ_h6psfIWFgqm1RHZxzobs,12483
145
145
  biolib/experiments/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
146
- biolib/experiments/experiment.py,sha256=4g1xMYmfp5yzSOdwjf3pUUULF9QjqBJb4uQ25FHrFrk,13688
146
+ biolib/experiments/experiment.py,sha256=ePipnJs6TW84jr9iBfYYRpYuEXUVGIxaD8Z8Jf0FYIA,13909
147
147
  biolib/jobs/__init__.py,sha256=aIb2H2DHjQbM2Bs-dysFijhwFcL58Blp0Co0gimED3w,32
148
148
  biolib/jobs/job.py,sha256=X7F_jCwAwtPcI1qu-oLamZNzt1IVSIeOPWlax1ztfAM,29674
149
149
  biolib/jobs/job_result.py,sha256=_xqQu9z9BqPQrU6tjqKPuKlQDt5W0Zw5xiQvzEBkDyE,5266
@@ -161,8 +161,8 @@ biolib/utils/cache_state.py,sha256=u256F37QSRIVwqKlbnCyzAX4EMI-kl6Dwu6qwj-Qmag,3
161
161
  biolib/utils/multipart_uploader.py,sha256=XvGP1I8tQuKhAH-QugPRoEsCi9qvbRk-DVBs5PNwwJo,8452
162
162
  biolib/utils/seq_util.py,sha256=rImaghQGuIqTVWks6b9P2yKuN34uePUYPUFW_Wyoa4A,6737
163
163
  biolib/utils/zip/remote_zip.py,sha256=0wErYlxir5921agfFeV1xVjf29l9VNgGQvNlWOlj2Yc,23232
164
- pybiolib-1.2.1361.dist-info/METADATA,sha256=Mc0J-5SkgNFy4G4hYW2XaekpJp1qODDRm2TB6LlMaww,1644
165
- pybiolib-1.2.1361.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
166
- pybiolib-1.2.1361.dist-info/entry_points.txt,sha256=p6DyaP_2kctxegTX23WBznnrDi4mz6gx04O5uKtRDXg,42
167
- pybiolib-1.2.1361.dist-info/licenses/LICENSE,sha256=F2h7gf8i0agDIeWoBPXDMYScvQOz02pAWkKhTGOHaaw,1067
168
- pybiolib-1.2.1361.dist-info/RECORD,,
164
+ pybiolib-1.2.1379.dist-info/METADATA,sha256=K_Bnjzo9XB9Aq5g63v7A6CEKrEc1YC5jh6u0gYMGqCA,1644
165
+ pybiolib-1.2.1379.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
166
+ pybiolib-1.2.1379.dist-info/entry_points.txt,sha256=p6DyaP_2kctxegTX23WBznnrDi4mz6gx04O5uKtRDXg,42
167
+ pybiolib-1.2.1379.dist-info/licenses/LICENSE,sha256=F2h7gf8i0agDIeWoBPXDMYScvQOz02pAWkKhTGOHaaw,1067
168
+ pybiolib-1.2.1379.dist-info/RECORD,,