datalab-api 0.2.9__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,6 +1,6 @@
1
- Metadata-Version: 2.2
1
+ Metadata-Version: 2.4
2
2
  Name: datalab-api
3
- Version: 0.2.9
3
+ Version: 0.2.10
4
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
@@ -43,6 +43,7 @@ Requires-Dist: pandas~=2.2; extra == "cheminventory-helper"
43
43
  Requires-Dist: openpyxl~=3.0; extra == "cheminventory-helper"
44
44
  Provides-Extra: all
45
45
  Requires-Dist: datalab-api[cli,dev,docs]; extra == "all"
46
+ Dynamic: license-file
46
47
 
47
48
  # <div align="center"><i>datalab</i> Python API</div>
48
49
 
@@ -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.
@@ -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,6 +1,6 @@
1
- Metadata-Version: 2.2
1
+ Metadata-Version: 2.4
2
2
  Name: datalab-api
3
- Version: 0.2.9
3
+ Version: 0.2.10
4
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
@@ -43,6 +43,7 @@ Requires-Dist: pandas~=2.2; extra == "cheminventory-helper"
43
43
  Requires-Dist: openpyxl~=3.0; extra == "cheminventory-helper"
44
44
  Provides-Extra: all
45
45
  Requires-Dist: datalab-api[cli,dev,docs]; extra == "all"
46
+ Dynamic: license-file
46
47
 
47
48
  # <div align="center"><i>datalab</i> Python API</div>
48
49
 
@@ -28,7 +28,7 @@ def test_redirect_url(fake_ui_html, fake_info_json, fake_block_info_json):
28
28
 
29
29
 
30
30
  @respx.mock
31
- def test_sample_list(fake_samples_json, fake_info_json, fake_block_info_json):
31
+ def test_sample_list(fake_samples_json, fake_info_json, fake_sample_json, fake_block_info_json):
32
32
  fake_api = respx.get("https://api.datalab.industries/").mock(
33
33
  return_value=Response(200, content="<!doctype html></html>")
34
34
  )
@@ -41,6 +41,9 @@ def test_sample_list(fake_samples_json, fake_info_json, fake_block_info_json):
41
41
  fake_block_info_api = respx.get("https://api.datalab.industries/info/blocks").mock(
42
42
  return_value=Response(200, json=fake_block_info_json)
43
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
+ )
44
47
  with DatalabClient("https://api.datalab.industries") as client:
45
48
  samples = client.get_items(display=True)
46
49
  assert fake_samples_api.called
@@ -49,3 +52,6 @@ def test_sample_list(fake_samples_json, fake_info_json, fake_block_info_json):
49
52
  assert fake_block_info_api.called
50
53
  assert len(samples)
51
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"
File without changes
File without changes
File without changes
File without changes