Skip to content

Commit 4c9f544

Browse files
committed
add integration test for send to labeling
1 parent 632f8aa commit 4c9f544

File tree

3 files changed

+32
-1
lines changed

3 files changed

+32
-1
lines changed

nucleus/slice.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from nucleus.dataset_item import DatasetItem
33
from nucleus.annotation import Annotation
44
from nucleus.utils import format_dataset_item_response
5+
from nucleus.job import AsyncJob
56

67
from .constants import DEFAULT_ANNOTATION_UPDATE_MODE
78

@@ -146,9 +147,10 @@ def annotate(
146147
)
147148

148149
def send_to_labeling(self, project_id: str):
149-
return self._client.make_request(
150+
response = self._client.make_request(
150151
{}, f"slice/{self.slice_id}/{project_id}/send_to_labeling"
151152
)
153+
return AsyncJob(response["job_id"], self._client)
152154

153155

154156
def check_annotations_are_in_slice(

tests/helpers.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
TEST_MODEL_RUN = "[PyTest] Test Model Run"
1111
TEST_DATASET_NAME = "[PyTest] Test Dataset"
1212
TEST_SLICE_NAME = "[PyTest] Test Slice"
13+
TEST_PROJECT_ID = "60b699d70f139e002dd31bfc"
1314

1415

1516
TEST_IMG_URLS = [

tests/test_slice.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@
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)

0 commit comments

Comments
 (0)