Download python_lora_dataset_builder/pipeline/coverage.py from api-relay/sadASDasd: direct link, hf CLI and curl.
- Browser
- Download file 711 Bytes
-
https://huggingface.co/datasets/api-relay/sadASDasd/resolve/main/python_lora_dataset_builder/pipeline/coverage.py
- Command line
-
hf download hf://datasets/api-relay/sadASDasd/python_lora_dataset_builder/pipeline/coverage.py
-
curl -L -o coverage.py https://huggingface.co/datasets/api-relay/sadASDasd/resolve/main/python_lora_dataset_builder/pipeline/coverage.py
711 Bytes
| import json | |
| from pathlib import Path | |
| class CoverageTracker: | |
| def __init__(self,path:Path,topics,default_target): | |
| self.path=path; self.default_target=default_target | |
| self.data={t:{"accepted":0,"target":default_target} for t in topics} | |
| if path.exists():self.data.update(json.loads(path.read_text(encoding="utf-8"))) | |
| def needs_coverage(self,topic): | |
| x=self.data[topic]; return int(x.get("accepted",0))<int(x.get("target",self.default_target)) | |
| def add(self,topic): | |
| self.data[topic]["accepted"]=int(self.data[topic].get("accepted",0))+1 | |
| self.path.parent.mkdir(parents=True,exist_ok=True); self.path.write_text(json.dumps(self.data,indent=2),encoding="utf-8") | |