Skip to content

Commit cba504b

Browse files
author
Val Brodsky
committed
More fixture support
1 parent 297c142 commit cba504b

File tree

2 files changed

+29
-20
lines changed

2 files changed

+29
-20
lines changed

libs/labelbox/tests/conftest.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -636,20 +636,17 @@ def organization(client):
636636

637637

638638
@pytest.fixture
639-
def configured_project_with_label(
640-
client,
641-
rand_gen,
642-
image_url,
643-
project,
644-
dataset,
645-
data_row,
646-
wait_for_label_processing,
647-
):
639+
def configured_project_with_label(client, rand_gen, dataset, data_row,
640+
wait_for_label_processing, teardown_helpers):
648641
"""Project with a connected dataset, having one datarow
642+
649643
Project contains an ontology with 1 bbox tool
650644
Additionally includes a create_label method for any needed extra labels
651645
One label is already created and yielded when using fixture
652646
"""
647+
project = client.create_project(name=rand_gen(str),
648+
queue_mode=QueueMode.Batch,
649+
media_type=MediaType.Image)
653650
project._wait_until_data_rows_are_processed(
654651
data_row_ids=[data_row.uid],
655652
wait_processing_max_seconds=DATA_ROW_PROCESSING_WAIT_TIMEOUT_SECONDS,
@@ -667,9 +664,7 @@ def configured_project_with_label(
667664
)
668665
yield [project, dataset, data_row, label]
669666

670-
client.delete_unused_ontology(ontology.uid)
671-
for label in project.labels():
672-
label.delete()
667+
teardown_helpers.teardown_project_labels_ontology_feature_schemas(project)
673668

674669

675670
def _create_label(project, data_row, ontology, wait_for_label_processing):
@@ -1187,19 +1182,24 @@ def teardown_project_labels_ontology_feature_schemas(project: Project):
11871182
client = project.client
11881183

11891184
# featureSchemaIds = [tool.feature_schema_id for tool in ontology_builder.tools]
1190-
featureSchemaIds = [
1185+
classification_feature_schema_ids = [
11911186
feature["featureSchemaId"]
11921187
for feature in ontology.normalized["classifications"]
11931188
]
1189+
tool_feature_schema_ids = [
1190+
feature["featureSchemaId"]
1191+
for feature in ontology.normalized["tools"]
1192+
]
11941193

1194+
feature_schema_ids = classification_feature_schema_ids + tool_feature_schema_ids
11951195
labels = list(project.labels())
11961196
for label in labels:
11971197
label.delete()
11981198

11991199
project.delete()
12001200
client.delete_unused_ontology(ontology_id)
1201-
for featureSchemaId in featureSchemaIds:
1202-
project.client.delete_unused_feature_schema(featureSchemaId)
1201+
for feature_schema_id in feature_schema_ids:
1202+
project.client.delete_unused_feature_schema(feature_schema_id)
12031203

12041204

12051205
@pytest.fixture

libs/labelbox/tests/data/annotation_import/test_model_run.py

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,22 @@
77
from labelbox import DataSplit, ModelRun
88

99

10-
@pytest.mark.order(1)
11-
def test_model_run(client, configured_project_with_label, data_row, rand_gen):
10+
@pytest.fixture
11+
def current_model(client, configured_project_with_label, rand_gen):
1212
project, _, _, label = configured_project_with_label
13-
label_id = label.uid
1413
ontology = project.ontology()
15-
data = {"name": rand_gen(str), "ontology_id": ontology.uid}
16-
model = client.create_model(data["name"], data["ontology_id"])
14+
15+
model = client.create_model(rand_gen(str), ontology.uid)
16+
yield model
17+
18+
model.delete()
19+
20+
21+
def test_model_run(client, configured_project_with_label, current_model,
22+
data_row, rand_gen):
23+
_, _, _, label = configured_project_with_label
24+
label_id = label.uid
25+
model = current_model
1726

1827
name = rand_gen(str)
1928
config = {"batch_size": 100, "reruns": None}

0 commit comments

Comments
 (0)