def start_heartbeat_thread(): trainer = get_trainer() extension = watchdog_extension.Watchdog(watch_items=[]) assert not extension._heartbeat_thread.is_alive() extension.initialize(trainer) assert extension._heartbeat_thread.is_alive()
def on_dead_heartbeat_thread(): trainer = get_trainer() extension = watchdog_extension.Watchdog(watch_items=[]) with pytest.raises(RuntimeError) as exc_info: extension(trainer) assert str(exc_info.value) == 'Heartbeat thread is dead'
def without_trigger(): trainer = get_trainer() extension = watchdog_extension.Watchdog( watch_items=[], trigger=lambda trainer: False) extension.initialize(trainer) extension(trainer)
def test_with_tuple_watch_items(): extension = watchdog_extension.Watchdog(watch_items=[ watchdog_extension.WatchItem('action', 'estimator') ]) assert [type(item) for item in extension._watch_items ] == [watchdog_extension.WatchItem]
def test_inheritance(monkeypatch): extension = watchdog_extension.Watchdog(watch_items=[]) assert isinstance(extension, training.extension.Extension)