terminal-agent-rl / artifacts /runtime-source /update_task_source_manifest.py
suunny's picture
Private full trajectory and experiment artifact archive (part 13)
b1a18a7 verified
Raw History Blame Contribute Delete
1.1 kB
"""Record committed git task/build/registry bytes; never untracked bytecode."""
import hashlib
import json
from pathlib import Path
import subprocess
ROOT=Path(__file__).resolve().parent
def update():
path=ROOT/'task-source.json';source=json.loads(path.read_text());repo=ROOT/'.state/task-registry-repo'
revision=source['commit']
files=subprocess.check_output(['git','-C',str(repo),'ls-tree','-r','--name-only',revision,'tasks','build','registry.json'],text=True).splitlines()
manifest={};build={}
for file in files:
data=subprocess.check_output(['git','-C',str(repo),'show',f'{revision}:{file}'])
sha=hashlib.sha256(data).hexdigest()
if file.startswith('tasks/'):
_,task,relative=file.split('/',2)
manifest.setdefault(task,{})[relative]=sha
elif file.startswith('build/'):
build[file]=sha
else:
source['registry_sha256']=sha
source['task_manifest']=manifest;source['build_manifest']=build
path.write_text(json.dumps(source,indent=2)+'\n')
if __name__=='__main__':
update()