Skip to content

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.

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.

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.

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
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.

3 participants