Datasets:
Download code/robohome/src/engine/real_test/seal_derived.py from RoboParty/RoboHome: direct link, hf CLI and curl.
- Browser
- Download file 2.13 kB
-
https://huggingface.co/datasets/RoboParty/RoboHome/resolve/main/code/robohome/src/engine/real_test/seal_derived.py
- Command line
-
hf download hf://datasets/RoboParty/RoboHome/code/robohome/src/engine/real_test/seal_derived.py
-
curl -L -o seal_derived.py https://huggingface.co/datasets/RoboParty/RoboHome/resolve/main/code/robohome/src/engine/real_test/seal_derived.py
2.13 kB
| """Record an explicit derived source snapshot while retaining parent hashes.""" | |
| import hashlib | |
| import json | |
| from pathlib import Path | |
| BASE = Path(__file__).resolve().parents[1] | |
| PARENT = BASE.with_name('wholehouse_generation_20261023') | |
| def sha(path): | |
| return hashlib.sha256(path.read_bytes()).hexdigest() | |
| def main(): | |
| inventory = PARENT / 'BASE_SHA256SUMS' | |
| parent = {} | |
| for line in inventory.read_text().splitlines(): | |
| expected, name = line.split(' ', 1) | |
| if sha(PARENT / name) != expected: | |
| raise ValueError('Parent source has changed: ' + name) | |
| parent[name] = expected | |
| for path in (PARENT / 'source').rglob('*'): | |
| if path.is_file() and '__pycache__' not in path.parts and path.suffix != '.pyc': | |
| parent.setdefault(str(path.relative_to(PARENT)), sha(path)) | |
| paths = sorted(p for p in (BASE / 'source').rglob('*') if p.is_file() | |
| and '__pycache__' not in p.parts and p.suffix != '.pyc') | |
| current = {str(path.relative_to(BASE)): sha(path) for path in paths} | |
| changes = [{'path': name, 'parent_sha256': parent.get(name), | |
| 'derived_sha256': current.get(name)} for name in sorted(parent.keys() | current.keys()) | |
| if parent.get(name) != current.get(name)] | |
| (BASE / 'PARENT_BASE_SHA256SUMS').write_bytes(inventory.read_bytes()) | |
| (BASE / 'BASE_SHA256SUMS').write_text(''.join(value + ' ' + name + '\n' | |
| for name, value in current.items())) | |
| origin = dict(schema='rhg.derived-source-origin.v1', version='v16.21p-wholehouse-opt3-20261023', | |
| parent_directory=PARENT.name, parent_version='v16.21p-wholehouse-opt2-20261023', | |
| parent_inventory_sha256=sha(inventory), source_directory='source', | |
| base_hash_inventory='BASE_SHA256SUMS', base_files=len(current), | |
| parent_source_unchanged=True, derived_source_modified=True, changes=changes) | |
| (BASE / 'BASE_ORIGIN.json').write_text(json.dumps(origin, indent=2, sort_keys=True) + '\n') | |
| print(json.dumps(dict(files=len(current), changed_files=len(changes), parent_unchanged=True))) | |
| if __name__ == '__main__': | |
| main() | |