From 8c15d1daeca1bb05255788a48a22e24a414820a3 Mon Sep 17 00:00:00 2001 From: Ines Montani Date: Fri, 29 Jan 2021 18:24:47 +1100 Subject: [PATCH] Update and validate config first and exit early if paths don't exist --- spacy/language.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/spacy/language.py b/spacy/language.py index f0d311e5d..5a2a0cd65 100644 --- a/spacy/language.py +++ b/spacy/language.py @@ -730,9 +730,6 @@ class Language: ) raise ValueError(err) pipe = self.get_pipe(pipe_name) - # Go over the listener layers and replace them - for listener in pipe_listeners: - util.replace_model_node(pipe.model, listener, tok2vec.model.copy()) # Update the config accordingly by coping the tok2vec model to all # sections defined in the listener paths for listener_path in listeners: @@ -745,6 +742,9 @@ class Language: ) raise ValueError(err) util.set_dot_to_object(pipe_cfg, listener_path, tok2vec_cfg["model"]) + # Go over the listener layers and replace them + for listener in pipe_listeners: + util.replace_model_node(pipe.model, listener, tok2vec.model.copy()) def create_pipe_from_source( self, source_name: str, source: "Language", *, name: str