Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ANN-2419][internal] Make mask annotation's sparse_rle field optional #659

Merged
merged 2 commits into from
Sep 13, 2023

Conversation

AndriiKlymchuk
Copy link
Contributor

@AndriiKlymchuk AndriiKlymchuk commented Sep 13, 2023

Problem

We made sparse_rle field non required and don't save it in the db anymore. Validation in darwin-py must reflect it.

Solution

Adjust import validation

Changelog

Make sparse_rle field of mask annotations optional during import

@linear
Copy link

linear bot commented Sep 13, 2023

ANN-2419 Fix mask validation in darwin-py

We made sparse_rle field non required and don't save it in the db anymore. Need to adjust validation in darwin-py accordingly.

@@ -764,19 +764,16 @@ def _parse_darwin_raster_annotation(annotation: dict) -> Optional[dt.Annotation]


def _parse_darwin_mask_annotation(annotation: dict) -> Optional[dt.Annotation]:
if not annotation.get("mask"):
raise ValueError("Mask annotation must have a 'mask' field")

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need in this condition as it checked one more time below.

id: Optional[str] = annotation.get("id")
name: Optional[str] = annotation.get("name")
mask: Optional[dt.JSONFreeForm] = annotation.get("mask")
slot_names: Optional[List[str]] = parse_slot_names(annotation)

if not id or not name or not mask or not slot_names:
if not id or not name or mask == None or not slot_names:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mask field could contain empty object which is valid, but is falsy value, therefore we should explicitly check None value.

Copy link
Contributor

@owencjones owencjones left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a couple of minor changes requested, to do with code convention to avoid bugs in identity Vs equality comparators.

darwin/utils/utils.py Outdated Show resolved Hide resolved
darwin/utils/utils.py Outdated Show resolved Hide resolved
Copy link
Contributor

@owencjones owencjones left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All looks good now. Thanks!

@AndriiKlymchuk AndriiKlymchuk merged commit 0a5a0a5 into master Sep 13, 2023
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants