Datasets:
Download codes/reconstruction/relocate.py from shuinb/SP-TransientBench: direct link, hf CLI and curl.
- Browser
- Download file 893 Bytes
-
https://huggingface.co/datasets/shuinb/SP-TransientBench/resolve/main/codes/reconstruction/relocate.py
- Command line
-
hf download hf://datasets/shuinb/SP-TransientBench/codes/reconstruction/relocate.py
-
curl -L -o relocate.py https://huggingface.co/datasets/shuinb/SP-TransientBench/resolve/main/codes/reconstruction/relocate.py
893 Bytes
| from pathlib import Path | |
| import json | |
| root=Path(__file__).resolve().parent | |
| old='/home/donghongzhou/project/SP-Transient-retrain' | |
| previous=root/'.relocation.json' | |
| origins=[old] | |
| if previous.exists(): origins.append(json.loads(previous.read_text())['root']) | |
| count=0 | |
| for base in [root/'stb_minimal_20261017',root/'experiments',root/'config']: | |
| for p in base.rglob('*'): | |
| if not p.is_file() or p.suffix.lower() not in {'.py','.ini','.yaml','.yml','.json'}: continue | |
| try: text=p.read_text(encoding='utf-8') | |
| except UnicodeError: continue | |
| updated=text | |
| for source in origins: updated=updated.replace(source,str(root)) | |
| if updated!=text: | |
| temp=p.with_name(p.name+'.relocate.tmp'); temp.write_text(updated,encoding='utf-8'); temp.replace(p); count+=1 | |
| previous.write_text(json.dumps({'root':str(root)})) | |
| print('Relocated',count,'files to',root) | |