Skip to content

Commit 20e9bf6

Browse files
author
Matt Sokoloff
committed
bug fix
1 parent 9ff4c72 commit 20e9bf6

File tree

2 files changed

+18
-15
lines changed

2 files changed

+18
-15
lines changed

examples/project_configuration/project_setup.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@
108108
"id": "limiting-bleeding",
109109
"metadata": {},
110110
"source": [
111-
"### Create Project and Setup\n",
111+
"### Create Project and Setup the Editor\n",
112112
"* Setting up a project will add an ontology and will enable labeling to begin\n",
113113
"* Attaching dataset(s) will add all data_rows belonging to the dataset to the queue."
114114
]

labelbox/client.py

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)