Download python_lora_dataset_builder/pipeline/tiers.py from api-relay/sadASDasd: direct link, hf CLI and curl.
- Browser
- Download file 1.43 kB
-
https://huggingface.co/datasets/api-relay/sadASDasd/resolve/main/python_lora_dataset_builder/pipeline/tiers.py
- Command line
-
hf download hf://datasets/api-relay/sadASDasd/python_lora_dataset_builder/pipeline/tiers.py
-
curl -L -o tiers.py https://huggingface.co/datasets/api-relay/sadASDasd/resolve/main/python_lora_dataset_builder/pipeline/tiers.py
1.43 kB
| from __future__ import annotations | |
| TIER1_BASIC = "basic_python_syntax" | |
| TIER2_PER_LIBRARY = "per_library" | |
| TIER3_REAL_WORLD = "real_world_repository" | |
| ALL_TIERS = (TIER1_BASIC, TIER2_PER_LIBRARY, TIER3_REAL_WORLD) | |
| def classify_tier(imports: list[str], tier2_libraries: dict) -> tuple[str, str | None]: | |
| """Classify a code sample into one of the three dataset tiers, based on its | |
| top-level imports. | |
| - No imports at all -> tier 1, basic syntax (fully automated | |
| end-to-end today: extraction, static checks, sandbox execution, NIM | |
| review, and scoring all run for this tier). | |
| - Every import is a library we recognise (config/tier2_libraries.json) | |
| -> tier 2, per-library, tagged with the primary (alphabetically first) | |
| recognised library so records can be organized/filtered per library. | |
| - Any unrecognised import -> tier 3, treated as real-world/project | |
| code until a dedicated validation profile exists for it (see README). | |
| Tier 2 and tier 3 do not yet have execution environments, so the runner | |
| skips sandbox execution for them and never auto-includes an unexecuted | |
| record; see runner.py. | |
| """ | |
| if not imports: | |
| return TIER1_BASIC, None | |
| unknown = [lib for lib in imports if lib not in tier2_libraries] | |
| if unknown: | |
| return TIER3_REAL_WORLD, None | |
| primary = sorted(imports)[0] | |
| return TIER2_PER_LIBRARY, primary | |