Skip to content

Vb/fix create ontology for project setup #1722

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions libs/labelbox/src/labelbox/schema/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -790,16 +790,16 @@ def connect_ontology(self, ontology) -> None:
Args:
ontology (Ontology): The ontology to attach to the project
"""
if not self.is_empty_ontology():
raise ValueError("Ontology already connected to project.")

if self.labeling_frontend(
) is None: # Chat evaluation projects are automatically set up via the same api that creates a project
self._connect_default_labeling_front_end(ontology_as_dict={
"tools": [],
"classifications": []
})

if not self.is_empty_ontology():
raise ValueError("Ontology already connected to project.")

query_str = """mutation ConnectOntologyPyApi($projectId: ID!, $ontologyId: ID!){
project(where: {id: $projectId}) {connectOntology(ontologyId: $ontologyId) {id}}}"""
self.client.execute(query_str, {
Expand Down Expand Up @@ -832,19 +832,19 @@ def setup(self, labeling_frontend, labeling_frontend_options) -> None:
""")
return

if self.labeling_frontend(
) is None: # Chat evaluation projects are automatically set up via the same api that creates a project
self._connect_default_labeling_front_end(labeling_frontend_options)
self._connect_default_labeling_front_end(labeling_frontend_options)

timestamp = datetime.now(timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ")
self.update(setup_complete=timestamp)

def _connect_default_labeling_front_end(self, ontology_as_dict: dict):
warnings.warn("Connecting default labeling editor for the project.")
labeling_frontend = next(
self.client.get_labeling_frontends(
where=Entity.LabelingFrontend.name == "Editor"))
self.labeling_frontend.connect(labeling_frontend)
labeling_frontend = self.labeling_frontend()
if labeling_frontend is None: # Chat evaluation projects are automatically set up via the same api that creates a project
warnings.warn("Connecting default labeling editor for the project.")
labeling_frontend = next(
self.client.get_labeling_frontends(
where=Entity.LabelingFrontend.name == "Editor"))
self.labeling_frontend.connect(labeling_frontend)

if not isinstance(ontology_as_dict, str):
labeling_frontend_options_str = json.dumps(ontology_as_dict)
Expand Down
1 change: 0 additions & 1 deletion libs/labelbox/tests/data/annotation_import/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,6 @@ def configured_project(client, initial_dataset, ontology, rand_gen, image_url):
client.get_labeling_frontends(
where=LabelingFrontend.name == "editor"))[0]
project.setup(editor, ontology)

data_row_ids = []

ontologies = ontology["tools"] + ontology["classifications"]
Expand Down
Loading