Datasets:
Download scripts/remote_util.py from Lilambd/empire-eval: direct link, hf CLI and curl.
- Browser
- Download file 700 Bytes
-
https://huggingface.co/datasets/Lilambd/empire-eval/resolve/main/scripts/remote_util.py
- Command line
-
hf download hf://datasets/Lilambd/empire-eval/scripts/remote_util.py
-
curl -L -o remote_util.py https://huggingface.co/datasets/Lilambd/empire-eval/resolve/main/scripts/remote_util.py
700 Bytes
| import glob, os, re | |
| def latest(root, pattern): | |
| """Newest file matching pattern (by the date in its path), as a path relative to root.""" | |
| hits = sorted(glob.glob(os.path.join(root, pattern))) | |
| if not hits: | |
| return None | |
| hits.sort(key=lambda p: re.findall(r'\d{4}-\d{2}-\d{2}', p)[-1] if re.findall(r'\d{4}-\d{2}-\d{2}', p) else '') | |
| return os.path.relpath(hits[-1], root).replace(os.sep, '/') | |
| def day_of(rel): | |
| m = re.findall(r'\d{4}-\d{2}-\d{2}', rel or '') | |
| return m[-1] if m else None | |
| def has(df, *cols): | |
| return all(c in df.columns for c in cols) | |
| def uniq(df, col): | |
| return df[df[col].notna() & ~df.duplicated([col], keep=False)] | |