def print_parallel_status(real_progress=False): now = toc() / 1000 if real_progress: global _last_real_progress if isinstance(_last_real_progress, DictProxy): _last_real_progress['value'] = now else: _last_real_progress = now from mlib.boot.crunch import get_manager if isinstance(_last_real_progress, DictProxy): then = _last_real_progress['value'] else: then = _last_real_progress last_real = now - then s = StringBuilder( f" | {format_sec_dur(now)} (last real update {format_sec_dur(last_real)} ago)", "\n") s += f'Parallel Statuses' s += 'PROCESSES' for k, v in get_manager().PROCESS_STATUSES.items(): if v != PROCESS_COMPLETE_STR: s += f'\t\t{k}\t:\t{v}' s += 'THREADS' for k, v in get_manager().THREAD_STATUSES.items(): s += f'\t\t{k}\t:\t{v}' REMOTE_STATUS_FOLDER['parallel.status'].write(s)
def finish_dnn_remote(): from mlib.file import File from mlib.boot.crunch import get_manager, PIPELINE_SECTION_FILE File(PIPELINE_SECTION_FILE).save(get_manager().PIPELINE_SECTIONS, silent=True) from mlib.boot import info info('printing dnn is finished string!') print('__DNN_IS_FINISHED__')
def non_daemon_process_map(fun, iterator, manager=None): from multiprocessing import Process if manager is None: with multiprocessing.Manager() as manager: r = manager.dict() def funfun(aa, ii): r[ii] = fun(a) ps = [] for i, a in enum(iterator): r[i] = None p = Process(target=funfun, args=(a, i), daemon=False) p.start() ps.append(p) [p.join() for p in ps] return [v for v in r.values()] else: r = manager.dict() def funfun(aa, ii): assert crunch.get_manager( ).PIPELINE_SECTIONS["Startup"] is not None r[ii] = fun(a) ps = [] for i, a in enum(iterator): r[i] = None p = Process(target=funfun, args=(a, i), daemon=False) assert crunch.get_manager( ).PIPELINE_SECTIONS["Startup"] is not None p.start() ps.append(p) [p.join() for p in ps] return [v for v in r.values()]
def update_process_status(s): from mlib.boot.crunch import get_manager get_manager().PROCESS_STATUSES[current_process().name] = s
def funfun(aa, ii): assert crunch.get_manager( ).PIPELINE_SECTIONS["Startup"] is not None r[ii] = fun(a)