-
Notifications
You must be signed in to change notification settings - Fork 42
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
[ANN-2419][internal] Make mask annotation's sparse_rle field optional #659
Conversation
ANN-2419 Fix mask validation in darwin-py
We made |
@@ -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") | |||
|
There was a problem hiding this comment.
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.
darwin/utils/utils.py
Outdated
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: |
There was a problem hiding this comment.
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.
There was a problem hiding this 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.
There was a problem hiding this 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!
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