Skip to content

Commit d5f8d3b

Browse files
committed
Fix non-existing attributes error
1 parent 9216286 commit d5f8d3b

File tree

3 files changed

+20
-8
lines changed

3 files changed

+20
-8
lines changed

superannotate/db/annotation_classes.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -302,12 +302,18 @@ def fill_class_and_attribute_names(annotations_json, annotation_classes_dict):
302302
if "attributes" in r:
303303
for attribute in r["attributes"]:
304304
if "groupId" in attribute and "id" in attribute:
305-
attribute["groupName"] = annotation_classes_dict[
306-
r["classId"]]["attribute_groups"][
307-
attribute["groupId"]]["name"]
308-
attribute["name"] = annotation_classes_dict[
309-
r["classId"]]["attribute_groups"][attribute[
310-
"groupId"]]["attributes"][attribute["id"]]
305+
if attribute["groupId"] in annotation_classes_dict[
306+
r["classId"]]["attribute_groups"]:
307+
attribute["groupName"] = annotation_classes_dict[
308+
r["classId"]]["attribute_groups"][
309+
attribute["groupId"]]["name"]
310+
if attribute["id"] in annotation_classes_dict[
311+
r["classId"]]["attribute_groups"][
312+
attribute["groupId"]]["attributes"]:
313+
attribute["name"] = annotation_classes_dict[
314+
r["classId"]]["attribute_groups"][
315+
attribute["groupId"]]["attributes"][
316+
attribute["id"]]
311317

312318

313319
def fill_class_and_attribute_ids(annotation_json, annotation_classes_dict):

superannotate/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "3.1.1"
1+
__version__ = "3.1.2"

tests/test_single_annotation_download.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def test_annotation_download_upload(
3838
)
3939
sa.upload_annotations_from_folder_to_project(project, from_folder)
4040

41-
image = sa.search_images(project)[2]
41+
image = sa.search_images(project)[0]
4242
paths = sa.download_image_annotations(project, image, tmpdir)
4343

4444
input_annotation_paths_after = sa.image_path_to_annotation_paths(
@@ -64,8 +64,14 @@ def test_annotation_download_upload(
6464
json2 = json.load(open(anns_json_in_folder[0]))
6565
for i in json1["instances"]:
6666
i.pop("classId", None)
67+
for j in i["attributes"]:
68+
j.pop("groupId", None)
69+
j.pop("id", None)
6770
for i in json2["instances"]:
6871
i.pop("classId", None)
72+
for j in i["attributes"]:
73+
j.pop("groupId", None)
74+
j.pop("id", None)
6975
assert json1 == json2
7076
if project_type == "Pixel":
7177
assert filecmp.cmp(

0 commit comments

Comments
 (0)