Skip to content

Commit

Permalink
added stop event on validation
Browse files Browse the repository at this point in the history
  • Loading branch information
TheoLisin committed Nov 9, 2023
1 parent f2b04f5 commit 731c1d1
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions train/src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -1147,11 +1147,12 @@ def train_batch_watcher_disable():

threading.Thread(target=train_batch_watcher_func, daemon=True).start()

def stop_on_train_batch_end_if_needed(*args, **kwargs):
def stop_on_batch_end_if_needed(*args, **kwargs):
if app.app_is_stopped():
raise app.StopAppError("This error is expected.")

model.add_callback("on_train_batch_end", stop_on_train_batch_end_if_needed)
model.add_callback("on_train_batch_end", stop_on_batch_end_if_needed)
model.add_callback("on_val_batch_end", stop_on_batch_end_if_needed)

with app.run_with_stop_app_error_suppression():
model.train(
Expand Down

0 comments on commit 731c1d1

Please sign in to comment.