def wait_for_checkpoint()

in robot_ws/src/rl_agent/markov/utils.py [0:0]


def wait_for_checkpoint(checkpoint_dir, data_store=None, retries=10):
    """
    block until there is a checkpoint in checkpoint_dir
    """
    for i in range(retries):
        if data_store:
            data_store.load_from_store()

        if has_checkpoint(checkpoint_dir):
            return
        time.sleep(10)

    raise ValueError((
        'Tried {retries} times, but checkpoint never found in '
        '{checkpoint_dir}'
    ).format(
        retries=retries,
        checkpoint_dir=checkpoint_dir,
    ))