@@ -196,7 +196,6 @@ def check_errors(keywords, *path):
196196 return None
197197
198198 def get_error_status_code (error ):
199- print (error )
200199 return error ["extensions" ]["exception" ].get ("status" )
201200
202201 if check_errors (["AUTHENTICATION_ERROR" ], "extensions" ,
@@ -804,19 +803,28 @@ def create_ontology_from_feature_schemas(self, name, feature_schema_ids):
804803 tools , classifications = [], []
805804 for feature_schema_id in feature_schema_ids :
806805 feature_schema = self .get_feature_schema (feature_schema_id )
807- tool = feature_schema .normalized ['tool' ]
808- try :
809- Tool .Type (tool )
810- tools .append (feature_schema .normalized )
811- except ValueError :
806+ tool = ['tool' ]
807+ if 'tool' in feature_schema .normalized :
808+ tool = feature_schema .normalized ['tool' ]
812809 try :
813- Classification .Type (tool )
810+ Tool .Type (tool )
811+ tools .append (feature_schema .normalized )
812+ except ValueError :
813+ raise ValueError (
814+ f"Tool `{ tool } ` not in list of supported tools." )
815+ elif 'type' in feature_schema .normalized :
816+ classification = feature_schema .normalized ['type' ]
817+ try :
818+ Classification .Type (classification )
814819 classifications .append (feature_schema .normalized )
815820 except ValueError :
816821 raise ValueError (
817- f"Tool `{ tool } ` not in list of supported tools or classifications."
822+ f"Classification `{ classification } ` not in list of supported classifications."
818823 )
819-
824+ else :
825+ raise ValueError (
826+ "Neither `tool` or `classification` found in the normalized feature schema"
827+ )
820828 normalized = {'tools' : tools , 'classifications' : classifications }
821829 return self .create_ontology (name , normalized )
822830
@@ -882,11 +890,6 @@ def create_feature_schema(self, normalized):
882890 upsertRootSchemaNode(data: $data){ %s }
883891 } """ % query .results_query_part (Entity .FeatureSchema )
884892 normalized = {k : v for k , v in normalized .items () if v }
885-
886- # The OntologyBuilder automatically assigns colors when calling asdict() but Tools and Classifications do not.
887- # So we check here to prevent getting 500 erros
888- if 'color' not in normalized :
889- raise KeyError ("Must provide color." )
890893 params = {'data' : {'normalized' : json .dumps (normalized )}}
891894 res = self .execute (query_str , params )['upsertRootSchemaNode' ]
892895 # Technically we are querying for a Schema Node.
0 commit comments