DERBACH/latent-rubric / scripts /launch_research_threads.py
DERBACH's picture
download
raw
1.61 kB
import subprocess,shlex,json
from pathlib import Path
root=Path('/home/ningyuxi/workspace/latent-rubric');threads=[]
for name in ['engine','audit','statistics']:
session='latent-rubric-'+name
prompt=root/'outputs/threads'/f'{name}_task.md';script=root/'outputs/threads'/f'{name}_run.sh';log=root/'outputs/threads'/f'{name}_events.jsonl';final=root/'outputs/threads'/f'{name}_last_message.md'
cmd=['/home/ningyuxi/.local/bin/codex','exec','-C',str(root),'--json','-o',str(final),'-']
body='#!/usr/bin/env bash\nset -uo pipefail\ncd '+shlex.quote(str(root))+'\n'
if name!='engine':body+="export CUDA_VISIBLE_DEVICES='' OMP_NUM_THREADS=2 OPENBLAS_NUM_THREADS=2\n"
body+=' '.join(map(shlex.quote,cmd))+' < '+shlex.quote(str(prompt))+' > '+shlex.quote(str(log))+' 2>&1\n'
body+='code=$?\nprintf "%s\\n" "$code" > '+shlex.quote(str(root/'outputs/threads'/f'{name}_exit_code'))+'\nexit "$code"\n';script.write_text(body);script.chmod(0o700)
if subprocess.run(['tmux','has-session','-t',session],capture_output=True).returncode==0:raise RuntimeError('Existing session '+session)
subprocess.run(['tmux','new-session','-d','-s',session,'-c',str(root),'/bin/bash'],check=True)
subprocess.run(['tmux','set-option','-t',session,'remain-on-exit','on'],check=True)
subprocess.run(['tmux','send-keys','-t',session,'exec /bin/bash '+shlex.quote(str(script)),'Enter'],check=True)
threads.append({'name':name,'tmux':session,'prompt_file':str(prompt),'event_log':str(log),'final_message':str(final)})
(root/'outputs/threads/manifest.json').write_text(json.dumps(threads,indent=2));print(json.dumps(threads,indent=2))

Xet Storage Details

Size:
1.61 kB
·
Xet hash:
40c7f1e9e699964c7ed4bb94c64b1b10afb76d53ca158b4a0d94d5bebea8c615

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.