datalab-api 0.5.0__tar.gz → 0.5.1__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
1
  Metadata-Version: 2.4
2
2
  Name: datalab-api
3
- Version: 0.5.0
3
+ Version: 0.5.1
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
@@ -273,7 +273,13 @@ class DatalabClient(BaseDatalabClient):
273
273
  for chunk in response.iter_bytes(chunk_size=1024):
274
274
  file.write(chunk)
275
275
 
276
- def get_block(self, item_id: str, block_id: str, block_data: dict[str, Any]) -> dict[str, Any]:
276
+ def get_block(
277
+ self,
278
+ item_id: str,
279
+ block_id: str,
280
+ block_data: dict[str, Any] | None = None,
281
+ event_data: dict[str, Any] | None = None,
282
+ ) -> dict[str, Any]:
277
283
  """Get a block with a given ID and block data.
278
284
  Should be used in conjunction with `get_item` to load an existing block.
279
285
 
@@ -281,17 +287,25 @@ class DatalabClient(BaseDatalabClient):
281
287
  item_id: The ID of the item to search for.
282
288
  block_id: The ID of the block to search for.
283
289
  block_data: Any other block data required by the request.
290
+ event_data: Any block events to trigger.
284
291
 
285
292
  Returns:
286
293
  A dictionary of block data for the block with the given ID.
287
294
 
288
295
  """
289
- block_url = f"{self.datalab_api_url}/update-block/"
296
+ block_url = f"{self.datalab_api_url}/blocks/"
297
+
298
+ if not block_data:
299
+ block_data = {}
300
+
301
+ block_data["item_id"] = item_id
302
+ block_data["block_id"] = block_id
303
+ if "blocktype" not in block_data:
304
+ raise ValueError("block_data must contain a 'blocktype' key.")
305
+
290
306
  block_request = {
291
307
  "block_data": block_data,
292
- "item_id": item_id,
293
- "block_id": block_id,
294
- "save_to_db": False,
308
+ "event_data": event_data,
295
309
  }
296
310
  block = self._post(block_url, json=block_request)
297
311
  return block["new_block_data"]
@@ -424,10 +438,10 @@ class DatalabClient(BaseDatalabClient):
424
438
 
425
439
  if file_ids:
426
440
  if len(file_ids) > 1:
427
- raise RuntimeError(
428
- "API does not currently support attaching multiple files in a block."
429
- )
430
- block_data["file_id"] = file_ids[0]
441
+ block_data["file_ids"] = file_ids
442
+ else:
443
+ block_data.pop("file_ids", None)
444
+ block_data["file_id"] = file_ids[0]
431
445
 
432
446
  blocks_url = f"{self.datalab_api_url}/update-block/"
433
447
  payload = {
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: datalab-api
3
- Version: 0.5.0
3
+ Version: 0.5.1
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
File without changes
File without changes
File without changes
File without changes