4
4
TEST_DATASET_NAME ,
5
5
TEST_MODEL_NAME ,
6
6
TEST_MODEL_REFERENCE ,
7
+ TEST_MODEL_RUN ,
7
8
TEST_IMG_URLS ,
8
9
TEST_BOX_PREDICTIONS ,
9
10
TEST_POLYGON_PREDICTIONS ,
16
17
from nucleus .constants import ERROR_PAYLOAD
17
18
18
19
@pytest .fixture ()
19
- def dataset (CLIENT ):
20
+ def model_run (CLIENT ):
20
21
ds = CLIENT .create_dataset (TEST_DATASET_NAME )
21
22
ds_items = []
22
23
for url in TEST_IMG_URLS :
@@ -30,46 +31,48 @@ def dataset(CLIENT):
30
31
31
32
model = CLIENT .add_model (
32
33
name = TEST_MODEL_NAME ,
33
- reference_id = TEST_MODEL_NAME
34
+ reference_id = TEST_MODEL_REFERENCE
34
35
)
35
36
37
+ run = model .create_run (
38
+ name = TEST_MODEL_RUN ,
39
+ dataset = ds ,
40
+ predictions = [])
36
41
37
- yield ds
42
+ yield run
38
43
39
44
response = CLIENT .delete_dataset (ds .id )
40
45
assert response == {}
46
+ response = CLIENT .delete_model (model .id )
47
+ assert response == {}
41
48
42
-
43
- def test_box_pred_upload (dataset ):
49
+ def test_box_pred_upload (model_run ):
44
50
prediction = BoxPrediction (** TEST_BOX_PREDICTIONS [0 ])
45
- response = dataset . annotate ( predictions = [prediction ])
51
+ response = model_run . predict ( annotations = [prediction ])
46
52
47
- assert response ['dataset_id ' ] == dataset . id
53
+ assert response ['model_run_id ' ] == model_run . model_run_id
48
54
assert response ['predictions_processed' ] == 1
49
55
50
- response = dataset .refloc (prediction .reference_id )[ 'predictions' ]
56
+ response = model_run .refloc (prediction .reference_id )
51
57
assert len (response ) == 1
52
- response_prediction = response [0 ]
53
- assert_box_prediction_matches_dict (response_prediction , TEST_BOX_PREDICTIONS [0 ])
58
+ assert_box_prediction_matches_dict (response [0 ], TEST_BOX_PREDICTIONS [0 ])
54
59
55
60
56
- def test_polygon_pred_upload (dataset ):
61
+ def test_polygon_pred_upload (model_run ):
57
62
prediction = PolygonPrediction (** TEST_POLYGON_PREDICTIONS [0 ])
58
- response = dataset . annotate ( predictions = [prediction ])
63
+ response = model_run . predict ( annotations = [prediction ])
59
64
60
- assert response ['dataset_id ' ] == dataset . id
65
+ assert response ['model_run_id ' ] == model_run . model_run_id
61
66
assert response ['predictions_processed' ] == 1
62
67
63
- response = dataset .refloc (prediction .reference_id )[ 'predictions' ]
68
+ response = model_run .refloc (prediction .reference_id )
64
69
assert len (response ) == 1
65
- response_prediction = response [0 ]
66
- print (response_prediction )
67
- assert_polygon_prediction_matches_dict (response_prediction , TEST_POLYGON_PREDICTIONS [0 ])
70
+ assert_polygon_prediction_matches_dict (response [0 ], TEST_POLYGON_PREDICTIONS [0 ])
68
71
69
72
70
- def test_box_pred_upload_update (dataset ):
73
+ def test_box_pred_upload_update (model_run ):
71
74
prediction = BoxPrediction (** TEST_BOX_PREDICTIONS [0 ])
72
- response = dataset . annotate ( predictions = [prediction ])
75
+ response = model_run . predict ( annotations = [prediction ])
73
76
74
77
assert response ['predictions_processed' ] == 1
75
78
@@ -79,19 +82,18 @@ def test_box_pred_upload_update(dataset):
79
82
prediction_update_params ['reference_id' ] = TEST_BOX_PREDICTIONS [0 ]['reference_id' ]
80
83
81
84
prediction_update = BoxPrediction (** prediction_update_params )
82
- response = dataset . annotate ( predictions = [prediction_update ], update = True )
85
+ response = model_run . predict ( annotations = [prediction_update ], update = True )
83
86
84
87
assert response ['predictions_processed' ] == 1
85
88
86
- response = dataset .refloc (prediction .reference_id )[ 'predictions' ]
89
+ response = model_run .refloc (prediction .reference_id )
87
90
assert len (response ) == 1
88
- response_prediction = response [0 ]
89
- assert_box_prediction_matches_dict (response_prediction , prediction_update_params )
91
+ assert_box_prediction_matches_dict (response [0 ], prediction_update_params )
90
92
91
93
92
- def test_box_pred_upload_ignore (dataset ):
94
+ def test_box_pred_upload_ignore (model_run ):
93
95
prediction = BoxPrediction (** TEST_BOX_PREDICTIONS [0 ])
94
- response = dataset . annotate ( predictions = [prediction ])
96
+ response = model_run . predict ( annotations = [prediction ])
95
97
96
98
assert response ['predictions_processed' ] == 1
97
99
@@ -101,19 +103,18 @@ def test_box_pred_upload_ignore(dataset):
101
103
prediction_update_params ['reference_id' ] = TEST_BOX_PREDICTIONS [0 ]['reference_id' ]
102
104
prediction_update = BoxPrediction (** prediction_update_params )
103
105
# Default behavior is ignore.
104
- response = dataset . annotate ( predictions = [prediction_update ])
106
+ response = model_run . predict ( annotations = [prediction_update ])
105
107
106
108
assert response ['predictions_processed' ] == 1
107
109
108
- response = dataset .refloc (prediction .reference_id )[ 'predictions' ]
110
+ response = model_run .refloc (prediction .reference_id )
109
111
assert len (response ) == 1
110
- response_prediction = response [0 ]
111
- assert_box_prediction_matches_dict (response_prediction , TEST_BOX_PREDICTIONS [0 ])
112
+ assert_box_prediction_matches_dict (response [0 ], TEST_BOX_PREDICTIONS [0 ])
112
113
113
114
114
- def test_polygon_pred_upload_update (dataset ):
115
+ def test_polygon_pred_upload_update (model_run ):
115
116
prediction = PolygonPrediction (** TEST_POLYGON_PREDICTIONS [0 ])
116
- response = dataset . annotate ( predictions = [prediction ])
117
+ response = model_run . predict ( annotations = [prediction ])
117
118
118
119
assert response ['predictions_processed' ] == 1
119
120
@@ -123,19 +124,18 @@ def test_polygon_pred_upload_update(dataset):
123
124
prediction_update_params ['reference_id' ] = TEST_POLYGON_PREDICTIONS [0 ]['reference_id' ]
124
125
125
126
prediction_update = PolygonPrediction (** prediction_update_params )
126
- response = dataset . annotate ( predictions = [prediction_update ], update = True )
127
+ response = model_run . predict ( annotations = [prediction_update ], update = True )
127
128
128
129
assert response ['predictions_processed' ] == 1
129
130
130
- response = dataset .refloc (prediction .reference_id )[ 'predictions' ]
131
+ response = model_run .refloc (prediction .reference_id )
131
132
assert len (response ) == 1
132
- response_prediction = response [0 ]
133
- assert_polygon_prediction_matches_dict (response_prediction , prediction_update_params )
133
+ assert_polygon_prediction_matches_dict (response [0 ], prediction_update_params )
134
134
135
135
136
- def test_polygon_pred_upload_ignore (dataset ):
136
+ def test_polygon_pred_upload_ignore (model_run ):
137
137
prediction = PolygonPrediction (** TEST_POLYGON_PREDICTIONS [0 ])
138
- response = dataset . annotate ( predictions = [prediction ])
138
+ response = model_run . predict ( annotations = [prediction ])
139
139
140
140
assert response ['predictions_processed' ] == 1
141
141
@@ -146,11 +146,10 @@ def test_polygon_pred_upload_ignore(dataset):
146
146
147
147
prediction_update = PolygonPrediction (** prediction_update_params )
148
148
# Default behavior is ignore.
149
- response = dataset . annotate ( predictions = [prediction_update ])
149
+ response = model_run . predict ( annotations = [prediction_update ])
150
150
151
151
assert response ['predictions_processed' ] == 1
152
152
153
- response = dataset .refloc (prediction .reference_id )[ 'predictions' ]
153
+ response = model_run .refloc (prediction .reference_id )
154
154
assert len (response ) == 1
155
- response_prediction = response [0 ]
156
- assert_polygon_prediction_matches_dict (response_prediction , TEST_POLYGON_PREDICTIONS [0 ])
155
+ assert_polygon_prediction_matches_dict (response [0 ], TEST_POLYGON_PREDICTIONS [0 ])
0 commit comments