Skip to content

Commit 14f11c4

Browse files
authoredMar 30, 2021
Merge pull request #45 from scaleapi/slice-changes
GET a slice and all the data of each dataset item
2 parents 2ccbf72 + e071afb commit 14f11c4

File tree

4 files changed

+12
-16
lines changed

4 files changed

+12
-16
lines changed
 

‎nucleus/__init__.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -920,7 +920,7 @@ def get_slice(self, slice_id: str) -> Slice:
920920
return Slice(slice_id, self)
921921

922922
def slice_info(
923-
self, slice_id: str, id_type: str = DATASET_ITEM_ID_KEY
923+
self, slice_id: str
924924
) -> dict:
925925
"""
926926
This endpoint provides information about specified slice.
@@ -939,7 +939,7 @@ def slice_info(
939939
"""
940940
response = self._make_request(
941941
{},
942-
f"slice/{slice_id}?idType={id_type}",
942+
f"slice/{slice_id}",
943943
requests_command=requests.get,
944944
)
945945
return response

‎nucleus/slice.py

+3-7
Original file line numberDiff line numberDiff line change
@@ -15,22 +15,18 @@ def __init__(self, slice_id: str, client):
1515
self.slice_id = slice_id
1616
self._client = client
1717

18-
def info(self, id_type: str = DATASET_ITEM_ID_KEY) -> dict:
18+
def info(self) -> dict:
1919
"""
2020
This endpoint provides information about specified slice.
2121
22-
:param
23-
id_type: the type of IDs you want in response (either "reference_id" or "dataset_item_id")
24-
to identify the DatasetItems
25-
2622
:return:
2723
{
2824
"name": str,
2925
"dataset_id": str,
30-
"dataset_item_ids" or "reference_ids": List[str],
26+
"dataset_items",
3127
}
3228
"""
33-
return self._client.slice_info(self.slice_id, id_type)
29+
return self._client.slice_info(self.slice_id)
3430

3531
def append(
3632
self,

‎tests/__init__.py

Whitespace-only changes.

‎tests/test_dataset.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ def test_dataset_list_autotags(CLIENT, dataset):
9191
assert autotag_response == []
9292

9393

94-
def test_slice_create_and_delete(dataset):
94+
def test_slice_create_and_delete_and_list(dataset):
9595
# Dataset upload
9696
ds_items = []
9797
for url in TEST_IMG_URLS:
@@ -114,12 +114,12 @@ def test_slice_create_and_delete(dataset):
114114
assert len(dataset_slices) == 1
115115
assert slc.slice_id == dataset_slices[0]
116116

117-
response = slc.info(id_type="reference_id")
117+
response = slc.info()
118118
assert response["name"] == TEST_SLICE_NAME
119119
assert response["dataset_id"] == dataset.id
120-
assert len(response["reference_ids"]) == 2
120+
assert len(response["dataset_items"]) == 2
121121
for item in ds_items[:2]:
122-
assert item.reference_id in response["reference_ids"]
122+
assert item.reference_id == response["dataset_items"][0]["reference_id"] or item.reference_id == response["dataset_items"][1]["reference_id"]
123123

124124

125125
def test_slice_append(dataset):
@@ -144,7 +144,7 @@ def test_slice_append(dataset):
144144
# Insert duplicate first item
145145
slc.append(reference_ids=[item.reference_id for item in ds_items[:3]])
146146

147-
response = slc.info(id_type="reference_ids")
148-
assert len(response["reference_ids"]) == 3
147+
response = slc.info()
148+
assert len(response["dataset_items"]) == 3
149149
for item in ds_items[:3]:
150-
assert item.reference_id in response["reference_ids"]
150+
assert item.reference_id == response["dataset_items"][0]["reference_id"] or item.reference_id == response["dataset_items"][1]["reference_id"] or item.reference_id == response["dataset_items"][2]["reference_id"]

0 commit comments

Comments
 (0)