File tree Expand file tree Collapse file tree 3 files changed +36
-0
lines changed Expand file tree Collapse file tree 3 files changed +36
-0
lines changed Original file line number Diff line number Diff line change 22from nucleus .dataset_item import DatasetItem
33from nucleus .annotation import Annotation
44from nucleus .utils import format_dataset_item_response
5+ from nucleus .job import AsyncJob
56
67from .constants import DEFAULT_ANNOTATION_UPDATE_MODE
78
@@ -145,6 +146,12 @@ def annotate(
145146 batch_size = batch_size ,
146147 )
147148
149+ def send_to_labeling (self , project_id : str ):
150+ response = self ._client .make_request (
151+ {}, f"slice/{ self .slice_id } /{ project_id } /send_to_labeling"
152+ )
153+ return AsyncJob (response ["job_id" ], self ._client )
154+
148155
149156def check_annotations_are_in_slice (
150157 annotations : List [Annotation ], slice_to_check : Slice
Original file line number Diff line number Diff line change 1010TEST_MODEL_RUN = "[PyTest] Test Model Run"
1111TEST_DATASET_NAME = "[PyTest] Test Dataset"
1212TEST_SLICE_NAME = "[PyTest] Test Slice"
13+ TEST_PROJECT_ID = "60b699d70f139e002dd31bfc"
1314
1415
1516TEST_IMG_URLS = [
Original file line number Diff line number Diff line change 66 TEST_IMG_URLS ,
77 TEST_SLICE_NAME ,
88 TEST_BOX_ANNOTATIONS ,
9+ TEST_PROJECT_ID ,
910 reference_id_from_url ,
1011)
12+ from nucleus .job import AsyncJob
1113
1214
1315@pytest .fixture ()
@@ -141,3 +143,29 @@ def sort_by_reference_id(items):
141143 assert sort_by_reference_id (all_stored_items ) == sort_by_reference_id (
142144 ds_items [:3 ]
143145 )
146+
147+
148+ def test_slice_send_to_labeling (dataset ):
149+ # Dataset upload
150+ ds_items = []
151+ for url in TEST_IMG_URLS :
152+ ds_items .append (
153+ DatasetItem (
154+ image_location = url ,
155+ reference_id = reference_id_from_url (url ),
156+ )
157+ )
158+ response = dataset .append (ds_items )
159+ assert ERROR_PAYLOAD not in response .json ()
160+
161+ # Slice creation
162+ slc = dataset .create_slice (
163+ name = TEST_SLICE_NAME ,
164+ reference_ids = [ds_items [0 ].reference_id , ds_items [1 ].reference_id ],
165+ )
166+
167+ response = slc .info ()
168+ assert len (response ["dataset_items" ]) == 2
169+
170+ response = slc .send_to_labeling (TEST_PROJECT_ID )
171+ assert isinstance (response , AsyncJob )
You can’t perform that action at this time.
0 commit comments