Labelbox / labelbox-python

The data factory for next gen AI
https://labelbox.com
Apache License 2.0
115 stars 58 forks source link

Add ornithology to a project using `project.setup_editor(ontology)` fails #1008

Closed mae5357 closed 1 year ago

mae5357 commented 1 year ago

Expected Behavior

Add an ornithology to a project using project.setup_editor(ontology)

Actual Behavior

Function errors out with

---------------------------------------------------------------------------
StopIteration                             Traceback (most recent call last)
Cell In[21], line 12
      8 ontology = client.create_ontology(name=ontology_name,
      9                                   normalized=ontology_normalized_json,
     10                                   media_type=MediaType.Image)
     11 project = client.create_project(name="my_new_project")
---> 12 project.setup_editor(ontology)
     13 print(project.ontology())

File [~/bottega/env/lib/python3.8/site-packages/labelbox/schema/project.py:518](https://vscode-remote+ssh-002dremote-002bmid-002dnon-002dphi.vscode-resource.vscode-cdn.net/fsx/madison/bottega/bottega/annotations/~/bottega/env/lib/python3.8/site-packages/labelbox/schema/project.py:518), in Project.setup_editor(self, ontology)
    515 if self.labeling_frontend() is not None:
    516     raise ResourceConflict("Editor is already set up.")
--> 518 labeling_frontend = next(
    519     self.client.get_labeling_frontends(
    520         where=Entity.LabelingFrontend.name == "Editor"))
    521 self.labeling_frontend.connect(labeling_frontend)
    523 LFO = Entity.LabelingFrontendOptions

File [~/bottega/env/lib/python3.8/site-packages/labelbox/pagination.py:76](https://vscode-remote+ssh-002dremote-002bmid-002dnon-002dphi.vscode-resource.vscode-cdn.net/fsx/madison/bottega/bottega/annotations/~/bottega/env/lib/python3.8/site-packages/labelbox/pagination.py:76), in PaginatedCollection.__next__(self)
     74     self._data.extend(page_data)
     75     if len(page_data) == 0:
---> 76         raise StopIteration()
     78 rval = self._data[self._data_ind]
     79 self._data_ind += 1

StopIteration:

Steps to Reproduce the Problem

Minimal Reproducible Example:

client = labelbox.Client(api_key=os.environ['LABELBOX_API_KEY'])

ontology_normalized_json = {
    "tools": [{'tool': 'polygon'}],
    "classifications": []
}

ontology = client.create_ontology(name="example_ontology",
                                  normalized=ontology_normalized_json,
                                  media_type=MediaType.Image)
project = client.create_project(name="example_project")

project.setup_editor(ontology)

this errors out with the error above. seems like an issue where self.client.get_labeling_frontends(where=Entity.LabelingFrontend.name == "Editor") is return an empty list.

Specifications

python: 3.8.14 labelbox: 3.33.1

paultancre commented 1 year ago

Please refer to our documentation on how to create Ontology/Tools : https://docs.labelbox.com/reference/ontology If the error persist please update your SDK version to the lastest : pip install labelbox --upgrade .