@@ -790,16 +790,16 @@ def connect_ontology(self, ontology) -> None:
790790 Args:
791791 ontology (Ontology): The ontology to attach to the project
792792 """
793+ if not self .is_empty_ontology ():
794+ raise ValueError ("Ontology already connected to project." )
795+
793796 if self .labeling_frontend (
794797 ) is None : # Chat evaluation projects are automatically set up via the same api that creates a project
795798 self ._connect_default_labeling_front_end (ontology_as_dict = {
796799 "tools" : [],
797800 "classifications" : []
798801 })
799802
800- if not self .is_empty_ontology ():
801- raise ValueError ("Ontology already connected to project." )
802-
803803 query_str = """mutation ConnectOntologyPyApi($projectId: ID!, $ontologyId: ID!){
804804 project(where: {id: $projectId}) {connectOntology(ontologyId: $ontologyId) {id}}}"""
805805 self .client .execute (query_str , {
@@ -832,19 +832,19 @@ def setup(self, labeling_frontend, labeling_frontend_options) -> None:
832832 """ )
833833 return
834834
835- if self .labeling_frontend (
836- ) is None : # Chat evaluation projects are automatically set up via the same api that creates a project
837- self ._connect_default_labeling_front_end (labeling_frontend_options )
835+ self ._connect_default_labeling_front_end (labeling_frontend_options )
838836
839837 timestamp = datetime .now (timezone .utc ).strftime ("%Y-%m-%dT%H:%M:%SZ" )
840838 self .update (setup_complete = timestamp )
841839
842840 def _connect_default_labeling_front_end (self , ontology_as_dict : dict ):
843- warnings .warn ("Connecting default labeling editor for the project." )
844- labeling_frontend = next (
845- self .client .get_labeling_frontends (
846- where = Entity .LabelingFrontend .name == "Editor" ))
847- self .labeling_frontend .connect (labeling_frontend )
841+ labeling_frontend = self .labeling_frontend ()
842+ if labeling_frontend is None : # Chat evaluation projects are automatically set up via the same api that creates a project
843+ warnings .warn ("Connecting default labeling editor for the project." )
844+ labeling_frontend = next (
845+ self .client .get_labeling_frontends (
846+ where = Entity .LabelingFrontend .name == "Editor" ))
847+ self .labeling_frontend .connect (labeling_frontend )
848848
849849 if not isinstance (ontology_as_dict , str ):
850850 labeling_frontend_options_str = json .dumps (ontology_as_dict )
0 commit comments