datalab-api 0.2.8__tar.gz → 0.2.10__tar.gz

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,7 +1,7 @@
1
- Metadata-Version: 2.2
1
+ Metadata-Version: 2.4
2
2
  Name: datalab-api
3
- Version: 0.2.8
4
- Summary: A Python API for instances of the datalab data management platform (https://github.com/the-grey-group/datalab).
3
+ Version: 0.2.10
4
+ Summary: A Python API for instances of the datalab data management platform (https://github.com/datalab-org/datalab).
5
5
  Author-email: Matthew Evans <matthew@ml-evs.science>
6
6
  License: MIT
7
7
  Project-URL: homepage, https://github.com/datalab-org/datalab-api
@@ -10,7 +10,6 @@ Project-URL: documentation, https://datalab-python-api.readthedocs.io
10
10
  Project-URL: changelog, https://github.com/datalab-org/datalab-api/releases
11
11
  Classifier: Programming Language :: Python :: 3
12
12
  Classifier: Programming Language :: Python :: 3.9
13
- Classifier: Programming Language :: Python :: 3
14
13
  Classifier: Programming Language :: Python :: 3.10
15
14
  Classifier: Programming Language :: Python :: 3.11
16
15
  Classifier: Programming Language :: Python :: 3.12
@@ -22,7 +21,7 @@ Requires-Python: >=3.9
22
21
  Description-Content-Type: text/markdown
23
22
  License-File: LICENSE
24
23
  Requires-Dist: httpx~=0.27
25
- Requires-Dist: bokeh~=2.4
24
+ Requires-Dist: bokeh~=2.4; platform_system != "Emscripten"
26
25
  Requires-Dist: rich~=13.0
27
26
  Requires-Dist: numpy<2
28
27
  Provides-Extra: dev
@@ -44,6 +43,7 @@ Requires-Dist: pandas~=2.2; extra == "cheminventory-helper"
44
43
  Requires-Dist: openpyxl~=3.0; extra == "cheminventory-helper"
45
44
  Provides-Extra: all
46
45
  Requires-Dist: datalab-api[cli,dev,docs]; extra == "all"
46
+ Dynamic: license-file
47
47
 
48
48
  # <div align="center"><i>datalab</i> Python API</div>
49
49
 
@@ -5,14 +5,15 @@ build-backend = "setuptools.build_meta"
5
5
  [project]
6
6
  name = "datalab-api"
7
7
  readme = "README.md"
8
- description = "A Python API for instances of the datalab data management platform (https://github.com/the-grey-group/datalab)."
8
+ description = "A Python API for instances of the datalab data management platform (https://github.com/datalab-org/datalab)."
9
9
  keywords = []
10
10
  license = { text = "MIT" }
11
11
  authors = [{ name = "Matthew Evans", email = "matthew@ml-evs.science" }]
12
12
  dynamic = ["version"]
13
13
  classifiers = [
14
- "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.9",
15
- "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.10",
14
+ "Programming Language :: Python :: 3",
15
+ "Programming Language :: Python :: 3.9",
16
+ "Programming Language :: Python :: 3.10",
16
17
  "Programming Language :: Python :: 3.11",
17
18
  "Programming Language :: Python :: 3.12",
18
19
  "Intended Audience :: Science/Research",
@@ -22,11 +23,11 @@ classifiers = [
22
23
  ]
23
24
 
24
25
  requires-python = ">=3.9"
25
- dependencies =[
26
- "httpx ~= 0.27", # better HTTP requests
27
- "bokeh ~= 2.4", # interactive plots from datalab directly
28
- "rich ~= 13.0", # nicer terminal output
29
- "numpy < 2", # upper pin for numpy due to bad pins in bokeh
26
+ dependencies = [
27
+ "httpx ~= 0.27", # better HTTP requests
28
+ 'bokeh ~= 2.4; platform_system != "Emscripten"', # interactive plots from datalab directly
29
+ "rich ~= 13.0", # nicer terminal output
30
+ "numpy < 2", # upper pin for numpy due to bad pins in bokeh
30
31
  ]
31
32
 
32
33
 
@@ -47,18 +48,13 @@ docs = [
47
48
  ]
48
49
 
49
50
  cli = [
50
- "typer ~= 0.9", # command line interface
51
+ "typer ~= 0.9", # command line interface
51
52
  "click-shell ~= 2.1", # REPL-like interface
52
53
  ]
53
54
 
54
- cheminventory-helper = [
55
- "pandas ~= 2.2",
56
- "openpyxl ~= 3.0"
57
- ]
55
+ cheminventory-helper = ["pandas ~= 2.2", "openpyxl ~= 3.0"]
58
56
 
59
- all = [
60
- "datalab-api[dev,docs,cli]"
61
- ]
57
+ all = ["datalab-api[dev,docs,cli]"]
62
58
 
63
59
  [project.scripts]
64
60
  datalab = "datalab_api.cli:app"
@@ -130,7 +126,6 @@ ignore = [
130
126
  "PLW0603",
131
127
  "PLW2901",
132
128
  "PT003",
133
- "PT004", # pytest-missing-fixture-name-underscore
134
129
  "PT006", # pytest-parametrize-names-wrong-type
135
130
  "PT013", # pytest-incorrect-pytest-import
136
131
  "PTH", # prefer Pathlib to os.path
@@ -165,7 +160,7 @@ ignore = [
165
160
  pydocstyle.convention = "numpy"
166
161
  isort.known-first-party = ["jobflow_remote"]
167
162
  isort.split-on-trailing-comma = false
168
- fixable = ["A", "B", "C", "D", "E", "F", "I"]
163
+ fixable = ["A", "B", "C", "D", "E", "F", "I", "PT", "RUF"]
169
164
  unfixable = []
170
165
  # Allow unused variables when underscore-prefixed.
171
166
  dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"
@@ -7,7 +7,7 @@ from typing import Any, Optional, Union
7
7
 
8
8
  from ._base import BaseDatalabClient, __version__
9
9
 
10
- __all__ = ("__version__", "DatalabClient")
10
+ __all__ = ("DatalabClient", "__version__")
11
11
 
12
12
 
13
13
  class DuplicateItemError(ValueError):
@@ -282,8 +282,9 @@ class DatalabClient(BaseDatalabClient):
282
282
  warnings.warn(f"Will not overwrite existing file {f['name']}")
283
283
  continue
284
284
  with open(f["name"], "wb") as file:
285
- response = self.session.get(url, follow_redirects=True)
286
- file.write(response.content)
285
+ with self.session.stream("GET", url, follow_redirects=True) as response:
286
+ for chunk in response.iter_bytes(chunk_size=1024):
287
+ file.write(chunk)
287
288
 
288
289
  def get_block(self, item_id: str, block_id: str, block_data: dict[str, Any]) -> dict[str, Any]:
289
290
  """Get a block with a given ID and block data.
@@ -14,7 +14,7 @@ from rich.table import Table
14
14
 
15
15
  __version__ = version("datalab-api")
16
16
 
17
- __all__ = ("__version__", "BaseDatalabClient")
17
+ __all__ = ("BaseDatalabClient", "__version__")
18
18
 
19
19
 
20
20
  def pretty_displayer(method):
@@ -270,7 +270,7 @@ class BaseDatalabClient(metaclass=AutoPrettyPrint):
270
270
 
271
271
  return self.api_key
272
272
 
273
- def __enter__(self) -> "BaseDatalabClient":
273
+ def __enter__(self):
274
274
  return self
275
275
 
276
276
  def __exit__(self, *_):
@@ -1,7 +1,7 @@
1
- Metadata-Version: 2.2
1
+ Metadata-Version: 2.4
2
2
  Name: datalab-api
3
- Version: 0.2.8
4
- Summary: A Python API for instances of the datalab data management platform (https://github.com/the-grey-group/datalab).
3
+ Version: 0.2.10
4
+ Summary: A Python API for instances of the datalab data management platform (https://github.com/datalab-org/datalab).
5
5
  Author-email: Matthew Evans <matthew@ml-evs.science>
6
6
  License: MIT
7
7
  Project-URL: homepage, https://github.com/datalab-org/datalab-api
@@ -10,7 +10,6 @@ Project-URL: documentation, https://datalab-python-api.readthedocs.io
10
10
  Project-URL: changelog, https://github.com/datalab-org/datalab-api/releases
11
11
  Classifier: Programming Language :: Python :: 3
12
12
  Classifier: Programming Language :: Python :: 3.9
13
- Classifier: Programming Language :: Python :: 3
14
13
  Classifier: Programming Language :: Python :: 3.10
15
14
  Classifier: Programming Language :: Python :: 3.11
16
15
  Classifier: Programming Language :: Python :: 3.12
@@ -22,7 +21,7 @@ Requires-Python: >=3.9
22
21
  Description-Content-Type: text/markdown
23
22
  License-File: LICENSE
24
23
  Requires-Dist: httpx~=0.27
25
- Requires-Dist: bokeh~=2.4
24
+ Requires-Dist: bokeh~=2.4; platform_system != "Emscripten"
26
25
  Requires-Dist: rich~=13.0
27
26
  Requires-Dist: numpy<2
28
27
  Provides-Extra: dev
@@ -44,6 +43,7 @@ Requires-Dist: pandas~=2.2; extra == "cheminventory-helper"
44
43
  Requires-Dist: openpyxl~=3.0; extra == "cheminventory-helper"
45
44
  Provides-Extra: all
46
45
  Requires-Dist: datalab-api[cli,dev,docs]; extra == "all"
46
+ Dynamic: license-file
47
47
 
48
48
  # <div align="center"><i>datalab</i> Python API</div>
49
49
 
@@ -1,8 +1,10 @@
1
1
  httpx~=0.27
2
- bokeh~=2.4
3
2
  rich~=13.0
4
3
  numpy<2
5
4
 
5
+ [:platform_system != "Emscripten"]
6
+ bokeh~=2.4
7
+
6
8
  [all]
7
9
  datalab-api[cli,dev,docs]
8
10
 
@@ -0,0 +1,57 @@
1
+ import pytest
2
+ import respx
3
+ from httpx import Response
4
+
5
+ from datalab_api import DatalabClient
6
+
7
+
8
+ @respx.mock
9
+ def test_redirect_url(fake_ui_html, fake_info_json, fake_block_info_json):
10
+ fake_ui = respx.get("https://ui.datalab.industries").mock(
11
+ return_value=Response(200, content=fake_ui_html)
12
+ )
13
+ fake_info_api = respx.get("https://api.datalab.industries/info").mock(
14
+ return_value=Response(200, json=fake_info_json)
15
+ )
16
+ fake_block_info_api = respx.get("https://api.datalab.industries/info/blocks").mock(
17
+ return_value=Response(200, json=fake_block_info_json)
18
+ )
19
+ with pytest.warns(
20
+ UserWarning,
21
+ match="^Found API URL https://api.datalab.industries in HTML meta tag. Creating client with this URL instead.$",
22
+ ):
23
+ client = DatalabClient("https://ui.datalab.industries")
24
+ assert fake_ui.called
25
+ assert fake_info_api.called
26
+ assert fake_block_info_api.called
27
+ assert client.datalab_api_url == "https://api.datalab.industries"
28
+
29
+
30
+ @respx.mock
31
+ def test_sample_list(fake_samples_json, fake_info_json, fake_sample_json, fake_block_info_json):
32
+ fake_api = respx.get("https://api.datalab.industries/").mock(
33
+ return_value=Response(200, content="<!doctype html></html>")
34
+ )
35
+ fake_samples_api = respx.get("https://api.datalab.industries/samples").mock(
36
+ return_value=Response(200, json=fake_samples_json)
37
+ )
38
+ fake_info_api = respx.get("https://api.datalab.industries/info").mock(
39
+ return_value=Response(200, json=fake_info_json)
40
+ )
41
+ fake_block_info_api = respx.get("https://api.datalab.industries/info/blocks").mock(
42
+ return_value=Response(200, json=fake_block_info_json)
43
+ )
44
+ fake_item_api = respx.get("https://api.datalab.industries/get-item-data/KUVEKJ").mock(
45
+ return_value=Response(200, json=fake_sample_json)
46
+ )
47
+ with DatalabClient("https://api.datalab.industries") as client:
48
+ samples = client.get_items(display=True)
49
+ assert fake_samples_api.called
50
+ assert fake_api.called
51
+ assert fake_info_api.called
52
+ assert fake_block_info_api.called
53
+ assert len(samples)
54
+ assert samples[0]["item_id"] == "test"
55
+ sample = client.get_item("KUVEKJ", display=True)
56
+ assert fake_item_api.called
57
+ assert sample["item_id"] == "KUVEKJ"
@@ -1,26 +0,0 @@
1
- import pytest
2
- import respx
3
- from datalab_api import DatalabClient
4
- from httpx import Response
5
-
6
-
7
- @respx.mock
8
- def test_redirect_url(fake_ui_html, fake_info_json, fake_block_info_json):
9
- fake_ui = respx.get("https://ui.datalab.industries").mock(
10
- return_value=Response(200, content=fake_ui_html)
11
- )
12
- fake_info_api = respx.get("https://api.datalab.industries/info").mock(
13
- return_value=Response(200, json=fake_info_json)
14
- )
15
- fake_block_info_api = respx.get("https://api.datalab.industries/info/blocks").mock(
16
- return_value=Response(200, json=fake_block_info_json)
17
- )
18
- with pytest.warns(
19
- UserWarning,
20
- match="^Found API URL https://api.datalab.industries in HTML meta tag. Creating client with this URL instead.$",
21
- ):
22
- client = DatalabClient("https://ui.datalab.industries")
23
- assert fake_ui.called
24
- assert fake_info_api.called
25
- assert fake_block_info_api.called
26
- assert client.datalab_api_url == "https://api.datalab.industries"
File without changes
File without changes
File without changes