|
20 | 20 | from labelbox.pagination import PaginatedCollection
|
21 | 21 | from labelbox.schema.invite import Invite
|
22 | 22 | from labelbox.schema.user import User
|
23 |
| -from labelbox import OntologyBuilder, Tool |
| 23 | +from labelbox import OntologyBuilder, Tool, Option, Classification |
24 | 24 | from labelbox.schema.annotation_import import LabelImport
|
25 | 25 |
|
26 | 26 | IMG_URL = "https://picsum.photos/200/300"
|
@@ -333,3 +333,55 @@ def configured_project_with_label(client, rand_gen, image_url):
|
333 | 333 | yield [project, label]
|
334 | 334 | dataset.delete()
|
335 | 335 | project.delete()
|
| 336 | + |
| 337 | + |
| 338 | +@pytest.fixture |
| 339 | +def configured_project_with_complex_ontology(client, rand_gen, image_url): |
| 340 | + project = client.create_project(name=rand_gen(str)) |
| 341 | + dataset = client.create_dataset(name=rand_gen(str), projects=project) |
| 342 | + data_row = dataset.create_data_row(row_data=image_url) |
| 343 | + editor = list( |
| 344 | + project.client.get_labeling_frontends( |
| 345 | + where=LabelingFrontend.name == "editor"))[0] |
| 346 | + |
| 347 | + ontology = OntologyBuilder() |
| 348 | + tools = [ |
| 349 | + Tool(tool=Tool.Type.BBOX, name="test-bbox-class"), |
| 350 | + Tool(tool=Tool.Type.LINE, name="test-line-class"), |
| 351 | + Tool(tool=Tool.Type.POINT, name="test-point-class"), |
| 352 | + Tool(tool=Tool.Type.POLYGON, name="test-polygon-class"), |
| 353 | + Tool(tool=Tool.Type.NER, name="test-ner-class") |
| 354 | + ] |
| 355 | + |
| 356 | + options = [ |
| 357 | + Option(value="first option answer"), |
| 358 | + Option(value="second option answer"), |
| 359 | + Option(value="third option answer") |
| 360 | + ] |
| 361 | + |
| 362 | + classifications = [ |
| 363 | + Classification(class_type=Classification.Type.TEXT, |
| 364 | + instructions="test-text-class"), |
| 365 | + Classification(class_type=Classification.Type.DROPDOWN, |
| 366 | + instructions="test-dropdown-class", |
| 367 | + options=options), |
| 368 | + Classification(class_type=Classification.Type.RADIO, |
| 369 | + instructions="test-radio-class", |
| 370 | + options=options), |
| 371 | + Classification(class_type=Classification.Type.CHECKLIST, |
| 372 | + instructions="test-checklist-class", |
| 373 | + options=options) |
| 374 | + ] |
| 375 | + |
| 376 | + for t in tools: |
| 377 | + for c in classifications: |
| 378 | + t.add_classification(c) |
| 379 | + ontology.add_tool(t) |
| 380 | + for c in classifications: |
| 381 | + ontology.add_classification(c) |
| 382 | + |
| 383 | + project.setup(editor, ontology.asdict()) |
| 384 | + |
| 385 | + yield [project, data_row] |
| 386 | + dataset.delete() |
| 387 | + project.delete() |
0 commit comments