From 5743b06e36c92fdb541c0a02d1a4b3850676418f Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Thu, 5 Oct 2017 08:12:50 -0500 Subject: [PATCH] Wrap model saving in try/except --- spacy/cli/train.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/spacy/cli/train.py b/spacy/cli/train.py index a22db6abc..064f053a1 100644 --- a/spacy/cli/train.py +++ b/spacy/cli/train.py @@ -114,9 +114,12 @@ def train(cmd, lang, output_dir, train_data, dev_data, n_iter=20, n_sents=0, print_progress(i, losses, scorer.scores) finally: print("Saving model...") - with (output_path / 'model-final.pickle').open('wb') as file_: - with nlp.use_params(optimizer.averages): - dill.dump(nlp, file_, -1) + try: + with (output_path / 'model-final.pickle').open('wb') as file_: + with nlp.use_params(optimizer.averages): + dill.dump(nlp, file_, -1) + except: + print("Error saving model") def _render_parses(i, to_render):