Datasets:
File size: 1,973 Bytes
870b85a | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | """Create a reproducible identity manifest for the local source tree."""
import hashlib
import json
from pathlib import Path
BASE = Path(__file__).resolve().parents[1]
def digest(path):
value = hashlib.sha256()
with path.open('rb') as stream:
for block in iter(lambda: stream.read(1024 * 1024), b''):
value.update(block)
return value.hexdigest()
def main():
paths = sorted(path for path in (BASE/'source').rglob('*')
if path.is_file() and '__pycache__' not in path.parts
and path.suffix != '.pyc' and path.name != '.DS_Store'
and not path.name.startswith('._')
and path.relative_to(BASE/'source').as_posix() not in {
'configs/floorplans/rplan_production_25.json',
'scripts/internal/scene_generation/real_assets/source_orientation_overrides.json',
'scripts/internal/scene_generation/real_assets/evidence/worktop_aperture_boundaries.json',
'scripts/internal/scene_generation/real_assets/tests/actual_bed_records.jsonl',
})
inventory = {str(path.relative_to(BASE)): digest(path) for path in paths}
(BASE/'BASE_SHA256SUMS').write_text(''.join(
sha+' '+name+'\n' for name, sha in inventory.items()))
origin = dict(schema='rhg.robohomegen-source-origin.v1',
version='independent-working-copy', source_files=len(inventory),
inventory_sha256=digest(BASE/'BASE_SHA256SUMS'),
excluded_external_inputs=[
'configs/floorplans/rplan_production_25.json',
'scripts/internal/scene_generation/real_assets/source_orientation_overrides.json',
'scripts/internal/scene_generation/real_assets/evidence/worktop_aperture_boundaries.json',
'scripts/internal/scene_generation/real_assets/tests/actual_bed_records.jsonl',
])
(BASE/'BASE_ORIGIN.json').write_text(json.dumps(origin, indent=2)+'\n')
print(json.dumps(origin))
if __name__ == '__main__':
main()
|