Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
hist = History(alloc_specs, sim_specs, gen_specs, exit_criteria, H0)
# Launch workers here
dtypes = {EVAL_SIM_TAG: hist.H[sim_specs['in']].dtype,
EVAL_GEN_TAG: hist.H[gen_specs['in']].dtype}
try:
wcomms = [QCommThread(worker_main, dtypes=dtypes,
sim_specs=sim_specs,
gen_specs=gen_specs,
workerID=w+1)
for w in range(libE_specs['nworkers'])]
for wcomm in wcomms:
wcomm.run()
persis_info, exit_flag = \
manager_main(hist, libE_specs, alloc_specs, sim_specs, gen_specs,
exit_criteria, persis_info, wcomms)
except Exception as e:
eprint(traceback.format_exc())
eprint("\nManager exception raised .. aborting ensemble:\n")
eprint("\nDumping ensemble history with {} sims evaluated:\n".
format(hist.sim_count))
filename = 'libE_history_at_abort_' + str(hist.sim_count) + '.npy'
np.save(filename, hist.trim_H())
sys.stdout.flush()
sys.stderr.flush()
else:
logger.debug("Manager exiting")
print(libE_specs['nworkers'], exit_criteria)
sys.stdout.flush()
def libE_manager(wcomms, sim_specs, gen_specs, exit_criteria, persis_info,
alloc_specs, libE_specs, hist,
on_abort=None, on_cleanup=None):
"Generic manager routine run."
if 'out' in gen_specs and ('sim_id', int) in gen_specs['out']:
logger.manager_warning(_USER_SIM_ID_WARNING)
try:
persis_info, exit_flag, elapsed_time = \
manager_main(hist, libE_specs, alloc_specs, sim_specs, gen_specs,
exit_criteria, persis_info, wcomms)
logger.info("libE_manager total time: {}".format(elapsed_time))
except ManagerException as e:
_report_manager_exception(hist, persis_info, e)
if libE_specs.get('abort_on_exception', True) and on_abort is not None:
on_abort()
raise
except Exception:
_report_manager_exception(hist, persis_info)
if libE_specs.get('abort_on_exception', True) and on_abort is not None:
on_abort()
raise
else:
logger.debug("Manager exiting")
logger.debug("Exiting with {} workers.".format(len(wcomms)))
def libE_manager(wcomms, sim_specs, gen_specs, exit_criteria, persis_info,
alloc_specs, libE_specs, hist,
on_abort=None, on_cleanup=None):
"Generic manager routine run."
if 'out' in gen_specs and ('sim_id', int) in gen_specs['out']:
logger.manager_warning(_USER_SIM_ID_WARNING)
try:
persis_info, exit_flag, elapsed_time = \
manager_main(hist, libE_specs, alloc_specs, sim_specs, gen_specs,
exit_criteria, persis_info, wcomms)
logger.info("libE_manager total time: {}".format(elapsed_time))
except ManagerException as e:
report_manager_exception(hist, persis_info, e)
if libE_specs.get('abort_on_exception', True) and on_abort is not None:
on_abort()
raise
except Exception:
report_manager_exception(hist, persis_info)
if libE_specs.get('abort_on_exception', True) and on_abort is not None:
on_abort()
raise
else:
logger.debug("Manager exiting")
logger.debug("Exiting with {} workers.".format(len(wcomms)))
CalcInfo.make_statdir()
exit_flag = []
hist = History(alloc_specs, sim_specs, gen_specs, exit_criteria, H0)
# Launch workers here
dtypes = {EVAL_SIM_TAG: hist.H[sim_specs['in']].dtype,
EVAL_GEN_TAG: hist.H[gen_specs['in']].dtype}
try:
wcomms = [QCommProcess(worker_main, dtypes, sim_specs, gen_specs, w)
for w in range(1, libE_specs['nworkers']+1)]
for wcomm in wcomms:
wcomm.run()
persis_info, exit_flag = \
manager_main(hist, libE_specs, alloc_specs, sim_specs, gen_specs,
exit_criteria, persis_info, wcomms)
except Exception:
eprint(traceback.format_exc())
eprint("\nManager exception raised .. aborting ensemble:\n")
eprint("\nDumping ensemble history with {} sims evaluated:\n".
format(hist.sim_count))
filename = 'libE_history_at_abort_' + str(hist.sim_count) + '.npy'
np.save(filename, hist.trim_H())
sys.stdout.flush()
sys.stderr.flush()
else:
logger.debug("Manager exiting")
print(libE_specs['nworkers'], exit_criteria)
sys.stdout.flush()