-
Notifications
You must be signed in to change notification settings - Fork 47
IO-496: Request: Add support for importing polygons in Dataloop format #497
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
Conversation
IO-496 Request: Add support for importing polygons in Dataloop format
Product Request Form submission from @Rafal Zadlowski Is this a V1 or V2 issue, or both? What is your request?
What are the acceptance criteria? Which product area is this request is applicable to (specify a team if known)? How important is this request? Do you have any deadline for this request (if deadline applicable, specify why)? Any additional info / Specify why Urgent or High: |
.python-version
Outdated
| @@ -0,0 +1 @@ | |||
| 3.9 | |||
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.
Using 3.9 as 3.10 and 3.11 both have issues compiling the [ml] options in pip install. Opening tickets to address this.
| annotations: List[dt.Annotation] = list(filter(None, map(_parse_annotation, data["annotations"]))) | ||
| annotation_classes: Set[dt.AnnotationClass] = set([annotation.annotation_class for annotation in annotations]) | ||
| return dt.AnnotationFile( | ||
| path, _remove_leading_slash(data["filename"]), annotation_classes, annotations, remote_path="/" |
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 formatting change, done automatically by Black
| content = f.read() | ||
| # from https://www.py4u.net/discuss/139845 | ||
| version = re.search(r'__version__\s*=\s*[\'"]([^\'"]*)[\'"]', content).group(1) | ||
| version = re.search(r'__version__\s*=\s*[\'"]([^\'"]*)[\'"]', content).group(1) # type: ignore |
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.
Prevents mypy complaining about this - rather than refactor type, when we have to replace setup.py in the coming months anyway.
| self.DATALOOP_MOCK_DATA = _fd.read() | ||
| _fd.close() | ||
|
|
||
| def assertApproximatelyEqualNumber( |
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.
Seems odd, but prevents issues with floating point numbers being off by .0000000000001 etc.
| with patch("darwin.importer.formats.dataloop.dt.make_polygon") as make_polygon_mock: | ||
| pa(self.parsed_json["annotations"][2]) # 2 is a segment type | ||
|
|
||
| if "kwargs" in make_polygon_mock.call_args: |
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.
MagicMock and Mock before version 3.8 don't support testing kwargs, so testing this would be difficult, but this feature switch will mean we still test against 3.8 and 3.9 in both Windows and Ubuntu, which I think is plenty for a simple dict comprehension.
setup.cfg
Outdated
| @@ -0,0 +1,2 @@ | |||
| [flake8] | |||
| max-line-length = 160 No newline at end of file | |||
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.
end-of-line 🙏
Dataloop importer was not handling the 'segment' type in dataloop formats. Have added support for it with simple polygons - it doesn't appear to include complex polygons - and have written a test suite for the whole importer.
Also took the opportunity to:
.python-versionset at 3.9 forpyenvusers to use in developmentsetup.cfgwithflake8settingssetup.ptthat developers can install with.