Ignore hidden placeholder files in validator
Browse files- validator.py +9 -2
validator.py
CHANGED
|
@@ -138,6 +138,13 @@ def _iter_data_refs(text: str) -> list[str]:
|
|
| 138 |
return refs
|
| 139 |
|
| 140 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 141 |
def cleanup_work_dir(work_dir: str | Path | None) -> None:
|
| 142 |
if not work_dir:
|
| 143 |
return
|
|
@@ -360,7 +367,7 @@ def validate_task_dir(
|
|
| 360 |
if any(token in description for token in STALE_TOKENS):
|
| 361 |
errors.append(f'{prefix}.description still contains stale source paths or legacy directories')
|
| 362 |
|
| 363 |
-
actual_data_files =
|
| 364 |
uncovered = sorted(actual_data_files - covered_files)
|
| 365 |
if uncovered:
|
| 366 |
errors.append('data/ contains undeclared files: ' + ', '.join(rel(p, task_dir) for p in uncovered[:20]))
|
|
@@ -429,7 +436,7 @@ def validate_task_dir(
|
|
| 429 |
errors.append(f'{prefix}.path does not exist: {path_value}')
|
| 430 |
referenced_images.add(path_value)
|
| 431 |
|
| 432 |
-
actual_image_files = {str(p.relative_to(target_dir)) for p in
|
| 433 |
extra_images = sorted(actual_image_files - referenced_images)
|
| 434 |
missing_images = sorted(referenced_images - actual_image_files)
|
| 435 |
if extra_images:
|
|
|
|
| 138 |
return refs
|
| 139 |
|
| 140 |
|
| 141 |
+
def _iter_visible_files(root: Path) -> set[Path]:
|
| 142 |
+
return {
|
| 143 |
+
path for path in root.rglob('*')
|
| 144 |
+
if path.is_file() and not any(part.startswith('.') for part in path.relative_to(root).parts)
|
| 145 |
+
}
|
| 146 |
+
|
| 147 |
+
|
| 148 |
def cleanup_work_dir(work_dir: str | Path | None) -> None:
|
| 149 |
if not work_dir:
|
| 150 |
return
|
|
|
|
| 367 |
if any(token in description for token in STALE_TOKENS):
|
| 368 |
errors.append(f'{prefix}.description still contains stale source paths or legacy directories')
|
| 369 |
|
| 370 |
+
actual_data_files = _iter_visible_files(data_dir) if data_dir.exists() else set()
|
| 371 |
uncovered = sorted(actual_data_files - covered_files)
|
| 372 |
if uncovered:
|
| 373 |
errors.append('data/ contains undeclared files: ' + ', '.join(rel(p, task_dir) for p in uncovered[:20]))
|
|
|
|
| 436 |
errors.append(f'{prefix}.path does not exist: {path_value}')
|
| 437 |
referenced_images.add(path_value)
|
| 438 |
|
| 439 |
+
actual_image_files = {str(p.relative_to(target_dir)) for p in _iter_visible_files(images_dir)} if images_dir.exists() else set()
|
| 440 |
extra_images = sorted(actual_image_files - referenced_images)
|
| 441 |
missing_images = sorted(referenced_images - actual_image_files)
|
| 442 |
if extra_images:
|