PERDYPTO
Upload 45 files
0109502 verified
Raw History Blame Contribute Delete
3.58 kB
from __future__ import annotations
import argparse
from pathlib import Path
from pipeline.runner import run
from pipeline import tiers as tiers_mod
TIER_ALIASES = {
"basic": tiers_mod.TIER1_BASIC,
"basic_python_syntax": tiers_mod.TIER1_BASIC,
"tier1": tiers_mod.TIER1_BASIC,
"library": tiers_mod.TIER2_PER_LIBRARY,
"per_library": tiers_mod.TIER2_PER_LIBRARY,
"tier2": tiers_mod.TIER2_PER_LIBRARY,
"project": tiers_mod.TIER3_REAL_WORLD,
"real_world": tiers_mod.TIER3_REAL_WORLD,
"real_world_repository": tiers_mod.TIER3_REAL_WORLD,
"tier3": tiers_mod.TIER3_REAL_WORLD,
"all": None, # expanded below
}
def _parse_tiers(raw: str) -> tuple[str, ...]:
names = [x.strip().lower() for x in raw.split(",") if x.strip()]
if "all" in names:
return tiers_mod.ALL_TIERS
out = []
for n in names:
if n not in TIER_ALIASES:
valid = ", ".join(sorted(TIER_ALIASES))
raise SystemExit(f"Unknown --tiers value '{n}'. Valid values: {valid}")
out.append(TIER_ALIASES[n])
return tuple(dict.fromkeys(out)) # dedupe, preserve order
def main():
parser = argparse.ArgumentParser(description="Python LoRA dataset quality pipeline")
parser.add_argument("--limit", type=int, default=500, help="Maximum source rows to process")
parser.add_argument("--dry-run", action="store_true",
help="Run extraction/static/execution checks without NIM")
parser.add_argument("--source", default=None, help="Override Hugging Face dataset name")
parser.add_argument(
"--tiers", default="basic",
help=(
"Comma-separated tiers to actively process this run: "
"'basic' (import-free, fully automated — the default and the one to run right now), "
"'library' (per-library, classified + NIM-reviewed but never auto-included; "
"no per-library execution env yet), "
"'project' (real-world/project code, classified only, not executed or scored), "
"or 'all'. Records in inactive tiers are still classified and saved "
"(decision=skip) so nothing is lost."
),
)
parser.add_argument(
"--no-resume", action="store_true",
help=(
"Ignore data/metadata/checkpoint.json and start over from row 0 "
"of the source dataset. By default (no flag) the pipeline resumes "
"from wherever the last run left off — this is what makes running "
"it once a day for a few weeks pick up where it stopped instead of "
"reprocessing rows or restarting the source from scratch."
),
)
args = parser.parse_args()
root = Path(__file__).resolve().parent
active_tiers = _parse_tiers(args.tiers)
stats = run(root, limit=args.limit, dry_run=args.dry_run,
source_name_override=args.source, active_tiers=active_tiers,
resume=not args.no_resume)
print("\nPipeline complete (this run)")
print(f"active tiers: {', '.join(active_tiers)}")
for key, value in stats.items():
if key == "cumulative_stats":
print("cumulative totals across all runs on this source:")
for ck, cv in value.items():
print(f" {ck}: {cv}")
else:
print(f"{key}: {value}")
if not stats.get("source_exhausted"):
print(
"\nSource not finished yet — run the same command again "
"(e.g. tomorrow) to continue from here."
)
if __name__ == "__main__":
main()