datalab-api 0.2.6__tar.gz → 0.2.7__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.2.6/src/datalab_api.egg-info → datalab_api-0.2.7}/PKG-INFO +1 -1
- {datalab_api-0.2.6 → datalab_api-0.2.7}/src/datalab_api/__init__.py +29 -2
- {datalab_api-0.2.6 → datalab_api-0.2.7}/src/datalab_api/_base.py +9 -2
- {datalab_api-0.2.6 → datalab_api-0.2.7/src/datalab_api.egg-info}/PKG-INFO +1 -1
- {datalab_api-0.2.6 → datalab_api-0.2.7}/LICENSE +0 -0
- {datalab_api-0.2.6 → datalab_api-0.2.7}/README.md +0 -0
- {datalab_api-0.2.6 → datalab_api-0.2.7}/pyproject.toml +0 -0
- {datalab_api-0.2.6 → datalab_api-0.2.7}/setup.cfg +0 -0
- {datalab_api-0.2.6 → datalab_api-0.2.7}/src/datalab_api/cli.py +0 -0
- {datalab_api-0.2.6 → datalab_api-0.2.7}/src/datalab_api/helpers.py +0 -0
- {datalab_api-0.2.6 → datalab_api-0.2.7}/src/datalab_api.egg-info/SOURCES.txt +0 -0
- {datalab_api-0.2.6 → datalab_api-0.2.7}/src/datalab_api.egg-info/dependency_links.txt +0 -0
- {datalab_api-0.2.6 → datalab_api-0.2.7}/src/datalab_api.egg-info/entry_points.txt +0 -0
- {datalab_api-0.2.6 → datalab_api-0.2.7}/src/datalab_api.egg-info/requires.txt +0 -0
- {datalab_api-0.2.6 → datalab_api-0.2.7}/src/datalab_api.egg-info/top_level.txt +0 -0
- {datalab_api-0.2.6 → datalab_api-0.2.7}/tests/test_client.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: datalab-api
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.7
|
|
4
4
|
Summary: A Python API for instances of the datalab data management platform (https://github.com/the-grey-group/datalab).
|
|
5
5
|
Author-email: Matthew Evans <matthew@ml-evs.science>
|
|
6
6
|
License: MIT
|
|
@@ -131,7 +131,8 @@ class DatalabClient(BaseDatalabClient):
|
|
|
131
131
|
try:
|
|
132
132
|
collection_immutable_id = self.get_collection(collection_id)["immutable_id"]
|
|
133
133
|
except RuntimeError:
|
|
134
|
-
|
|
134
|
+
self.create_collection(collection_id)
|
|
135
|
+
collection_immutable_id = self.get_collection(collection_id)["immutable_id"]
|
|
135
136
|
new_item["collections"] = new_item.get("collections", [])
|
|
136
137
|
new_item["collections"].append({"immutable_id": collection_immutable_id})
|
|
137
138
|
|
|
@@ -389,6 +390,33 @@ class DatalabClient(BaseDatalabClient):
|
|
|
389
390
|
|
|
390
391
|
return block_data
|
|
391
392
|
|
|
393
|
+
def update_data_block(
|
|
394
|
+
self, item_id: str, block_id: str, block_type: str, block_data: dict
|
|
395
|
+
) -> dict[str, Any]:
|
|
396
|
+
"""Attempts to update a block with the given payload of data,
|
|
397
|
+
returning the updated block.
|
|
398
|
+
|
|
399
|
+
Parameters:
|
|
400
|
+
item_id: The ID of the item that the block is attached to.
|
|
401
|
+
block_id: The ID of existing block.
|
|
402
|
+
block_type: The type of block to update.
|
|
403
|
+
block_data: The payload of block data to update; will be used to selectively update
|
|
404
|
+
any fields present, with validation performed by the remote block code itself.
|
|
405
|
+
|
|
406
|
+
Returns:
|
|
407
|
+
If successful, the updated block data.
|
|
408
|
+
|
|
409
|
+
Raises:
|
|
410
|
+
RuntimeError: If the block update fails.
|
|
411
|
+
|
|
412
|
+
"""
|
|
413
|
+
payload = {k: v for k, v in block_data.items()}
|
|
414
|
+
payload["block_id"] = block_id
|
|
415
|
+
payload["blocktype"] = block_type
|
|
416
|
+
payload["item_id"] = item_id
|
|
417
|
+
|
|
418
|
+
return self._update_data_block(block_type=block_type, block_data=payload)
|
|
419
|
+
|
|
392
420
|
def _update_data_block(
|
|
393
421
|
self, block_type: str, block_data: dict, file_ids: str | list[str] | None = None
|
|
394
422
|
) -> dict[str, Any]:
|
|
@@ -401,7 +429,6 @@ class DatalabClient(BaseDatalabClient):
|
|
|
401
429
|
raise RuntimeError(
|
|
402
430
|
"API does not currently support attaching multiple files in a block."
|
|
403
431
|
)
|
|
404
|
-
|
|
405
432
|
block_data["file_id"] = file_ids[0]
|
|
406
433
|
|
|
407
434
|
blocks_url = f"{self.datalab_api_url}/update-block/"
|
|
@@ -95,6 +95,7 @@ class BaseDatalabClient(metaclass=AutoPrettyPrint):
|
|
|
95
95
|
_api_key: Optional[str] = None
|
|
96
96
|
_session: Optional[httpx.Client] = None
|
|
97
97
|
_headers: dict[str, str] = {}
|
|
98
|
+
_timeout: httpx.Timeout = httpx.Timeout(10.0, read=60.0)
|
|
98
99
|
|
|
99
100
|
bad_server_versions: Optional[tuple[tuple[int, int, int]]] = ((0, 2, 0),)
|
|
100
101
|
"""Any known server versions that are not supported by this client."""
|
|
@@ -172,13 +173,19 @@ class BaseDatalabClient(metaclass=AutoPrettyPrint):
|
|
|
172
173
|
@property
|
|
173
174
|
def session(self) -> httpx.Client:
|
|
174
175
|
if self._session is None:
|
|
175
|
-
return self._http_client(headers=self.headers)
|
|
176
|
+
return self._http_client(headers=self.headers, timeout=self.timeout)
|
|
176
177
|
return self._session
|
|
177
178
|
|
|
178
179
|
@property
|
|
179
|
-
def headers(self):
|
|
180
|
+
def headers(self) -> dict[str, str]:
|
|
181
|
+
"""Any headers to send with each request to the datalab API."""
|
|
180
182
|
return self._headers
|
|
181
183
|
|
|
184
|
+
@property
|
|
185
|
+
def timeout(self) -> httpx.Timeout:
|
|
186
|
+
"""A timeout object to use for the datalab API session."""
|
|
187
|
+
return self._timeout
|
|
188
|
+
|
|
182
189
|
def _version_negotiation(self):
|
|
183
190
|
"""Check whether this client is expected to work with this instance.
|
|
184
191
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: datalab-api
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.7
|
|
4
4
|
Summary: A Python API for instances of the datalab data management platform (https://github.com/the-grey-group/datalab).
|
|
5
5
|
Author-email: Matthew Evans <matthew@ml-evs.science>
|
|
6
6
|
License: MIT
|
|
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
|
|
File without changes
|
|
File without changes
|