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

@@ -5,17 +5,19 @@ from biolib.app import BioLibApp
5
5
 
6
6
 
7
7
  class Session:
8
- def __init__(self, _init_dict: ApiClientInitDict) -> None:
8
+ def __init__(self, _init_dict: ApiClientInitDict, _experiment: Optional[str] = None) -> None:
9
9
  self._api = ApiClient(_init_dict=_init_dict)
10
+ self._experiment = _experiment
10
11
 
11
12
  @staticmethod
12
- def get_session(refresh_token: str, base_url: Optional[str] = None, client_type: Optional[str] = None) -> 'Session':
13
+ def get_session(refresh_token: str, base_url: Optional[str] = None, client_type: Optional[str] = None, experiment: Optional[str] = None) -> 'Session':
13
14
  return Session(
14
15
  _init_dict=ApiClientInitDict(
15
16
  refresh_token=refresh_token,
16
17
  base_url=base_url or utils.load_base_url_from_env(),
17
18
  client_type=client_type,
18
- )
19
+ ),
20
+ _experiment=experiment,
19
21
  )
20
22
 
21
23
  def load(self, uri: str, suppress_version_warning: bool = False) -> BioLibApp:
@@ -39,4 +41,4 @@ class Session:
39
41
  >>> app = biolib.load('https://biolib.com/biolib/myapp/')
40
42
  >>> result = app.cli('--help')
41
43
  """
42
- return BioLibApp(uri=uri, _api_client=self._api, suppress_version_warning=suppress_version_warning)
44
+ return BioLibApp(uri=uri, _api_client=self._api, suppress_version_warning=suppress_version_warning, _experiment=self._experiment)
biolib/app/app.py CHANGED
@@ -25,8 +25,15 @@ from biolib._internal.file_utils import path_to_renamed_path
25
25
 
26
26
 
27
27
  class BioLibApp:
28
- def __init__(self, uri: str, _api_client: Optional[ApiClient] = None, suppress_version_warning: bool = False):
28
+ def __init__(
29
+ self,
30
+ uri: str,
31
+ _api_client: Optional[ApiClient] = None,
32
+ suppress_version_warning: bool = False,
33
+ _experiment: Optional[str] = None,
34
+ ):
29
35
  self._api_client: Optional[ApiClient] = _api_client
36
+ self._experiment = _experiment
30
37
 
31
38
  app_response = BiolibAppApi.get_by_uri(uri=uri, api_client=self._api_client)
32
39
  self._app: App = app_response['app']
@@ -85,7 +92,12 @@ class BioLibApp:
85
92
  raise ValueError('The argument "check" cannot be True when blocking is False')
86
93
 
87
94
  if not experiment_id:
88
- experiment_instance = Experiment(experiment) if experiment else Experiment.get_experiment_in_context()
95
+ experiment_to_use = experiment if experiment is not None else self._experiment
96
+ experiment_instance: Optional[Experiment]
97
+ if experiment_to_use:
98
+ experiment_instance = Experiment(experiment_to_use)
99
+ else:
100
+ experiment_instance = Experiment.get_experiment_in_context()
89
101
  experiment_id = experiment_instance.uuid if experiment_instance else None
90
102
 
91
103
  module_input_serialized = self._get_serialized_module_input(args, stdin, files)
biolib/jobs/job.py CHANGED
@@ -498,11 +498,17 @@ class Result:
498
498
  stdout_and_stderr_package = base64.b64decode(stdout_and_stderr_package_b64)
499
499
  stdout_and_stderr = StdoutAndStderr(stdout_and_stderr_package).deserialize()
500
500
 
501
- sys.stdout.buffer.write(stdout_and_stderr)
502
- if not IS_RUNNING_IN_NOTEBOOK: # for some reason flushing in jupyter notebooks breaks \r handling
501
+ if IS_RUNNING_IN_NOTEBOOK:
502
+ sys.stdout.write(stdout_and_stderr.decode(encoding='utf-8', errors='replace'))
503
+ else:
504
+ sys.stdout.buffer.write(stdout_and_stderr)
505
+ # Note: we avoid flush() in notebook as that breaks \r handling
503
506
  sys.stdout.buffer.flush()
504
507
  # flush after having processed all packages
505
- sys.stdout.buffer.flush()
508
+ if IS_RUNNING_IN_NOTEBOOK:
509
+ sys.stdout.flush()
510
+ else:
511
+ sys.stdout.buffer.flush()
506
512
 
507
513
  def show(self) -> None:
508
514
  self._refetch_job_dict()
@@ -522,11 +528,19 @@ class Result:
522
528
  logger.info(f'--- The result {self.id} has already completed (no streaming will take place) ---')
523
529
  logger.info('--- The stdout log is printed below: ---')
524
530
  sys.stdout.flush()
525
- sys.stdout.buffer.write(self.get_stdout())
526
- sys.stdout.buffer.flush()
531
+ if IS_RUNNING_IN_NOTEBOOK:
532
+ sys.stdout.write(self.get_stdout().decode(encoding='utf-8', errors='replace'))
533
+ sys.stdout.flush()
534
+ else:
535
+ sys.stdout.buffer.write(self.get_stdout())
536
+ sys.stdout.buffer.flush()
527
537
  logger.info('--- The stderr log is printed below: ---')
528
- sys.stderr.buffer.write(self.get_stderr())
529
- sys.stderr.buffer.flush()
538
+ if IS_RUNNING_IN_NOTEBOOK:
539
+ sys.stderr.write(self.get_stderr().decode(encoding='utf-8', errors='replace'))
540
+ sys.stderr.flush()
541
+ else:
542
+ sys.stderr.buffer.write(self.get_stderr())
543
+ sys.stderr.buffer.flush()
530
544
  logger.info(f'--- The job {self.id} has already completed. Its output was printed above. ---')
531
545
  return
532
546
 
biolib/sdk/__init__.py CHANGED
@@ -12,8 +12,18 @@ from biolib.app import BioLibApp as _BioLibApp
12
12
  Runtime = _Runtime
13
13
 
14
14
 
15
- def get_session(refresh_token: str, base_url: Optional[str] = None, client_type: Optional[str] = None) -> _Session:
16
- return _Session.get_session(refresh_token=refresh_token, base_url=base_url, client_type=client_type)
15
+ def get_session(
16
+ refresh_token: str,
17
+ base_url: Optional[str] = None,
18
+ client_type: Optional[str] = None,
19
+ experiment: Optional[str] = None,
20
+ ) -> _Session:
21
+ return _Session.get_session(
22
+ refresh_token=refresh_token,
23
+ base_url=base_url,
24
+ client_type=client_type,
25
+ experiment=experiment,
26
+ )
17
27
 
18
28
 
19
29
  def push_app_version(uri: str, path: str) -> _BioLibApp:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pybiolib
3
- Version: 1.2.1310
3
+ Version: 1.2.1337
4
4
  Summary: BioLib Python Client
5
5
  License: MIT
6
6
  License-File: LICENSE
@@ -63,11 +63,11 @@ biolib/_internal/utils/__init__.py,sha256=xp1I-lVnu5owV1CW53jiPEZLKmqqHiPUDfauYD
63
63
  biolib/_internal/utils/job_url.py,sha256=YpwqCP56BD15M8p2tuSY_Z3O9vWAkG2rJbQu2Z5zqq0,1265
64
64
  biolib/_internal/utils/multinode.py,sha256=N7kR49xD1PdkMVlxxzRiSYHfgi9MG-kLCwemcY1rojg,8323
65
65
  biolib/_runtime/runtime.py,sha256=9q6Wuo8SBcJIezyScAgq2MDfpT0Pg8lcfbBFmeCWiUE,5974
66
- biolib/_session/session.py,sha256=US1Y1jfFIAm86-Lq3C7nCXpZXUJXXBVBkND9djMNYxI,1649
66
+ biolib/_session/session.py,sha256=Ymi9OQW_u_CfYA3JlBakPwRhNaKlb20P2G8SmtJhnzA,1824
67
67
  biolib/api/__init__.py,sha256=mQ4u8FijqyLzjYMezMUUbbBGNB3iFmkNdjXnWPZ7Jlw,138
68
68
  biolib/api/client.py,sha256=2GpKE7QrPgyPdgJgrV7XnZByIJf1n26UCy3aoaHBs1M,7881
69
69
  biolib/app/__init__.py,sha256=cdPtcfb_U-bxb9iSL4fCEq2rpD9OjkyY4W-Zw60B0LI,37
70
- biolib/app/app.py,sha256=Jc2PwNsZDKca9NxvasI_yrnb0q_S9PrJ94lva-y2Zpc,11882
70
+ biolib/app/app.py,sha256=FjiqT7jCH0pSzKpG_v2Z9ysdUaPhhdPmW5gC-IbnAl0,12230
71
71
  biolib/app/search_apps.py,sha256=K4a41f5XIWth2BWI7OffASgIsD0ko8elCax8YL2igaY,1470
72
72
  biolib/biolib_api_client/__init__.py,sha256=E5EMa19wJoblwSdQPYrxc_BtIeRsAuO0L_jQweWw-Yk,182
73
73
  biolib/biolib_api_client/api_client.py,sha256=IONzXeFCHl4wuct6fqOC_7NiTv_zFy6ys0hsAtvLzTA,7578
@@ -142,12 +142,12 @@ biolib/compute_node/webserver/worker_thread.py,sha256=7uD9yQPhePYvP2HCJ27EeZ_h6p
142
142
  biolib/experiments/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
143
143
  biolib/experiments/experiment.py,sha256=4g1xMYmfp5yzSOdwjf3pUUULF9QjqBJb4uQ25FHrFrk,13688
144
144
  biolib/jobs/__init__.py,sha256=aIb2H2DHjQbM2Bs-dysFijhwFcL58Blp0Co0gimED3w,32
145
- biolib/jobs/job.py,sha256=-yF9JnHH0CEJIqp3qV9Dsv8AwBi_H1alqcKwhh3AORI,29075
145
+ biolib/jobs/job.py,sha256=X7F_jCwAwtPcI1qu-oLamZNzt1IVSIeOPWlax1ztfAM,29674
146
146
  biolib/jobs/job_result.py,sha256=_xqQu9z9BqPQrU6tjqKPuKlQDt5W0Zw5xiQvzEBkDyE,5266
147
147
  biolib/jobs/types.py,sha256=rFs6bQWsNI-nb1Hu9QzOW2zFZ8bOVt7ax4UpGVASxVA,1034
148
148
  biolib/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
149
149
  biolib/runtime/__init__.py,sha256=MlRepA11n2H-3plB5rzWyyHK2JmP6PiaP3i6x3vt0mg,506
150
- biolib/sdk/__init__.py,sha256=Z1S5BgpvM87S2o1libtqkYN1CfYUhn_d4ChEJjwdFKM,2356
150
+ biolib/sdk/__init__.py,sha256=TATbgncVHIzxo_U1zpD1YrdngIIvJkT3S0o2qe3dcg4,2471
151
151
  biolib/tables.py,sha256=MmruV-nJLc3HbLVJBAiDuDCgS2-4oaUkpoCLLUNYbxQ,1173
152
152
  biolib/typing_utils.py,sha256=ntzrlyTkUaO2OtccLYzCAGztGdca0WT5fikJUmSkT-Y,148
153
153
  biolib/user/__init__.py,sha256=Db5wtxLfFz3ID9TULSSTo77csw9tO6RtxMRvV5cqKEE,39
@@ -158,8 +158,8 @@ biolib/utils/cache_state.py,sha256=u256F37QSRIVwqKlbnCyzAX4EMI-kl6Dwu6qwj-Qmag,3
158
158
  biolib/utils/multipart_uploader.py,sha256=XvGP1I8tQuKhAH-QugPRoEsCi9qvbRk-DVBs5PNwwJo,8452
159
159
  biolib/utils/seq_util.py,sha256=rImaghQGuIqTVWks6b9P2yKuN34uePUYPUFW_Wyoa4A,6737
160
160
  biolib/utils/zip/remote_zip.py,sha256=0wErYlxir5921agfFeV1xVjf29l9VNgGQvNlWOlj2Yc,23232
161
- pybiolib-1.2.1310.dist-info/METADATA,sha256=LNNxEg6rvoh17x8AIKHxVEHRW5CsI2k_Ybi3VrT_o6o,1644
162
- pybiolib-1.2.1310.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
163
- pybiolib-1.2.1310.dist-info/entry_points.txt,sha256=p6DyaP_2kctxegTX23WBznnrDi4mz6gx04O5uKtRDXg,42
164
- pybiolib-1.2.1310.dist-info/licenses/LICENSE,sha256=F2h7gf8i0agDIeWoBPXDMYScvQOz02pAWkKhTGOHaaw,1067
165
- pybiolib-1.2.1310.dist-info/RECORD,,
161
+ pybiolib-1.2.1337.dist-info/METADATA,sha256=rH78s_I8v02Htgz31ys8-Ap2-E8JBXQD3rfcF86_KsA,1644
162
+ pybiolib-1.2.1337.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
163
+ pybiolib-1.2.1337.dist-info/entry_points.txt,sha256=p6DyaP_2kctxegTX23WBznnrDi4mz6gx04O5uKtRDXg,42
164
+ pybiolib-1.2.1337.dist-info/licenses/LICENSE,sha256=F2h7gf8i0agDIeWoBPXDMYScvQOz02pAWkKhTGOHaaw,1067
165
+ pybiolib-1.2.1337.dist-info/RECORD,,