@@ -790,16 +790,16 @@ def connect_ontology(self, ontology) -> None:
790
790
Args:
791
791
ontology (Ontology): The ontology to attach to the project
792
792
"""
793
+ if not self .is_empty_ontology ():
794
+ raise ValueError ("Ontology already connected to project." )
795
+
793
796
if self .labeling_frontend (
794
797
) is None : # Chat evaluation projects are automatically set up via the same api that creates a project
795
798
self ._connect_default_labeling_front_end (ontology_as_dict = {
796
799
"tools" : [],
797
800
"classifications" : []
798
801
})
799
802
800
- if not self .is_empty_ontology ():
801
- raise ValueError ("Ontology already connected to project." )
802
-
803
803
query_str = """mutation ConnectOntologyPyApi($projectId: ID!, $ontologyId: ID!){
804
804
project(where: {id: $projectId}) {connectOntology(ontologyId: $ontologyId) {id}}}"""
805
805
self .client .execute (query_str , {
@@ -832,19 +832,19 @@ def setup(self, labeling_frontend, labeling_frontend_options) -> None:
832
832
""" )
833
833
return
834
834
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 )
838
836
839
837
timestamp = datetime .now (timezone .utc ).strftime ("%Y-%m-%dT%H:%M:%SZ" )
840
838
self .update (setup_complete = timestamp )
841
839
842
840
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 )
848
848
849
849
if not isinstance (ontology_as_dict , str ):
850
850
labeling_frontend_options_str = json .dumps (ontology_as_dict )
0 commit comments