Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-ji committed Aug 26, 2024
1 parent 28137ba commit 6f136b1
Showing 1 changed file with 10 additions and 28 deletions.
38 changes: 10 additions & 28 deletions schema/ingestion_config/v1.0.0/ingestion_config_models_extended.py
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,6 @@ def validate_sources(source_list: List[StandardSource] | List[VoxelSpacingSource
),
)
if len(finders_in_source_entry) == 0:
# means there's only a parent_filters entry
for source_child in SOURCE_CHILDREN_NON_FINDERS:
if getattr(source_element, source_child) is None:
continue
Expand Down Expand Up @@ -621,20 +620,23 @@ def valid_sources(cls: Self, source_list: List[AnnotationSource]) -> List[Annota
for i, source_element in enumerate(source_list):
shapes_in_source_entry = []
for shape in source_element.model_fields:
if getattr(source_element, shape) is None:
continue
if shape in {"parent_filters", "exclude"}:
continue

# If the shape is not None, add it to the list of shapes in the source entry
shapes_in_source_entry.append(shape)
# If the shape is not None and an actual shape, add it to the list of shapes in the source entry
if getattr(source_element, shape) is not None and shape not in SOURCE_CHILDREN_NON_FINDERS:
shapes_in_source_entry.append(shape)
# If there are more than one shape in the source entry, add the source entry index and the shapes to the error set
if len(shapes_in_source_entry) > 1:
total_errors.append(
ValueError(
f"Source entry {i} cannot have multiple shapes (split into multiple entries): {shapes_in_source_entry}",
),
)
if len(shapes_in_source_entry) == 0:
for source_child in SOURCE_CHILDREN_NON_FINDERS:
if getattr(source_element, source_child) is None:
continue
total_errors.append(
ValueError(f"Source entry {i} cannot have a {source_child} entry without a shape"),
)

# For verifying that all source entries have exactly one of glob_string and glob_strings
for i, source_element in enumerate(source_list):
Expand All @@ -652,26 +654,6 @@ def valid_sources(cls: Self, source_list: List[AnnotationSource]) -> List[Annota
),
)

# For verifying that all source entries do not only have parent_filters or exclude
for i, source_element in enumerate(source_list):
has_parent_filters = False
has_exclude = False
has_shape = False
for shape in source_element.model_fields:
if getattr(source_element, shape) is None:
continue
if shape == "exclude":
has_exclude = True
elif shape == "parent_filters":
has_parent_filters = True
else:
has_shape = True

if not has_shape and has_parent_filters:
total_errors.append(ValueError(f"Source entry {i} cannot have a parent_filters entry without a shape"))
if not has_shape and has_exclude:
total_errors.append(ValueError(f"Source entry {i} cannot have an exclude entry without a shape"))

if shapes_used_multiple_times_errors:
total_errors.append(
ValueError(f"Annotation cannot have multiple same-shape sources: {shapes_used_multiple_times_errors}"),
Expand Down

0 comments on commit 6f136b1

Please sign in to comment.