@@ -196,7 +196,6 @@ def check_errors(keywords, *path):
196
196
return None
197
197
198
198
def get_error_status_code (error ):
199
- print (error )
200
199
return error ["extensions" ]["exception" ].get ("status" )
201
200
202
201
if check_errors (["AUTHENTICATION_ERROR" ], "extensions" ,
@@ -804,19 +803,28 @@ def create_ontology_from_feature_schemas(self, name, feature_schema_ids):
804
803
tools , classifications = [], []
805
804
for feature_schema_id in feature_schema_ids :
806
805
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' ]
812
809
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 )
814
819
classifications .append (feature_schema .normalized )
815
820
except ValueError :
816
821
raise ValueError (
817
- f"Tool `{ tool } ` not in list of supported tools or classifications."
822
+ f"Classification `{ classification } ` not in list of supported classifications."
818
823
)
819
-
824
+ else :
825
+ raise ValueError (
826
+ "Neither `tool` or `classification` found in the normalized feature schema"
827
+ )
820
828
normalized = {'tools' : tools , 'classifications' : classifications }
821
829
return self .create_ontology (name , normalized )
822
830
@@ -882,11 +890,6 @@ def create_feature_schema(self, normalized):
882
890
upsertRootSchemaNode(data: $data){ %s }
883
891
} """ % query .results_query_part (Entity .FeatureSchema )
884
892
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." )
890
893
params = {'data' : {'normalized' : json .dumps (normalized )}}
891
894
res = self .execute (query_str , params )['upsertRootSchemaNode' ]
892
895
# Technically we are querying for a Schema Node.
0 commit comments