File tree Expand file tree Collapse file tree 3 files changed +58
-1
lines changed Expand file tree Collapse file tree 3 files changed +58
-1
lines changed Original file line number Diff line number Diff line change 21
21
ANNOTATION_UPDATE_KEY = "update"
22
22
DEFAULT_ANNOTATION_UPDATE_MODE = False
23
23
STATUS_CODE_KEY = "status_code"
24
- SUCCESS_STATUS_CODES = [200 , 201 ]
24
+ STATUS_KEY = "status"
25
+ SUCCESS_STATUS_CODES = [200 , 201 , 202 ]
25
26
ERRORS_KEY = "errors"
26
27
MODEL_RUN_ID_KEY = "model_run_id"
27
28
MODEL_ID_KEY = "model_id"
57
58
INDEX_KEY = "index"
58
59
SEGMENTATIONS_KEY = "segmentations"
59
60
EMBEDDINGS_URL_KEY = "embeddings_url"
61
+ JOB_ID_KEY = "job_id"
62
+ MESSAGE_KEY = "message"
Original file line number Diff line number Diff line change @@ -120,6 +120,7 @@ def reference_id_from_url(url):
120
120
for i in range (len (TEST_POLYGON_ANNOTATIONS ))
121
121
]
122
122
123
+ TEST_INDEX_EMBEDDINGS_FILE = "https://scale-ml.s3.amazonaws.com/tmp/sasha/pytest_embeddings_payload.json"
123
124
124
125
# Asserts that a box annotation instance matches a dict representing its properties.
125
126
# Useful to check annotation uploads/updates match.
Original file line number Diff line number Diff line change
1
+ import pytest
2
+
3
+ from helpers import (
4
+ get_signed_url ,
5
+ TEST_INDEX_EMBEDDINGS_FILE ,
6
+ TEST_IMG_URLS ,
7
+ TEST_DATASET_NAME ,
8
+ reference_id_from_url ,
9
+ )
10
+
11
+ from nucleus import DatasetItem
12
+
13
+ from nucleus .constants import (
14
+ ERROR_PAYLOAD ,
15
+ JOB_ID_KEY ,
16
+ MESSAGE_KEY ,
17
+ STATUS_KEY ,
18
+ )
19
+
20
+
21
+ @pytest .fixture ()
22
+ def dataset (CLIENT ):
23
+ ds = CLIENT .create_dataset (TEST_DATASET_NAME )
24
+ ds_items = []
25
+ for url in TEST_IMG_URLS :
26
+ ds_items .append (
27
+ DatasetItem (
28
+ image_location = url ,
29
+ reference_id = reference_id_from_url (url ),
30
+ )
31
+ )
32
+
33
+ response = ds .append (ds_items )
34
+ assert ERROR_PAYLOAD not in response .json ()
35
+ yield ds
36
+
37
+ response = CLIENT .delete_dataset (ds .id )
38
+ assert response == {}
39
+
40
+
41
+ def test_index_integration (dataset ):
42
+ signed_embeddings_url = get_signed_url (TEST_INDEX_EMBEDDINGS_FILE )
43
+ create_response = dataset .create_custom_index (signed_embeddings_url )
44
+ assert JOB_ID_KEY in create_response
45
+ assert MESSAGE_KEY in create_response
46
+ job_id = create_response [JOB_ID_KEY ]
47
+
48
+ # Job can error because pytest dataset fixture gets deleted
49
+ # As a workaround, we'll just check htat we got some response
50
+ job_status_response = dataset .check_index_status (job_id )
51
+ assert STATUS_KEY in job_status_response
52
+ assert JOB_ID_KEY in job_status_response
53
+ assert MESSAGE_KEY in job_status_response
You can’t perform that action at this time.
0 commit comments