File size: 1,112 Bytes
dee7f43
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
"""Prepare frozen inference components; never publish incomplete conversions."""
import os,sys,json,traceback
from pathlib import Path
os.environ.update(VDS_BATCH2_ROOT='/workspace/vds-litert-batch2',HF_TOKEN_FILE='/workspace/.secrets/hf_token',TORCH_NUM_THREADS='6')
root=Path('/workspace/vds-litert-batch2');sys.path.insert(0,str(root/'package/scripts'))
import convert_batch2 as worker
key=sys.argv[1];out=root/'learning-backbones'/key;out.mkdir(parents=True,exist_ok=True)
status={'key':key,'phase':'converting_frozen_component','published':False}
(out/'status.json').write_text(json.dumps(status))
try:
    spec=next(s for s in worker.all_specs() if s['key']==key);entry=worker.prefetched(key)
    artifacts,report=worker.CONV[spec['route']](spec,entry,out)
    status.update(phase='converted_frozen_component',artifacts=[str(p) for p in artifacts],report=report)
except Exception as e:
    status.update(phase='failed',error=str(e),traceback=traceback.format_exc());print(status['traceback'],flush=True)
(out/'status.json').write_text(json.dumps(status,indent=2)+'\n')
print(json.dumps(status),flush=True)