Skip to content

Commit

Permalink
Fixed import issue for complex/simple polygons
Browse files Browse the repository at this point in the history
  • Loading branch information
brentgracey authored Aug 12, 2021
1 parent 10b9b3e commit b2aa123
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 14 deletions.
2 changes: 1 addition & 1 deletion darwin/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
from .client import Client # noqa
from .team import Team # noqa

__version__ = "0.6.3"
__version__ = "0.6.4"
7 changes: 5 additions & 2 deletions darwin/dataset/remote_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -383,14 +383,17 @@ def add_annotation_class(self, annotation_class):
# Waiting for a better api for setting classes
# in the meantime this will do
all_classes = self.fetch_remote_classes(True)
annotation_class_type = (annotation_class.annotation_internal_type or annotation_class.annotation_type)
match = [
cls
for cls in all_classes
if cls["name"] == annotation_class.name
and annotation_class.annotation_internal_type in cls["annotation_types"]
and annotation_class_type in cls["annotation_types"]
]
if not match:
raise ValueError(f"Unknown annotation class {annotation_class.name}, id: {annotation_class.id}")
# We do not expect to reach here; as pervious logic divides annotation classes in imports
# between `in team` and `new to platform`
raise ValueError(f"Annotation class name: `{annotation_class.name}`, type: `{annotation_class_type}`; does not exist in Team.")

datasets = match[0]["datasets"]
# check that we are not already part of the dataset
Expand Down
22 changes: 11 additions & 11 deletions darwin/importer/importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,26 +75,26 @@ def get_remote_files(dataset, filenames):
return remote_files


def _resolve_annotation_classes(annotation_classes: List[dt.AnnotationClass], classes_in_dataset, classes_in_team):
local_classes_not_in_dataset = set()
local_classes_not_in_team = set()
def _resolve_annotation_classes(local_annotation_classes: List[dt.AnnotationClass], classes_in_dataset, classes_in_team):
local_classes_not_in_dataset: set[dt.AnnotationClass] = set()
local_classes_not_in_team: set[dt.AnnotationClass] = set()

for cls in annotation_classes:
annotation_type = cls.annotation_internal_type or cls.annotation_type
for local_cls in local_annotation_classes:
local_annotation_type = local_cls.annotation_internal_type or local_cls.annotation_type
# Only add the new class if it doesn't exist remotely already
if annotation_type in classes_in_dataset and cls.name in classes_in_dataset[annotation_type]:
if local_annotation_type in classes_in_dataset and local_cls.name in classes_in_dataset[local_annotation_type]:
continue

# Only add the new class if it's not included in the list of the missing classes already
if cls.name in [missing_class.name for missing_class in local_classes_not_in_dataset]:
if local_cls.name in [missing_class.name for missing_class in local_classes_not_in_dataset]:
continue
if cls.name in [missing_class.name for missing_class in local_classes_not_in_team]:
if local_cls.name in [missing_class.name for missing_class in local_classes_not_in_team]:
continue

if annotation_type in classes_in_team and cls.name in classes_in_team[annotation_type]:
local_classes_not_in_dataset.add(cls)
if local_annotation_type in classes_in_team and local_cls.name in classes_in_team[local_annotation_type]:
local_classes_not_in_dataset.add(local_cls)
else:
local_classes_not_in_team.add(cls)
local_classes_not_in_team.add(local_cls)
return local_classes_not_in_dataset, local_classes_not_in_team


Expand Down

0 comments on commit b2aa123

Please sign in to comment.