datalab-api 0.3.0__tar.gz → 0.3.2__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.
- {datalab_api-0.3.0/src/datalab_api.egg-info → datalab_api-0.3.2}/PKG-INFO +4 -4
- {datalab_api-0.3.0 → datalab_api-0.3.2}/README.md +1 -1
- {datalab_api-0.3.0 → datalab_api-0.3.2}/pyproject.toml +2 -2
- {datalab_api-0.3.0 → datalab_api-0.3.2}/src/datalab_api/__init__.py +5 -1
- {datalab_api-0.3.0 → datalab_api-0.3.2}/src/datalab_api/_base.py +14 -3
- {datalab_api-0.3.0 → datalab_api-0.3.2/src/datalab_api.egg-info}/PKG-INFO +4 -4
- {datalab_api-0.3.0 → datalab_api-0.3.2}/src/datalab_api.egg-info/requires.txt +2 -2
- {datalab_api-0.3.0 → datalab_api-0.3.2}/LICENSE +0 -0
- {datalab_api-0.3.0 → datalab_api-0.3.2}/setup.cfg +0 -0
- {datalab_api-0.3.0 → datalab_api-0.3.2}/src/datalab_api/cli.py +0 -0
- {datalab_api-0.3.0 → datalab_api-0.3.2}/src/datalab_api/helpers.py +0 -0
- {datalab_api-0.3.0 → datalab_api-0.3.2}/src/datalab_api/utils.py +0 -0
- {datalab_api-0.3.0 → datalab_api-0.3.2}/src/datalab_api.egg-info/SOURCES.txt +0 -0
- {datalab_api-0.3.0 → datalab_api-0.3.2}/src/datalab_api.egg-info/dependency_links.txt +0 -0
- {datalab_api-0.3.0 → datalab_api-0.3.2}/src/datalab_api.egg-info/entry_points.txt +0 -0
- {datalab_api-0.3.0 → datalab_api-0.3.2}/src/datalab_api.egg-info/top_level.txt +0 -0
- {datalab_api-0.3.0 → datalab_api-0.3.2}/tests/test_client.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: datalab-api
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.2
|
|
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-Expression: MIT
|
|
@@ -22,12 +22,12 @@ Description-Content-Type: text/markdown
|
|
|
22
22
|
License-File: LICENSE
|
|
23
23
|
Requires-Dist: httpx~=0.28
|
|
24
24
|
Requires-Dist: bokeh~=2.4; platform_system != "Emscripten"
|
|
25
|
-
Requires-Dist: rich
|
|
25
|
+
Requires-Dist: rich<15,>=13
|
|
26
26
|
Requires-Dist: numpy<2
|
|
27
27
|
Provides-Extra: dev
|
|
28
28
|
Requires-Dist: pre-commit<5,>=3; extra == "dev"
|
|
29
29
|
Requires-Dist: pytest~=8.0; extra == "dev"
|
|
30
|
-
Requires-Dist: pytest-cov<
|
|
30
|
+
Requires-Dist: pytest-cov<8,>=5; extra == "dev"
|
|
31
31
|
Requires-Dist: respx~=0.22; extra == "dev"
|
|
32
32
|
Provides-Extra: docs
|
|
33
33
|
Requires-Dist: mkdocs; extra == "docs"
|
|
@@ -61,7 +61,7 @@ A simple Python API that can interact with [*datalab*](https://github.com/datala
|
|
|
61
61
|
|
|
62
62
|
The idea here is to provide a set of utility functions and models for manipulating samples, cells, inventory, files, users and metadata associated with *datalab* entries in an automated way.
|
|
63
63
|
|
|
64
|
-
This API may not expose all the functionality available in a given *datalab* instance, and the idea would be that this package can support multiple versions of the underlying [*datalab* REST API](https://docs.datalab-org.io
|
|
64
|
+
This API may not expose all the functionality available in a given *datalab* instance, and the idea would be that this package can support multiple versions of the underlying [*datalab* REST API](https://docs.datalab-org.io).
|
|
65
65
|
This means that the API is primarily *functional* in nature, as opposed to object-oriented, since *datalab* instances are free to use their own custom data models.
|
|
66
66
|
The available schemas are reported as instance metadata and in the future object-oriented models may be able to be genereated directly in the client (so e.g., the returned data would be Python objects like `Sample` rather than JSON data).
|
|
67
67
|
|
|
@@ -14,7 +14,7 @@ A simple Python API that can interact with [*datalab*](https://github.com/datala
|
|
|
14
14
|
|
|
15
15
|
The idea here is to provide a set of utility functions and models for manipulating samples, cells, inventory, files, users and metadata associated with *datalab* entries in an automated way.
|
|
16
16
|
|
|
17
|
-
This API may not expose all the functionality available in a given *datalab* instance, and the idea would be that this package can support multiple versions of the underlying [*datalab* REST API](https://docs.datalab-org.io
|
|
17
|
+
This API may not expose all the functionality available in a given *datalab* instance, and the idea would be that this package can support multiple versions of the underlying [*datalab* REST API](https://docs.datalab-org.io).
|
|
18
18
|
This means that the API is primarily *functional* in nature, as opposed to object-oriented, since *datalab* instances are free to use their own custom data models.
|
|
19
19
|
The available schemas are reported as instance metadata and in the future object-oriented models may be able to be genereated directly in the client (so e.g., the returned data would be Python objects like `Sample` rather than JSON data).
|
|
20
20
|
|
|
@@ -26,7 +26,7 @@ requires-python = ">=3.9"
|
|
|
26
26
|
dependencies = [
|
|
27
27
|
"httpx ~= 0.28", # better HTTP requests
|
|
28
28
|
'bokeh ~= 2.4; platform_system != "Emscripten"', # interactive plots from datalab directly
|
|
29
|
-
"rich
|
|
29
|
+
"rich >= 13,< 15", # nicer terminal output
|
|
30
30
|
"numpy < 2", # upper pin for numpy due to bad pins in bokeh
|
|
31
31
|
]
|
|
32
32
|
|
|
@@ -35,7 +35,7 @@ dependencies = [
|
|
|
35
35
|
dev = [
|
|
36
36
|
"pre-commit >= 3,< 5",
|
|
37
37
|
"pytest ~= 8.0",
|
|
38
|
-
"pytest-cov >= 5,<
|
|
38
|
+
"pytest-cov >= 5,< 8",
|
|
39
39
|
"respx ~= 0.22",
|
|
40
40
|
]
|
|
41
41
|
|
|
@@ -5,7 +5,7 @@ from collections.abc import Iterable
|
|
|
5
5
|
from pathlib import Path
|
|
6
6
|
from typing import Any, Optional, Union
|
|
7
7
|
|
|
8
|
-
from ._base import BaseDatalabClient, DuplicateItemError, __version__
|
|
8
|
+
from ._base import BaseDatalabClient, DatalabAPIError, DuplicateItemError, __version__
|
|
9
9
|
|
|
10
10
|
__all__ = ("DatalabClient", "DuplicateItemError", "__version__")
|
|
11
11
|
|
|
@@ -150,6 +150,9 @@ class DatalabClient(BaseDatalabClient):
|
|
|
150
150
|
except RuntimeError:
|
|
151
151
|
self.create_collection(collection_id)
|
|
152
152
|
collection_immutable_id = self.get_collection(collection_id)[0]["immutable_id"]
|
|
153
|
+
except DatalabAPIError:
|
|
154
|
+
self.create_collection(collection_id)
|
|
155
|
+
collection_immutable_id = self.get_collection(collection_id)[0]["immutable_id"]
|
|
153
156
|
new_item["collections"] = new_item.get("collections", [])
|
|
154
157
|
new_item["collections"].append({"immutable_id": collection_immutable_id})
|
|
155
158
|
|
|
@@ -157,6 +160,7 @@ class DatalabClient(BaseDatalabClient):
|
|
|
157
160
|
created_item = self._post(
|
|
158
161
|
create_item_url,
|
|
159
162
|
json={"new_sample_data": new_item, "generate_id_automatically": item_id is None},
|
|
163
|
+
expected_status=201,
|
|
160
164
|
)
|
|
161
165
|
return created_item["sample_list_entry"]
|
|
162
166
|
|
|
@@ -2,6 +2,7 @@ import logging
|
|
|
2
2
|
import os
|
|
3
3
|
import re
|
|
4
4
|
import warnings
|
|
5
|
+
from getpass import getpass
|
|
5
6
|
from importlib.metadata import version
|
|
6
7
|
from typing import Any, Optional
|
|
7
8
|
|
|
@@ -37,6 +38,11 @@ class BaseDatalabClient(metaclass=AutoPrettyPrint):
|
|
|
37
38
|
_headers: dict[str, str] = {}
|
|
38
39
|
_timeout: httpx.Timeout = httpx.Timeout(10.0, read=60.0)
|
|
39
40
|
|
|
41
|
+
interactive: bool = True
|
|
42
|
+
"""Whether the client is being used in an interactive context (e.g., CLI or notebook) or not.
|
|
43
|
+
Set to false if you want the script to error if no API key is found in the environment variables,
|
|
44
|
+
rather than prompting for input."""
|
|
45
|
+
|
|
40
46
|
info: dict[str, Any] = {}
|
|
41
47
|
"""The `data` response from the `/info` endpoint of the Datalab API."""
|
|
42
48
|
|
|
@@ -189,9 +195,14 @@ class BaseDatalabClient(metaclass=AutoPrettyPrint):
|
|
|
189
195
|
api_key = api_key.strip("'").strip('"')
|
|
190
196
|
|
|
191
197
|
if api_key is None:
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
198
|
+
if self.interactive:
|
|
199
|
+
api_key = getpass(
|
|
200
|
+
f"Enter your API key for {self.datalab_api_url} (input will be hidden): "
|
|
201
|
+
)
|
|
202
|
+
else:
|
|
203
|
+
raise ValueError(
|
|
204
|
+
f"No API key found in environment variables {key_env_var}/<prefix>_{key_env_var}."
|
|
205
|
+
)
|
|
195
206
|
|
|
196
207
|
self._api_key = api_key
|
|
197
208
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: datalab-api
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.2
|
|
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-Expression: MIT
|
|
@@ -22,12 +22,12 @@ Description-Content-Type: text/markdown
|
|
|
22
22
|
License-File: LICENSE
|
|
23
23
|
Requires-Dist: httpx~=0.28
|
|
24
24
|
Requires-Dist: bokeh~=2.4; platform_system != "Emscripten"
|
|
25
|
-
Requires-Dist: rich
|
|
25
|
+
Requires-Dist: rich<15,>=13
|
|
26
26
|
Requires-Dist: numpy<2
|
|
27
27
|
Provides-Extra: dev
|
|
28
28
|
Requires-Dist: pre-commit<5,>=3; extra == "dev"
|
|
29
29
|
Requires-Dist: pytest~=8.0; extra == "dev"
|
|
30
|
-
Requires-Dist: pytest-cov<
|
|
30
|
+
Requires-Dist: pytest-cov<8,>=5; extra == "dev"
|
|
31
31
|
Requires-Dist: respx~=0.22; extra == "dev"
|
|
32
32
|
Provides-Extra: docs
|
|
33
33
|
Requires-Dist: mkdocs; extra == "docs"
|
|
@@ -61,7 +61,7 @@ A simple Python API that can interact with [*datalab*](https://github.com/datala
|
|
|
61
61
|
|
|
62
62
|
The idea here is to provide a set of utility functions and models for manipulating samples, cells, inventory, files, users and metadata associated with *datalab* entries in an automated way.
|
|
63
63
|
|
|
64
|
-
This API may not expose all the functionality available in a given *datalab* instance, and the idea would be that this package can support multiple versions of the underlying [*datalab* REST API](https://docs.datalab-org.io
|
|
64
|
+
This API may not expose all the functionality available in a given *datalab* instance, and the idea would be that this package can support multiple versions of the underlying [*datalab* REST API](https://docs.datalab-org.io).
|
|
65
65
|
This means that the API is primarily *functional* in nature, as opposed to object-oriented, since *datalab* instances are free to use their own custom data models.
|
|
66
66
|
The available schemas are reported as instance metadata and in the future object-oriented models may be able to be genereated directly in the client (so e.g., the returned data would be Python objects like `Sample` rather than JSON data).
|
|
67
67
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|