Add prepared urban route guidance to Gaussian simulation planning
Introduce a content-bound scene route provider, advisory runtime graph and plan-preview-launch workflow. Preserve live sensing authority and retire blocked intermediate goals without discarding final-arrival evidence. Bound native visual context losslessly and provide verified cache relocation. Full Maroseyka route qualification remains open.
This commit is contained in:
@@ -0,0 +1,91 @@
|
||||
"""Relocate only explicitly selected reproducible simulation caches, preserving every verified byte.
|
||||
|
||||
Run --apply only while the simulation coordinator is idle. Original source
|
||||
packages, run evidence, credentials and scheduled-task configuration are untouched.
|
||||
"""
|
||||
import argparse
|
||||
import hashlib
|
||||
import json
|
||||
from pathlib import Path
|
||||
import shutil
|
||||
import subprocess
|
||||
|
||||
|
||||
def sha(path):
|
||||
with path.open('rb') as stream:
|
||||
return hashlib.file_digest(stream, 'sha256').hexdigest()
|
||||
|
||||
|
||||
def main():
|
||||
parser=argparse.ArgumentParser()
|
||||
parser.add_argument('--runtime',type=Path,required=True)
|
||||
parser.add_argument('--destination',type=Path,required=True)
|
||||
parser.add_argument('--apply',action='store_true')
|
||||
parser.add_argument('--cache',choices=['project','isaac-derived-data'],default='project')
|
||||
parser.add_argument('--fresh',action='store_true')
|
||||
args=parser.parse_args()
|
||||
state=args.runtime/'state'
|
||||
source=(state/'project-packages' if args.cache=='project' else
|
||||
args.runtime/'isaac-sim-6.1.0/kit/cache/DerivedDataCache')
|
||||
if args.fresh and args.cache!='isaac-derived-data':
|
||||
raise ValueError('Fresh cache is reserved for invalidated renderer-derived data')
|
||||
for name in ('active.json','editor-active.json','route-active.json'):
|
||||
if (state/name).exists():
|
||||
raise RuntimeError('Worker must be idle: '+name)
|
||||
if source.is_symlink() or source.is_junction():
|
||||
raise RuntimeError('Cache already redirected; inspect its destination')
|
||||
target=args.destination.resolve()
|
||||
if target==source.resolve() or source.resolve() in target.parents:
|
||||
raise ValueError('Destination must be outside the source cache')
|
||||
files=sorted(p for p in source.rglob('*') if p.is_file())
|
||||
if any(p.is_symlink() or p.is_junction() for p in source.rglob('*')):
|
||||
raise RuntimeError('Nested cache links are unsupported')
|
||||
size=sum(p.stat().st_size for p in files)
|
||||
existing=next(p for p in [target,*target.parents] if p.exists())
|
||||
report=dict(source=str(source),destination=str(target),files=len(files),bytes=size,
|
||||
destination_free_bytes=shutil.disk_usage(existing).free,applied=False)
|
||||
if report['destination_free_bytes']<size+4*1024**3:
|
||||
raise RuntimeError('Insufficient destination space')
|
||||
if not args.apply:
|
||||
print(json.dumps(report));return
|
||||
target.mkdir(parents=True,exist_ok=True)
|
||||
inventory={}
|
||||
for path in files:
|
||||
relative=path.relative_to(source);destination=target/relative
|
||||
destination.parent.mkdir(parents=True,exist_ok=True)
|
||||
digest=sha(path)
|
||||
if not destination.exists() or destination.stat().st_size!=path.stat().st_size or sha(destination)!=digest:
|
||||
temporary=destination.with_name(destination.name+'.relocating')
|
||||
shutil.copy2(path,temporary)
|
||||
if sha(temporary)!=digest:raise RuntimeError('Cache copy verification failed')
|
||||
temporary.replace(destination)
|
||||
inventory[str(relative)]=dict(bytes=path.stat().st_size,sha256=digest)
|
||||
if set(inventory)!={str(p.relative_to(source)) for p in source.rglob('*') if p.is_file()}:
|
||||
raise RuntimeError('Cache changed during relocation')
|
||||
for path in files:
|
||||
if sha(path)!=inventory[str(path.relative_to(source))]['sha256']:
|
||||
raise RuntimeError('Source cache changed during relocation')
|
||||
for name in ('active.json','editor-active.json','route-active.json'):
|
||||
if (state/name).exists():raise RuntimeError('Worker became active during copy')
|
||||
active_target=target
|
||||
if args.fresh:
|
||||
active_target=target.with_name(target.name+'.fresh')
|
||||
active_target.mkdir(exist_ok=False)
|
||||
backup=source.with_name(source.name+'.relocation-source')
|
||||
if backup.exists():raise RuntimeError('Unfinished prior relocation')
|
||||
source.rename(backup)
|
||||
try:
|
||||
subprocess.run(['cmd','/c','mklink','/J',str(source),str(active_target)],check=True,capture_output=True)
|
||||
if source.resolve()!=active_target:raise RuntimeError('Junction target mismatch')
|
||||
except Exception:
|
||||
if source.is_junction():source.rmdir()
|
||||
backup.rename(source)
|
||||
raise
|
||||
report.update(applied=True,inventory=inventory,active_destination=str(active_target),
|
||||
previous_bytes_preserved=True,fresh=args.fresh)
|
||||
(target.parent/(args.cache+'-cache-relocation.json')).write_text(json.dumps(report,indent=2))
|
||||
shutil.rmtree(backup)
|
||||
print(json.dumps({k:v for k,v in report.items() if k!='inventory'}))
|
||||
|
||||
|
||||
if __name__=='__main__':main()
|
||||
Reference in New Issue
Block a user