Skip to content

Commit ab7747f

Browse files
committed
add support for listing autotags
1 parent 1a743e3 commit ab7747f

File tree

4 files changed

+28
-5
lines changed

4 files changed

+28
-5
lines changed

nucleus/__init__.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@
103103
DATASET_LENGTH_KEY,
104104
NAME_KEY,
105105
ANNOTATIONS_KEY,
106+
AUTOTAGS_KEY,
106107
)
107108
from .model import Model
108109
from .errors import (
@@ -838,6 +839,19 @@ def delete_slice(self, slice_id: str) -> dict:
838839
)
839840
return response
840841

842+
def list_autotags(self, dataset_id: str) -> List[str]:
843+
"""
844+
Fetches a list of autotags for a given dataset id
845+
:param dataset_id: internally controlled dataset_id
846+
:return: List[str] representing autotag_ids
847+
"""
848+
response = self._make_request(
849+
{},
850+
f"{dataset_id}/list_autotags",
851+
requests_command=requests.get,
852+
)
853+
return response[AUTOTAGS_KEY] if AUTOTAGS_KEY in response else response
854+
841855
def _make_grequest(
842856
self,
843857
payload: dict,

nucleus/constants.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
NUCLEUS_ENDPOINT = "https://api.scale.com/v1/nucleus"
1+
# NUCLEUS_ENDPOINT = "https://api.scale.com/v1/nucleus"
2+
NUCLEUS_ENDPOINT = "http://localhost:3000/v1/nucleus"
23
ITEMS_KEY = "items"
34
ITEM_KEY = "item"
45
REFERENCE_ID_KEY = "reference_id"
@@ -42,3 +43,4 @@
4243
BOX_TYPE = "box"
4344
POLYGON_TYPE = "polygon"
4445
GEOMETRY_KEY = "geometry"
46+
AUTOTAGS_KEY = "autotags"

nucleus/dataset.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,9 @@ def delete_item(self, item_id: str = None, reference_id: str = None):
221221
self.id, reference_id=reference_id, item_id=item_id
222222
)
223223

224+
def list_autotags(self):
225+
return self._client.list_autotags(self.id)
226+
224227
def _format_dataset_item_response(self, response: dict) -> dict:
225228
item = response.get(ITEM_KEY, None)
226229
annotation_payload = response.get(ANNOTATIONS_KEY, [])

nucleus/slice.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
from typing import List, Dict, Any
2-
from .constants import DATASET_ITEM_ID_KEY, REFERENCE_IDS_KEY
2+
from .constants import (
3+
DATASET_ITEM_ID_KEY,
4+
REFERENCE_IDS_KEY,
5+
DATASET_ITEM_IDS_KEY,
6+
)
37

48

59
class Slice:
@@ -29,9 +33,9 @@ def info(self, id_type: str = DATASET_ITEM_ID_KEY) -> dict:
2933
return self._client.slice_info(self.slice_id, id_type)
3034

3135
def append(
32-
self,
36+
self,
3337
dataset_item_ids: List[str] = None,
34-
reference_ids: List[str] = None
38+
reference_ids: List[str] = None,
3539
) -> dict:
3640
"""
3741
Appends to a slice from items already present in a dataset.
@@ -61,4 +65,4 @@ def append(
6165
response = self._client._make_request(
6266
payload, f"slice/{self.slice_id}/append"
6367
)
64-
return response
68+
return response

0 commit comments

Comments
 (0)