Spaces:
Running
Running
Aaron Mueller
commited on
Commit
·
6311d99
1
Parent(s):
fdcf92b
support multiple_circuits with abs
Browse files- src/submission/check_validity.py +59 -36
src/submission/check_validity.py
CHANGED
@@ -416,44 +416,67 @@ def verify_circuit_submission(hf_repo, level, progress=gr.Progress()):
|
|
416 |
except Exception as e:
|
417 |
errors.append(f"Could not open Huggingface URL: {e}")
|
418 |
return errors, warnings
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
444 |
else:
|
445 |
continue
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
|
458 |
task_set, model_set = set(), set()
|
459 |
for tm in directories_present:
|
|
|
416 |
except Exception as e:
|
417 |
errors.append(f"Could not open Huggingface URL: {e}")
|
418 |
return errors, warnings
|
419 |
+
|
420 |
+
def _process_directory(files, current_path="", file_counts=0):
|
421 |
+
"""Recursively process directories, handling abs/True/False subdirectories"""
|
422 |
+
nonlocal errors, warnings, directories_present, directories_valid
|
423 |
+
|
424 |
+
for dirname in progress.tqdm(files, desc=f"Validating directories in {current_path or 'repo'}"):
|
425 |
+
file_counts += 1
|
426 |
+
if file_counts >= 30:
|
427 |
+
warnings.append("Folder contains many files/directories; stopped at 30.")
|
428 |
+
break
|
429 |
+
|
430 |
+
circuit_dir = dirname["name"]
|
431 |
+
dirname_proc = circuit_dir.lower().split("/")[-1]
|
432 |
+
|
433 |
+
if not fs.isdir(circuit_dir):
|
434 |
+
continue
|
435 |
+
|
436 |
+
# Check if this directory contains "abs" and "True"/"False"
|
437 |
+
if "abs" in dirname_proc and ("true" in dirname_proc or "false" in dirname_proc):
|
438 |
+
try:
|
439 |
+
# Recurse into this directory
|
440 |
+
subdirs = fs.listdir(circuit_dir, revision=revision if 'revision' in locals() else None)
|
441 |
+
_process_directory(subdirs, circuit_dir, file_counts)
|
442 |
+
except Exception as e:
|
443 |
+
warnings.append(f"Could not access subdirectory {circuit_dir}: {e}")
|
444 |
+
continue
|
445 |
+
|
446 |
+
curr_task = None
|
447 |
+
curr_model = None
|
448 |
+
|
449 |
+
# Look for task names in filename
|
450 |
+
for task in TASKS:
|
451 |
+
if dirname_proc.startswith(task) or f"_{task}" in dirname_proc:
|
452 |
+
curr_task = task
|
453 |
+
break
|
454 |
+
|
455 |
+
# Look for model names in filename
|
456 |
+
for model in MODELS:
|
457 |
+
if dirname_proc.startswith(model) or f"_{model}" in dirname_proc:
|
458 |
+
curr_model = model
|
459 |
+
break
|
460 |
+
|
461 |
+
if curr_task is not None and curr_model is not None:
|
462 |
+
curr_tm = f"{curr_task}_{curr_model}"
|
463 |
+
if curr_tm in VALID_COMBINATIONS:
|
464 |
+
directories_present[curr_tm] = True
|
465 |
+
else:
|
466 |
+
continue
|
467 |
else:
|
468 |
continue
|
469 |
+
|
470 |
+
# Parse circuits directory
|
471 |
+
print(f"validating {circuit_dir}")
|
472 |
+
vd_errors, vd_warnings = validate_directory_circuit(fs, repo_id, circuit_dir, curr_tm, level)
|
473 |
+
errors.extend(vd_errors)
|
474 |
+
warnings.extend(vd_warnings)
|
475 |
+
if len(vd_errors) == 0:
|
476 |
+
directories_valid[curr_tm] = True
|
477 |
+
|
478 |
+
# Start the recursive processing
|
479 |
+
_process_directory(files)
|
480 |
|
481 |
task_set, model_set = set(), set()
|
482 |
for tm in directories_present:
|