lumera 0.8.2__tar.gz → 0.9.0__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.
- {lumera-0.8.2 → lumera-0.9.0}/PKG-INFO +1 -1
- {lumera-0.8.2 → lumera-0.9.0}/lumera/google.py +1 -1
- {lumera-0.8.2 → lumera-0.9.0}/lumera/pb.py +11 -7
- {lumera-0.8.2 → lumera-0.9.0}/lumera/sdk.py +6 -10
- {lumera-0.8.2 → lumera-0.9.0}/lumera.egg-info/PKG-INFO +1 -1
- {lumera-0.8.2 → lumera-0.9.0}/pyproject.toml +1 -1
- {lumera-0.8.2 → lumera-0.9.0}/tests/test_sdk.py +42 -0
- {lumera-0.8.2 → lumera-0.9.0}/lumera/__init__.py +0 -0
- {lumera-0.8.2 → lumera-0.9.0}/lumera/_utils.py +0 -0
- {lumera-0.8.2 → lumera-0.9.0}/lumera/automations.py +0 -0
- {lumera-0.8.2 → lumera-0.9.0}/lumera/exceptions.py +0 -0
- {lumera-0.8.2 → lumera-0.9.0}/lumera/llm.py +0 -0
- {lumera-0.8.2 → lumera-0.9.0}/lumera/locks.py +0 -0
- {lumera-0.8.2 → lumera-0.9.0}/lumera/storage.py +0 -0
- {lumera-0.8.2 → lumera-0.9.0}/lumera/webhooks.py +0 -0
- {lumera-0.8.2 → lumera-0.9.0}/lumera.egg-info/SOURCES.txt +0 -0
- {lumera-0.8.2 → lumera-0.9.0}/lumera.egg-info/dependency_links.txt +0 -0
- {lumera-0.8.2 → lumera-0.9.0}/lumera.egg-info/requires.txt +0 -0
- {lumera-0.8.2 → lumera-0.9.0}/lumera.egg-info/top_level.txt +0 -0
- {lumera-0.8.2 → lumera-0.9.0}/setup.cfg +0 -0
|
@@ -342,24 +342,28 @@ def bulk_delete(collection: str, record_ids: Sequence[str]) -> dict[str, Any]:
|
|
|
342
342
|
|
|
343
343
|
def bulk_update(
|
|
344
344
|
collection: str,
|
|
345
|
-
|
|
346
|
-
data: dict[str, Any],
|
|
345
|
+
records: Sequence[dict[str, Any]],
|
|
347
346
|
) -> dict[str, Any]:
|
|
348
|
-
"""Update multiple records with
|
|
347
|
+
"""Update multiple records with individual data per record.
|
|
348
|
+
|
|
349
|
+
Each record must have an 'id' field plus fields to update.
|
|
350
|
+
Records must exist (returns error if not found, does not create).
|
|
349
351
|
|
|
350
352
|
Args:
|
|
351
353
|
collection: Collection name or ID
|
|
352
|
-
|
|
353
|
-
data: Fields to update on all records
|
|
354
|
+
records: List of records to update (max 1000). Each must have 'id' field.
|
|
354
355
|
|
|
355
356
|
Returns:
|
|
356
357
|
Result with succeeded/failed counts
|
|
357
358
|
|
|
358
359
|
Example:
|
|
359
|
-
>>> result = pb.bulk_update("deposits", [
|
|
360
|
+
>>> result = pb.bulk_update("deposits", [
|
|
361
|
+
... {"id": "rec1", "status": "approved", "amount": 100},
|
|
362
|
+
... {"id": "rec2", "status": "rejected", "amount": 200},
|
|
363
|
+
... ])
|
|
360
364
|
>>> print(f"Updated {result['succeeded']} records")
|
|
361
365
|
"""
|
|
362
|
-
return _bulk_update_records(collection,
|
|
366
|
+
return _bulk_update_records(collection, records)
|
|
363
367
|
|
|
364
368
|
|
|
365
369
|
def bulk_upsert(collection: str, records: Sequence[dict[str, Any]]) -> dict[str, Any]:
|
|
@@ -613,28 +613,24 @@ def bulk_delete_records(
|
|
|
613
613
|
|
|
614
614
|
def bulk_update_records(
|
|
615
615
|
collection_id_or_name: str,
|
|
616
|
-
|
|
617
|
-
data: Mapping[str, Any],
|
|
616
|
+
records: Sequence[Mapping[str, Any]],
|
|
618
617
|
) -> dict[str, Any]:
|
|
619
|
-
"""Update multiple records with
|
|
618
|
+
"""Update multiple records with individual data per record.
|
|
620
619
|
|
|
621
620
|
Args:
|
|
622
621
|
collection_id_or_name: Collection name or ID
|
|
623
|
-
|
|
624
|
-
data: Fields to update on all records
|
|
622
|
+
records: List of records to update (max 1000). Each record must have an 'id' field.
|
|
625
623
|
|
|
626
624
|
Returns:
|
|
627
625
|
Result with succeeded/failed counts
|
|
628
626
|
"""
|
|
629
627
|
if not collection_id_or_name:
|
|
630
628
|
raise ValueError("collection_id_or_name is required")
|
|
631
|
-
if not
|
|
632
|
-
raise ValueError("
|
|
633
|
-
if not data:
|
|
634
|
-
raise ValueError("data is required")
|
|
629
|
+
if not records:
|
|
630
|
+
raise ValueError("records is required")
|
|
635
631
|
|
|
636
632
|
path = f"collections/{collection_id_or_name}/records/bulk/update"
|
|
637
|
-
result = _api_request("POST", path, json_body={"
|
|
633
|
+
result = _api_request("POST", path, json_body={"records": [dict(r) for r in records]})
|
|
638
634
|
return result if isinstance(result, dict) else {}
|
|
639
635
|
|
|
640
636
|
|
|
@@ -852,3 +852,45 @@ def test_claim_locks_custom_provenance(monkeypatch: pytest.MonkeyPatch) -> None:
|
|
|
852
852
|
body = captured.get("json_body")
|
|
853
853
|
assert isinstance(body, dict)
|
|
854
854
|
assert body["provenance"] == custom_prov
|
|
855
|
+
|
|
856
|
+
|
|
857
|
+
def test_bulk_update_records(monkeypatch: pytest.MonkeyPatch) -> None:
|
|
858
|
+
monkeypatch.setenv(sdk.TOKEN_ENV, "tok")
|
|
859
|
+
|
|
860
|
+
captured: dict[str, object] = {}
|
|
861
|
+
|
|
862
|
+
def fake_api(method: str, path: str, **kwargs: object) -> dict[str, object]:
|
|
863
|
+
captured["method"] = method
|
|
864
|
+
captured["path"] = path
|
|
865
|
+
captured["kwargs"] = kwargs
|
|
866
|
+
return {"succeeded": 2, "failed": 0, "errors": []}
|
|
867
|
+
|
|
868
|
+
monkeypatch.setattr(sdk, "_api_request", fake_api)
|
|
869
|
+
|
|
870
|
+
result = sdk.bulk_update_records(
|
|
871
|
+
"test_collection",
|
|
872
|
+
[
|
|
873
|
+
{"id": "rec1", "status": "approved", "amount": 100},
|
|
874
|
+
{"id": "rec2", "status": "rejected", "amount": 200},
|
|
875
|
+
],
|
|
876
|
+
)
|
|
877
|
+
|
|
878
|
+
assert result["succeeded"] == 2
|
|
879
|
+
assert result["failed"] == 0
|
|
880
|
+
assert captured["method"] == "POST"
|
|
881
|
+
assert captured["path"] == "collections/test_collection/records/bulk/update"
|
|
882
|
+
kwargs = captured["kwargs"]
|
|
883
|
+
assert "json_body" in kwargs
|
|
884
|
+
body = kwargs["json_body"]
|
|
885
|
+
assert isinstance(body, dict)
|
|
886
|
+
assert "records" in body
|
|
887
|
+
assert len(body["records"]) == 2
|
|
888
|
+
assert body["records"][0]["id"] == "rec1"
|
|
889
|
+
assert body["records"][0]["status"] == "approved"
|
|
890
|
+
assert body["records"][1]["id"] == "rec2"
|
|
891
|
+
assert body["records"][1]["status"] == "rejected"
|
|
892
|
+
|
|
893
|
+
|
|
894
|
+
def test_bulk_update_records_requires_records() -> None:
|
|
895
|
+
with pytest.raises(ValueError, match="records is required"):
|
|
896
|
+
sdk.bulk_update_records("test_collection", [])
|
|
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
|
|
File without changes
|