2121from labelbox .schema .invite import Invite
2222from labelbox .schema .user import User
2323from labelbox import OntologyBuilder , Tool
24+ from labelbox .schema .annotation_import import LabelImport
2425
2526IMG_URL = "https://picsum.photos/200/300"
2627
@@ -298,37 +299,7 @@ def configured_project(project, client, rand_gen, image_url):
298299
299300
300301@pytest .fixture
301- def annotation_submit_fn (client ):
302-
303- def submit (project_id , data_row_id ):
304- feature_result = client .execute (
305- """query featuresPyApi ($project_id : ID!, $datarow_id: ID!
306- ) {project(where: { id: $project_id }) {
307- featuresForDataRow(where: {dataRow: { id: $datarow_id }}) {id}}}
308- """ , {
309- "project_id" : project_id ,
310- "datarow_id" : data_row_id
311- })
312- features = feature_result ['project' ]['featuresForDataRow' ]
313- feature_ids = [feature ['id' ] for feature in features ]
314- res = client .execute (
315- """mutation createLabelPyApi ($project_id : ID!,$datarow_id: ID!,$feature_ids: [ID!]!,$time_seconds : Float!) {
316- createLabelFromFeatures(data: {dataRow: { id: $datarow_id },project: { id: $project_id },
317- featureIds: $feature_ids,secondsSpent: $time_seconds}) {id}}""" ,
318- {
319- "project_id" : project_id ,
320- "datarow_id" : data_row_id ,
321- "feature_ids" : feature_ids ,
322- "time_seconds" : 10
323- })
324- return res ['createLabelFromFeatures' ]['id' ]
325-
326- return submit
327-
328-
329- @pytest .fixture
330- def configured_project_with_label (client , rand_gen , annotation_submit_fn ,
331- image_url ):
302+ def configured_project_with_label (client , rand_gen , image_url ):
332303 project = client .create_project (name = rand_gen (str ))
333304 dataset = client .create_dataset (name = rand_gen (str ), projects = project )
334305 data_row = dataset .create_data_row (row_data = image_url )
@@ -355,10 +326,10 @@ def configured_project_with_label(client, rand_gen, annotation_submit_fn,
355326 "width" : 50
356327 }
357328 }]
358- upload_task = MALPredictionImport .create_from_objects (
359- client , project .uid , f'mal -import-{ uuid .uuid4 ()} ' , predictions )
329+ upload_task = LabelImport .create_from_objects (
330+ client , project .uid , f'label -import-{ uuid .uuid4 ()} ' , predictions )
360331 upload_task .wait_until_done ()
361- labels = annotation_submit_fn ( project .uid , data_row . uid )
332+ labels = [ label .uid for label in project . labels ()][ 0 ]
362333 time .sleep (3 )
363334 yield [project , labels ]
364335 dataset .delete ()
0 commit comments