Aaron Mueller commited on
Commit
6311d99
·
1 Parent(s): fdcf92b

support multiple_circuits with abs

Browse files
Files changed (1) hide show
  1. 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
- file_counts = 0
421
- for dirname in progress.tqdm(files, desc="Validating directories in repo"):
422
- file_counts += 1
423
- if file_counts >= 30:
424
- warnings.append("Folder contains many files/directories; stopped at 30.")
425
- break
426
- circuit_dir = dirname["name"]
427
- dirname_proc = circuit_dir.lower().split("/")[-1]
428
- if not fs.isdir(circuit_dir):
429
- continue
430
- curr_task = None
431
- curr_model = None
432
- # Look for task names in filename
433
- for task in TASKS:
434
- if dirname_proc.startswith(task) or f"_{task}" in dirname_proc:
435
- curr_task = task
436
- # Look for model names in filename
437
- for model in MODELS:
438
- if dirname_proc.startswith(model) or f"_{model}" in dirname_proc:
439
- curr_model = model
440
- if curr_task is not None and curr_model is not None:
441
- curr_tm = f"{curr_task}_{curr_model}"
442
- if curr_tm in VALID_COMBINATIONS:
443
- directories_present[curr_tm] = True
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
444
  else:
445
  continue
446
- else:
447
- continue
448
-
449
- # Parse circuits directory
450
- print(f"validating {circuit_dir}")
451
- vd_errors, vd_warnings = validate_directory_circuit(fs, repo_id, circuit_dir, curr_tm, level)
452
- errors.extend(vd_errors)
453
- warnings.extend(vd_warnings)
454
-
455
- if len(vd_errors) == 0:
456
- directories_valid[curr_tm] = True
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: