source_validation
anomaly_match.data_io.source_validation
¶
Validate that labeled filenames/IDs exist in data sources.
Provides efficient validation for container sources (Zarr, Cutana) without building full O(N) indexes. For each labeled item, produces a location tuple that downstream code can use for targeted extraction.
ValidationResult(found=list(), missing=list(), found_locations=dict(), partial=False)
dataclass
¶
Result of validating labeled files against a data source.
Attributes:
| Name | Type | Description |
|---|---|---|
found |
list[str]
|
Filenames/IDs that exist in the source. |
missing |
list[str]
|
Filenames/IDs that were not found. |
found_locations |
dict[str, tuple]
|
Map from filename to source-specific location info.
- Image folder: |
partial |
bool
|
|
validate_labeled_files(source_dir, label_df, source_type, *, stale_check=None)
¶
Check which labeled files/IDs exist in the data source.
Dispatches to source-specific validation. Never builds a full index of all N items in the source -- only checks the labeled subset.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source_dir
|
str
|
Path to the data directory or file. |
required |
label_df
|
DataFrame
|
DataFrame with |
required |
source_type
|
str | DataSourceType
|
A :class: |
required |
stale_check
|
Optional zero-arg callable returning |
None
|
Returns:
| Type | Description |
|---|---|
ValidationResult
|
ValidationResult with found/missing lists and location info. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If source_type is not recognised. |