File size: 1,932 Bytes
4ad9219
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
#!/usr/bin/env python3
"""仅同步已核实的阶段计数,不用部分题目填完整benchmark成绩。"""
import fcntl,json,os,pathlib,sys,time
ROOT=pathlib.Path(__file__).resolve().parents[1]
sys.path.insert(0,str(ROOT))
from cgvm.tracking import ExperimentLog
with (ROOT/'coordination/progress.lock').open('w') as lock:
 fcntl.flock(lock,fcntl.LOCK_EX|fcntl.LOCK_NB);lock.write(str(os.getpid()));lock.flush()
 logger=ExperimentLog('CGVM-live-progress',{'scope':'actual_counts_only_not_final_scores','authorized_gpus':[0,1,2,3]})
 if logger.run:
  (ROOT/'provenance/swanlab/live_progress_run.json').write_text(json.dumps({'run_id':logger.run.id,'mode':logger.mode,'url':'https://swanlab.cn/@xiangnan04/cgvm-minimal-validation/runs/'+logger.run.id},indent=2)+'\n')
 step=0
 try:
  while not (ROOT/'coordination/progress.stop').exists():
   try:
    state=json.loads((ROOT/'coordination/state.json').read_text())
    values={'progress/R0_smoke_answered':state['r0_smoke']['answered'],'data/media_training_videos':state['training']['media_videos'],
      'data/media_training_frames':state['training']['media_frames'],'cache/completed_videos':state['frozen_cache']['videos'],
      'cache/frames':state['frozen_cache']['frames'],'cache/gpu_seconds':state['frozen_cache']['gpu_seconds'],
      'resources/root_free_GiB':state['storage']['root_free_bytes']/1024**3,'resources/DATA_free_GiB':state['storage']['DATA_free_bytes']/1024**3}
    for variant in ['R0','R1','R2']:
     for benchmark in ['ovobench','streamingbench']:
      paths=list((ROOT/'results'/variant/benchmark).glob('shard*/state.json'));records=[json.loads(p.read_text()) for p in paths]
      values['progress/'+variant+'_'+benchmark+'_answered']=sum(r.get('answered',0) for r in records)
    logger.log(values,step=step);step+=1
   except (FileNotFoundError,KeyError,json.JSONDecodeError):pass
   time.sleep(60)
 finally:logger.finish(status='monitor_stopped')