88
99from nucleus .annotation import Annotation
1010from nucleus .async_job import AsyncJob , EmbeddingsExportJob
11- from nucleus .constants import EXPORT_FOR_TRAINING_KEY , EXPORTED_ROWS , ITEMS_KEY
11+ from nucleus .constants import (
12+ EXPORT_FOR_TRAINING_KEY ,
13+ EXPORTED_ROWS ,
14+ ITEMS_KEY ,
15+ SLICE_TAGS_KEY ,
16+ )
1217from nucleus .dataset_item import DatasetItem
1318from nucleus .errors import NucleusAPIError
1419from nucleus .prediction import Prediction
@@ -216,6 +221,10 @@ def dataset_id(self):
216221 self ._dataset_id = self .info ()["dataset_id" ]
217222 return self ._dataset_id
218223
224+ @property
225+ def tags (self ):
226+ return self .info ()["tags" ]
227+
219228 @property
220229 def type (self ):
221230 """The type of the Slice."""
@@ -330,6 +339,7 @@ def info(self) -> dict:
330339 "pending_job_count": int
331340 "created_at": datetime
332341 "description": Union[str, None]
342+ "tags":
333343 }
334344 """
335345 info = KeyErrorDict (
@@ -347,6 +357,25 @@ def info(self) -> dict:
347357 self ._description = info ["description" ]
348358 return info
349359
360+ def add_tags (self , tags : List [str ]) -> dict :
361+ """Tag a slice with custom tag names. ::
362+
363+ import nucleus
364+ client = nucleus.NucleusClient("YOUR_SCALE_API_KEY")
365+ slc = client.get_slice("YOUR_SLICE_ID")
366+
367+ slc.add_tags(["tag_1", "tag_1"])
368+
369+ Args:
370+ tags: list of tag names
371+ """
372+ response = self ._client .make_request (
373+ payload = {SLICE_TAGS_KEY : tags },
374+ route = f"slice/{ self .id } /tag" ,
375+ requests_command = requests .post ,
376+ )
377+ return response
378+
350379 def append (
351380 self ,
352381 reference_ids : Optional [List [str ]] = None ,
0 commit comments