def run(self):
"""Wait for new data until node receives a terminate or a test message.
In the beginning, the node is waiting for new batches distributed by
:class:`MPIGridSearchCVMaster._scatter_work`.
After the grid search has been completed, the node either receives data
from :func:`_fit_and_score_with_parameters` to evaluate the estimator
given the parameters determined during grid-search, or is asked
to terminate. Stop messages are: MPI_MSG_TERMINATE or MPI_MSG_TEST.
"""
task_desc = self._task_desc
while True:
comm.Bcast([task_desc, MPI.INT], root=0)
if task_desc[1] == MPI_MSG_TERMINATE:
LOG.debug("Node %d received terminate message", comm_rank)
return
if task_desc[1] == MPI_MSG_CV:
self._run_grid_search()
elif task_desc[1] == MPI_MSG_TEST:
self._run_train_test()
break
else:
raise ValueError('unknown task with id %d' % task_desc[1])
LOG.debug("Node %d is terminating", comm_rank)
评论列表
文章目录