dataroom-client 1.0.2.post1.dev0__tar.gz → 1.0.3.post11.dev0__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.
- {dataroom_client-1.0.2.post1.dev0 → dataroom_client-1.0.3.post11.dev0}/PKG-INFO +1 -1
- {dataroom_client-1.0.2.post1.dev0 → dataroom_client-1.0.3.post11.dev0}/dataroom_client/client.py +19 -11
- {dataroom_client-1.0.2.post1.dev0 → dataroom_client-1.0.3.post11.dev0}/pyproject.toml +1 -1
- {dataroom_client-1.0.2.post1.dev0 → dataroom_client-1.0.3.post11.dev0}/README.md +0 -0
- {dataroom_client-1.0.2.post1.dev0 → dataroom_client-1.0.3.post11.dev0}/dataroom_client/__init__.py +0 -0
- {dataroom_client-1.0.2.post1.dev0 → dataroom_client-1.0.3.post11.dev0}/dataroom_client/counter.py +0 -0
- {dataroom_client-1.0.2.post1.dev0 → dataroom_client-1.0.3.post11.dev0}/dataroom_client/loader.py +0 -0
- {dataroom_client-1.0.2.post1.dev0 → dataroom_client-1.0.3.post11.dev0}/dataroom_client/print_utils.py +0 -0
{dataroom_client-1.0.2.post1.dev0 → dataroom_client-1.0.3.post11.dev0}/dataroom_client/client.py
RENAMED
|
@@ -866,6 +866,7 @@ class DataRoomClient:
|
|
|
866
866
|
exclude_fields: list[str] = None,
|
|
867
867
|
all_fields: bool = False,
|
|
868
868
|
return_latents: list[str] = None,
|
|
869
|
+
fetch_image_bytes: bool = False,
|
|
869
870
|
) -> dict:
|
|
870
871
|
"""
|
|
871
872
|
Retrieves a single image by its ID.
|
|
@@ -876,9 +877,10 @@ class DataRoomClient:
|
|
|
876
877
|
@param exclude_fields: A list of fields to exclude from the response.
|
|
877
878
|
@param all_fields: If True and `fields` is None, returns all available fields for each image.
|
|
878
879
|
@param return_latents: A list of latent types to return for the image.
|
|
880
|
+
@param fetch_image_bytes: whether to return the image bytes or not. Will query `image_direct_url`.
|
|
879
881
|
@return: A dictionary representing the image.
|
|
880
882
|
"""
|
|
881
|
-
|
|
883
|
+
response = await self._make_request(
|
|
882
884
|
url=f"images/{image_id}/",
|
|
883
885
|
params=self._dict_filter_none({
|
|
884
886
|
"fields": ",".join(fields) if fields else None,
|
|
@@ -888,6 +890,12 @@ class DataRoomClient:
|
|
|
888
890
|
"return_latents": ",".join(return_latents) if return_latents else None,
|
|
889
891
|
}),
|
|
890
892
|
)
|
|
893
|
+
if fetch_image_bytes:
|
|
894
|
+
assert "image_direct_url" in response
|
|
895
|
+
image_bytes_response = await self.client.request(method="GET", url=response["image_direct_url"])
|
|
896
|
+
image_bytes_response.raise_for_status()
|
|
897
|
+
response["image_bytes"] = image_bytes_response.content
|
|
898
|
+
return response
|
|
891
899
|
|
|
892
900
|
async def create_image(
|
|
893
901
|
self,
|
|
@@ -921,10 +929,10 @@ class DataRoomClient:
|
|
|
921
929
|
"""
|
|
922
930
|
if not image_file and not image_url:
|
|
923
931
|
raise DataRoomError('Please provide either an "image_file" or "image_url" field')
|
|
924
|
-
|
|
932
|
+
|
|
925
933
|
if not image_id and not image_url:
|
|
926
934
|
raise DataRoomError('Please provide either an "image_id" or "image_url" field')
|
|
927
|
-
|
|
935
|
+
|
|
928
936
|
if not source:
|
|
929
937
|
raise DataRoomError('Please provide a "source" field')
|
|
930
938
|
|
|
@@ -1131,7 +1139,7 @@ class DataRoomClient:
|
|
|
1131
1139
|
image.setdefault('coca_embedding', None)
|
|
1132
1140
|
image.setdefault('related_images', None)
|
|
1133
1141
|
image.setdefault('datasets', None)
|
|
1134
|
-
|
|
1142
|
+
|
|
1135
1143
|
return await self._make_request(
|
|
1136
1144
|
url=f"images/bulk_update/",
|
|
1137
1145
|
method="PUT",
|
|
@@ -1437,7 +1445,7 @@ class DataRoomClient:
|
|
|
1437
1445
|
)
|
|
1438
1446
|
else:
|
|
1439
1447
|
raise DataRoomError("Invalid arguments")
|
|
1440
|
-
|
|
1448
|
+
|
|
1441
1449
|
async def get_related_images(
|
|
1442
1450
|
self,
|
|
1443
1451
|
image_id: str,
|
|
@@ -1551,7 +1559,7 @@ class DataRoomClient:
|
|
|
1551
1559
|
"coca_embedding": vector,
|
|
1552
1560
|
},
|
|
1553
1561
|
)
|
|
1554
|
-
|
|
1562
|
+
|
|
1555
1563
|
async def aggregate_images(self, field, type) -> dict:
|
|
1556
1564
|
"""
|
|
1557
1565
|
Performs an aggregation operation on a specified field across all images.
|
|
@@ -1568,7 +1576,7 @@ class DataRoomClient:
|
|
|
1568
1576
|
"type": type,
|
|
1569
1577
|
},
|
|
1570
1578
|
)
|
|
1571
|
-
|
|
1579
|
+
|
|
1572
1580
|
async def bucket_images(self, field, size) -> list[dict]:
|
|
1573
1581
|
"""
|
|
1574
1582
|
Groups images into buckets based on a specified field and bucket size.
|
|
@@ -1694,7 +1702,7 @@ class DataRoomClient:
|
|
|
1694
1702
|
"description": description if description else "",
|
|
1695
1703
|
},
|
|
1696
1704
|
)
|
|
1697
|
-
|
|
1705
|
+
|
|
1698
1706
|
async def freeze_dataset(self, slug_version: str) -> dict:
|
|
1699
1707
|
"""
|
|
1700
1708
|
Freezes a dataset version, making it immutable.
|
|
@@ -1706,7 +1714,7 @@ class DataRoomClient:
|
|
|
1706
1714
|
url=f"datasets/{slug_version}/freeze/",
|
|
1707
1715
|
method="POST",
|
|
1708
1716
|
)
|
|
1709
|
-
|
|
1717
|
+
|
|
1710
1718
|
async def unfreeze_dataset(self, slug_version: str) -> dict:
|
|
1711
1719
|
"""
|
|
1712
1720
|
Unfreezes a dataset version, making it mutable again.
|
|
@@ -1810,10 +1818,10 @@ class AsyncRunner:
|
|
|
1810
1818
|
logger.debug("Shutting down ClassAsyncRunner background thread...")
|
|
1811
1819
|
cls._loop.call_soon_threadsafe(cls._loop.stop)
|
|
1812
1820
|
# It's good practice to have a timeout on join
|
|
1813
|
-
cls._thread.join(timeout=5)
|
|
1821
|
+
cls._thread.join(timeout=5)
|
|
1814
1822
|
cls._loop.close()
|
|
1815
1823
|
logger.debug("ClassAsyncRunner has been shut down.")
|
|
1816
|
-
|
|
1824
|
+
|
|
1817
1825
|
cls._loop = None
|
|
1818
1826
|
cls._thread = None
|
|
1819
1827
|
|
|
File without changes
|
{dataroom_client-1.0.2.post1.dev0 → dataroom_client-1.0.3.post11.dev0}/dataroom_client/__init__.py
RENAMED
|
File without changes
|
{dataroom_client-1.0.2.post1.dev0 → dataroom_client-1.0.3.post11.dev0}/dataroom_client/counter.py
RENAMED
|
File without changes
|
{dataroom_client-1.0.2.post1.dev0 → dataroom_client-1.0.3.post11.dev0}/dataroom_client/loader.py
RENAMED
|
File without changes
|
|
File without changes
|