Skip to content

Commit 6f67194

Browse files
committed
update to all tests that used annotation_submit_fn
1 parent 86cd19c commit 6f67194

File tree

2 files changed

+9
-42
lines changed

2 files changed

+9
-42
lines changed

tests/integration/annotation_import/conftest.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
from typing import Type
99
from labelbox.schema.labeling_frontend import LabelingFrontend
10-
from labelbox.schema.annotation_import import MALPredictionImport, AnnotationImportState
10+
from labelbox.schema.annotation_import import LabelImport, MALPredictionImport, AnnotationImportState
1111

1212

1313
@pytest.fixture
@@ -327,18 +327,14 @@ def model_run(rand_gen, model):
327327

328328
@pytest.fixture
329329
def model_run_with_model_run_data_rows(client, configured_project,
330-
annotation_submit_fn,
331330
model_run_predictions, model_run):
332331
configured_project.enable_model_assisted_labeling()
333332

334-
upload_task = MALPredictionImport.create_from_objects(
335-
client, configured_project.uid, f'mal-import-{uuid.uuid4()}',
333+
upload_task = LabelImport.create_from_objects(
334+
client, configured_project.uid, f"label-import-{uuid.uuid4()}",
336335
model_run_predictions)
337336
upload_task.wait_until_done()
338-
label_ids = []
339-
for data_row_id in {x['dataRow']['id'] for x in model_run_predictions}:
340-
label_ids.append(
341-
annotation_submit_fn(configured_project.uid, data_row_id))
337+
label_ids = [label.uid for label in configured_project.labels()]
342338
model_run.upsert_labels(label_ids)
343339
time.sleep(3)
344340
yield model_run

tests/integration/conftest.py

Lines changed: 5 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
from labelbox.schema.invite import Invite
2222
from labelbox.schema.user import User
2323
from labelbox import OntologyBuilder, Tool
24+
from labelbox.schema.annotation_import import LabelImport
2425

2526
IMG_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

Comments
 (0)