pybiolib 1.2.1242__py3-none-any.whl → 1.2.1293__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/__init__.py CHANGED
@@ -1,3 +1,4 @@
1
+ # ruff: noqa: I001
1
2
  # Imports to hide
2
3
  import os
3
4
  from urllib.parse import urlparse as _urlparse
@@ -15,6 +16,7 @@ from biolib.jobs.job import Result as _Result
15
16
  from biolib import user as _user
16
17
  from biolib.typing_utils import List, Optional, cast as _cast
17
18
  from biolib._data_record.data_record import DataRecord as _DataRecord
19
+ from biolib._internal.utils.job_url import parse_result_id_or_url as _parse_result_id_or_url
18
20
 
19
21
  import biolib.api
20
22
  import biolib.app
@@ -22,7 +24,6 @@ import biolib.cli
22
24
  import biolib.sdk
23
25
  import biolib.utils
24
26
 
25
-
26
27
  # ------------------------------------ Function definitions for public Python API ------------------------------------
27
28
 
28
29
 
@@ -83,43 +84,65 @@ def search(
83
84
 
84
85
 
85
86
  def get_job(job_id: str, job_token: Optional[str] = None) -> _Result:
86
- r"""Get a job by its ID.
87
+ r"""Get a job by its ID or full URL.
87
88
 
88
89
  Args:
89
- job_id (str): The UUID of the job to retrieve
90
+ job_id (str): The UUID of the job to retrieve, or a full URL to the job.
91
+ Can be either:
92
+ - Job UUID (e.g., 'abc123')
93
+ - Full URL (e.g., 'https://biolib.com/result/abc123/?token=xyz789')
94
+ - Full URL with token parameter (e.g., 'biolib.com/result/abc123/token=xyz789')
90
95
  job_token (str, optional): Authentication token for accessing the job.
91
96
  Only needed for jobs that aren't owned by the current user.
97
+ If the URL contains a token, this parameter is ignored.
92
98
 
93
99
  Returns:
94
100
  Job: The job object
95
101
 
96
102
  Example::
97
103
 
104
+ >>> # Get by UUID
98
105
  >>> job = biolib.get_job('abc123')
99
- >>> # Access shared job
106
+ >>> # Get with explicit token
100
107
  >>> job = biolib.get_job('abc123', job_token='xyz789')
108
+ >>> # Get by full URL with token
109
+ >>> job = biolib.get_job('https://biolib.com/result/abc123/?token=xyz789')
110
+ >>> # Get by URL with inline token format
111
+ >>> job = biolib.get_job('biolib.com/result/abc123/token=xyz789')
101
112
  """
102
- return _Result.create_from_uuid(uuid=job_id, auth_token=job_token)
113
+ uuid, token = _parse_result_id_or_url(job_id, job_token)
114
+ return _Result.create_from_uuid(uuid=uuid, auth_token=token)
103
115
 
104
116
 
105
117
  def get_result(result_id: str, result_token: Optional[str] = None) -> _Result:
106
- r"""Get a result by its ID.
118
+ r"""Get a result by its ID or full URL.
107
119
 
108
120
  Args:
109
- result_id (str): The UUID of the result to retrieve
121
+ result_id (str): The UUID of the result to retrieve, or a full URL to the result.
122
+ Can be either:
123
+ - Result UUID (e.g., 'abc123')
124
+ - Full URL (e.g., 'https://biolib.com/result/abc123/?token=xyz789')
125
+ - Full URL with token parameter (e.g., 'biolib.com/result/abc123/token=xyz789')
110
126
  result_token (str, optional): Authentication token for accessing the result.
111
- Only needed for result that aren't owned by the current user.
127
+ Only needed for results that aren't owned by the current user.
128
+ If the URL contains a token, this parameter is ignored.
112
129
 
113
130
  Returns:
114
131
  Result: The result object
115
132
 
116
133
  Example::
117
134
 
135
+ >>> # Get by UUID
118
136
  >>> result = biolib.get_result('abc123')
119
- >>> # Access shared result
137
+ >>> # Get with explicit token
120
138
  >>> result = biolib.get_result('abc123', result_token='xyz789')
139
+ >>> # Get by full URL with token
140
+ >>> result = biolib.get_result('https://biolib.com/result/abc123/?token=xyz789')
141
+ >>> # Get by URL with inline token format
142
+ >>> result = biolib.get_result('biolib.com/result/abc123/token=xyz789')
121
143
  """
122
- return _Result.create_from_uuid(uuid=result_id, auth_token=result_token)
144
+ uuid, token = _parse_result_id_or_url(result_id, result_token)
145
+ return _Result.create_from_uuid(uuid=uuid, auth_token=token)
123
146
 
124
147
 
125
148
  def get_data_record(uri: str) -> _DataRecord:
@@ -1,3 +1,5 @@
1
+ # syntax=docker/dockerfile:1
2
+
1
3
  FROM node:24.4.1-alpine3.21 AS gui_builder
2
4
 
3
5
  WORKDIR /home/biolib/
@@ -1,3 +1,5 @@
1
+ # syntax=docker/dockerfile:1
2
+
1
3
  FROM python:3.13.3-slim
2
4
  WORKDIR /home/biolib/
3
5
 
@@ -0,0 +1,33 @@
1
+ import re
2
+ from urllib.parse import urlparse
3
+
4
+ import biolib.utils
5
+ from biolib.typing_utils import Optional, Tuple
6
+
7
+
8
+ def parse_result_id_or_url(result_id_or_url: str, default_token: Optional[str] = None) -> Tuple[str, Optional[str]]:
9
+ result_id_or_url = result_id_or_url.strip()
10
+
11
+ if '/' not in result_id_or_url:
12
+ return (result_id_or_url, default_token)
13
+
14
+ if not result_id_or_url.startswith('http://') and not result_id_or_url.startswith('https://'):
15
+ result_id_or_url = 'https://' + result_id_or_url
16
+
17
+ parsed_url = urlparse(result_id_or_url)
18
+
19
+ if biolib.utils.BIOLIB_BASE_URL:
20
+ expected_base = urlparse(biolib.utils.BIOLIB_BASE_URL)
21
+ if parsed_url.scheme != expected_base.scheme or parsed_url.netloc != expected_base.netloc:
22
+ raise ValueError(f'URL must start with {biolib.utils.BIOLIB_BASE_URL}, got: {result_id_or_url}')
23
+
24
+ pattern = r'/results?/(?P<uuid>[a-f0-9-]+)/?(?:\?token=(?P<token>[^&]+))?'
25
+ match = re.search(pattern, result_id_or_url, re.IGNORECASE)
26
+
27
+ if not match:
28
+ raise ValueError(f'URL must be in format <base_url>/results/<UUID>/?token=<token>, got: {result_id_or_url}')
29
+
30
+ uuid = match.group('uuid')
31
+ token = match.group('token') or default_token
32
+
33
+ return (uuid, token)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pybiolib
3
- Version: 1.2.1242
3
+ Version: 1.2.1293
4
4
  Summary: BioLib Python Client
5
5
  License: MIT
6
6
  License-File: LICENSE
@@ -1,4 +1,4 @@
1
- biolib/__init__.py,sha256=o0cpNzP7OwPYfdw5Cq-XgsMYooQdQynZTUO3W-LFuKo,10657
1
+ biolib/__init__.py,sha256=-pz1Ipyj1KmB709yYpl2Y-iKOWXpLxcFzL48G8rr9cU,12146
2
2
  biolib/_data_record/data_record.py,sha256=BM2WEBnn13reSiAqhBtcV8FLewFWSTcMmFV0bD74bM0,12489
3
3
  biolib/_internal/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
4
  biolib/_internal/add_copilot_prompts.py,sha256=wcIdrceFcfKSoEjvM4uNzhKZ0I1-MCFkfNO4duqtGHA,1861
@@ -29,7 +29,7 @@ biolib/_internal/templates/copilot_template/.github/prompts/biolib_onboard_repo.
29
29
  biolib/_internal/templates/copilot_template/.github/prompts/biolib_run_apps.prompt.md,sha256=-t1bmGr3zEFa6lKHaLcI98yq4Sg1TCMW8xbelNSHaOA,696
30
30
  biolib/_internal/templates/gui_template/.yarnrc.yml,sha256=Rz5t74b8A2OBIODAHQyLurCVZ3JWRg-k6nY-XUaX8nA,25
31
31
  biolib/_internal/templates/gui_template/App.tsx,sha256=hh_r7P4Pn4HLaE8C1PoECawd81yoC4MfWPu7Op02kWg,509
32
- biolib/_internal/templates/gui_template/Dockerfile,sha256=C_2vCYPu8JtJRhwviwwI7jq8767G7nGE8naYvNzej4E,449
32
+ biolib/_internal/templates/gui_template/Dockerfile,sha256=nGZQiL7coQBUnH1E2abK2PJ4XRjVS1QXn6HDX9UGpcE,479
33
33
  biolib/_internal/templates/gui_template/index.css,sha256=WYds1xQY2of84ebHhRW9ummbw0Bg9N-EyfmBzJKigck,70
34
34
  biolib/_internal/templates/gui_template/index.html,sha256=EM5xzJ9CsJalgzL-jLNkAoP4tgosw0WYExcH5W6DOs8,403
35
35
  biolib/_internal/templates/gui_template/index.tsx,sha256=YrdrpcckwLo0kYIA-2egtzlo0OMWigGxnt7mNN4qmlU,234
@@ -39,7 +39,7 @@ biolib/_internal/templates/gui_template/vite.config.mts,sha256=Bf1bgRReU3XFsR6rX
39
39
  biolib/_internal/templates/init_template/.biolib/config.yml,sha256=gxMVd1wjbsDvMv4byc8fKEdJFby4qgi6v38mO5qmhoY,453
40
40
  biolib/_internal/templates/init_template/.github/workflows/biolib.yml,sha256=sphjoiycV_oc4VbaA8wbUEokSMpnrdB6N-bYju_5Ibo,522
41
41
  biolib/_internal/templates/init_template/.gitignore,sha256=dR_jhtT0boUspgk3S5PPUwuO0o8gKGIbdwu8IH638CY,20
42
- biolib/_internal/templates/init_template/Dockerfile,sha256=Wv2r9aiazkL1wOf_BT1f5Kx_-txfrqSkYTtWI8HGdL8,169
42
+ biolib/_internal/templates/init_template/Dockerfile,sha256=Cx3ktDxcpgAWAacIewm7mcI7lNEsmgAETvFtN7NA3Ms,199
43
43
  biolib/_internal/templates/init_template/requirements.txt,sha256=2GnBHsKg4tX5F06Z4YeLuId6jQO3-HGTITsaVBTDG0Y,42
44
44
  biolib/_internal/templates/init_template/run.py,sha256=oat-Vzcz4XZilrTtgy8CzfltBAa5v6iduGof4Tuulhg,402
45
45
  biolib/_internal/templates/init_template/run.sh,sha256=ncvInHCn_PgjXmvaa5oBU0vC3dgFJQ6k7fUJKJzpOh4,69
@@ -60,6 +60,7 @@ biolib/_internal/types/result.py,sha256=MesSTBXCkaw8HydXgHf1OKGVLzsxhZ1KV5z4w-VI
60
60
  biolib/_internal/types/typing.py,sha256=qrsk8hHcGEbDpU1QQFzHAKnhQxkMe7uJ6pxHeAnfv1Y,414
61
61
  biolib/_internal/types/user.py,sha256=5_hYG0jrdGxynCCWXGaHZCAlVcRKBqMIEA2EBGrnpiE,439
62
62
  biolib/_internal/utils/__init__.py,sha256=xp1I-lVnu5owV1CW53jiPEZLKmqqHiPUDfauYDfJ7iQ,1540
63
+ biolib/_internal/utils/job_url.py,sha256=YpwqCP56BD15M8p2tuSY_Z3O9vWAkG2rJbQu2Z5zqq0,1265
63
64
  biolib/_internal/utils/multinode.py,sha256=N7kR49xD1PdkMVlxxzRiSYHfgi9MG-kLCwemcY1rojg,8323
64
65
  biolib/_runtime/runtime.py,sha256=9q6Wuo8SBcJIezyScAgq2MDfpT0Pg8lcfbBFmeCWiUE,5974
65
66
  biolib/_session/session.py,sha256=US1Y1jfFIAm86-Lq3C7nCXpZXUJXXBVBkND9djMNYxI,1649
@@ -157,8 +158,8 @@ biolib/utils/cache_state.py,sha256=u256F37QSRIVwqKlbnCyzAX4EMI-kl6Dwu6qwj-Qmag,3
157
158
  biolib/utils/multipart_uploader.py,sha256=XvGP1I8tQuKhAH-QugPRoEsCi9qvbRk-DVBs5PNwwJo,8452
158
159
  biolib/utils/seq_util.py,sha256=rImaghQGuIqTVWks6b9P2yKuN34uePUYPUFW_Wyoa4A,6737
159
160
  biolib/utils/zip/remote_zip.py,sha256=0wErYlxir5921agfFeV1xVjf29l9VNgGQvNlWOlj2Yc,23232
160
- pybiolib-1.2.1242.dist-info/METADATA,sha256=YDfYYUmotb0VAZWDAOq_kGDqEUIjyWJ9jeg4cKmLsNM,1644
161
- pybiolib-1.2.1242.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
162
- pybiolib-1.2.1242.dist-info/entry_points.txt,sha256=p6DyaP_2kctxegTX23WBznnrDi4mz6gx04O5uKtRDXg,42
163
- pybiolib-1.2.1242.dist-info/licenses/LICENSE,sha256=F2h7gf8i0agDIeWoBPXDMYScvQOz02pAWkKhTGOHaaw,1067
164
- pybiolib-1.2.1242.dist-info/RECORD,,
161
+ pybiolib-1.2.1293.dist-info/METADATA,sha256=VCKdgECpZTpBbM1RLQOkLM98ctNHM7mw4yxPUXanRnc,1644
162
+ pybiolib-1.2.1293.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
163
+ pybiolib-1.2.1293.dist-info/entry_points.txt,sha256=p6DyaP_2kctxegTX23WBznnrDi4mz6gx04O5uKtRDXg,42
164
+ pybiolib-1.2.1293.dist-info/licenses/LICENSE,sha256=F2h7gf8i0agDIeWoBPXDMYScvQOz02pAWkKhTGOHaaw,1067
165
+ pybiolib-1.2.1293.dist-info/RECORD,,