Skip to content

Commit 3ccf31e

Browse files
author
Ubuntu
committed
Clean up some missing stuff and docstrings
1 parent efe3247 commit 3ccf31e

File tree

3 files changed

+13
-83
lines changed

3 files changed

+13
-83
lines changed

nucleus/__init__.py

Lines changed: 10 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,7 @@
11
"""
22
Nucleus Python Library.
33
4-
Data formats used:
5-
6-
_____________________________________________________________________________________________________
7-
8-
DatasetItem
9-
10-
image_url | str | The URL containing the image for the given row of data.\n
11-
reference_id | str | An optional user-specified identifier to reference this given image.\n
12-
metadata | dict | All of column definitions for this item.
13-
| | The keys should match the user-specified column names,
14-
| | and the corresponding values will populate the cell under the column.\n
15-
_____________________________________________________________________________________________________
16-
17-
18-
Box2DGeometry:
19-
20-
x | float | The distance, in pixels, between the left border of the bounding box
21-
| | and the left border of the image.\n
22-
y | float | The distance, in pixels, between the top border of the bounding box
23-
| | and the top border of the image.\n
24-
width | float | The width in pixels of the annotation.\n
25-
height | float | The height in pixels of the annotation.\n
26-
27-
Box2DAnnotation:
28-
29-
item_id | str | The internally-controlled item identifier to associate this annotation with.
30-
| | The reference_id field should be empty if this field is populated.\n
31-
reference_id | str | The user-specified reference identifier to associate this annotation with.\n
32-
| | The item_id field should be empty if this field is populated.
33-
label | str | The label for this annotation (e.g. car, pedestrian, bicycle).\n
34-
type | str | The type of this annotation. It should always be the box string literal.\n
35-
geometry | dict | Representation of the bounding box in the Box2DGeometry format.\n
36-
metadata | dict | An arbitrary metadata blob for the annotation.\n
37-
38-
_____________________________________________________________________________________________________
39-
40-
Box2DDetection:
41-
42-
item_id | str | The internally-controlled item identifier to associate this annotation with.
43-
| | The reference_id field should be empty if this field is populated.\n
44-
reference_id | str | The user-specified reference identifier to associate this annotation with.
45-
| | The item_id field should be empty if this field is populated.\n
46-
label | str | The label for this annotation (e.g. car, pedestrian, bicycle).\n
47-
type | str | The type of this annotation. It should always be the box string literal.\n
48-
confidence | float | The optional confidence level of this annotation.
49-
| | It should be between 0 and 1 (inclusive).\n
50-
geometry | dict | Representation of the bounding box in the Box2DGeometry format.\n
51-
metadata | dict | An arbitrary metadata blob for the annotation.\n
4+
For full documentation see: https://dashboard.scale.com/nucleus/docs/api?language=python
525
"""
536
import asyncio
547
import json
@@ -244,11 +197,8 @@ def get_dataset_items(self, dataset_id) -> List[DatasetItem]:
244197
for item in dataset_items:
245198
image_url = item.get("original_image_url")
246199
metadata = item.get("metadata", None)
247-
item_id = item.get("id", None)
248200
ref_id = item.get("ref_id", None)
249-
dataset_item = DatasetItem(
250-
image_url, ref_id, item_id, metadata
251-
)
201+
dataset_item = DatasetItem(image_url, ref_id, metadata)
252202
constructed_dataset_items.append(dataset_item)
253203
elif error:
254204
raise DatasetItemRetrievalError(message=error)
@@ -349,26 +299,19 @@ def delete_dataset(self, dataset_id: str) -> dict:
349299
return self.make_request({}, f"dataset/{dataset_id}", requests.delete)
350300

351301
@sanitize_string_args
352-
def delete_dataset_item(
353-
self, dataset_id: str, item_id: str = None, reference_id: str = None
354-
) -> dict:
302+
def delete_dataset_item(self, dataset_id: str, reference_id) -> dict:
355303
"""
356304
Deletes a private dataset based on datasetId.
357305
Returns an empty payload where response status `200` indicates
358306
the dataset has been successfully deleted.
359307
:param payload: { "name": str }
360308
:return: { "dataset_id": str, "name": str }
361309
"""
362-
if item_id:
363-
return self.make_request(
364-
{}, f"dataset/{dataset_id}/{item_id}", requests.delete
365-
)
366-
else: # Assume reference_id is provided
367-
return self.make_request(
368-
{},
369-
f"dataset/{dataset_id}/refloc/{reference_id}",
370-
requests.delete,
371-
)
310+
return self.make_request(
311+
{},
312+
f"dataset/{dataset_id}/refloc/{reference_id}",
313+
requests.delete,
314+
)
372315

373316
def populate_dataset(
374317
self,
@@ -1015,17 +958,13 @@ def create_slice(self, dataset_id: str, payload: dict) -> Slice:
1015958
as a means of identifying items in the dataset.
1016959
1017960
"name" -- The human-readable name of the slice.
1018-
1019-
"dataset_item_ids" -- An optional list of dataset item ids for the items in the slice
1020-
1021961
"reference_ids" -- An optional list of user-specified identifier for the items in the slice
1022962
1023963
:param
1024964
dataset_id: id of the dataset
1025965
payload:
1026966
{
1027967
"name": str,
1028-
"dataset_item_ids": List[str],
1029968
"reference_ids": List[str],
1030969
}
1031970
:return: new Slice object
@@ -1051,14 +990,12 @@ def slice_info(self, slice_id: str) -> dict:
1051990
1052991
:param
1053992
slice_id: id of the slice
1054-
id_type: the type of IDs you want in response (either "reference_id" or "dataset_item_id")
1055-
to identify the DatasetItems
1056993
1057994
:return:
1058995
{
1059996
"name": str,
1060997
"dataset_id": str,
1061-
"dataset_item_ids": List[str],
998+
"reference_ids": List[str],
1062999
}
10631000
"""
10641001
response = self.make_request(
@@ -1118,7 +1055,6 @@ def append_to_slice(
11181055
as a means of identifying items in the dataset.
11191056
11201057
:param
1121-
dataset_item_ids: List[str],
11221058
reference_ids: List[str],
11231059
11241060
:return:
@@ -1182,7 +1118,7 @@ def create_custom_index(
11821118
11831119
:param
11841120
dataset_id: id of dataset that the custom index is being added to.
1185-
embeddings_urls: list of urls, each of which being a json mapping dataset_item_id -> embedding vector
1121+
embeddings_urls: list of urls, each of which being a json mapping reference_id -> embedding vector
11861122
embedding_dim: the dimension of the embedding vectors, must be consistent for all embedding vectors in the index.
11871123
"""
11881124
return self.make_request(

nucleus/dataset.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -360,22 +360,17 @@ def create_slice(
360360
as a means of identifying items in the dataset.
361361
362362
:param name: The human-readable name of the slice.
363-
:param dataset_item_ids: An optional list of dataset item ids for the items in the slice
364-
:param reference_ids: An optional list of user-specified identifier for the items in the slice
363+
:param reference_ids: A list of user-specified identifier for the items in the slice
365364
366365
:return: new Slice object
367366
"""
368367
return self._client.create_slice(
369368
self.id, {NAME_KEY: name, REFERENCE_IDS_KEY: reference_ids}
370369
)
371370

372-
def delete_item(self, item_id: str = None, reference_id: str = None):
373-
if bool(item_id) == bool(reference_id):
374-
raise Exception(
375-
"You must specify either a reference_id or an item_id for a DatasetItem."
376-
)
371+
def delete_item(self, reference_id: str):
377372
return self._client.delete_dataset_item(
378-
self.id, reference_id=reference_id, item_id=item_id
373+
self.id, reference_id=reference_id
379374
)
380375

381376
def list_autotags(self):

nucleus/slice.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ def append(
6262
as a means of identifying items in the dataset.
6363
6464
:param
65-
dataset_item_ids: List[str],
6665
reference_ids: List[str],
6766
6867
:return:

0 commit comments

Comments
 (0)