From 9ad3b8cf8d3ebf52c10537ee7459b57393ad3445 Mon Sep 17 00:00:00 2001 From: Adriane Boyd Date: Mon, 2 Aug 2021 18:22:35 +0200 Subject: [PATCH] Only add sourced vectors hashes to meta if necessary (#8830) --- spacy/language.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/spacy/language.py b/spacy/language.py index 589dca2bf..14b423be6 100644 --- a/spacy/language.py +++ b/spacy/language.py @@ -1698,7 +1698,6 @@ class Language: # them here so they're only loaded once source_nlps = {} source_nlp_vectors_hashes = {} - nlp.meta["_sourced_vectors_hashes"] = {} for pipe_name in config["nlp"]["pipeline"]: if pipe_name not in pipeline: opts = ", ".join(pipeline.keys()) @@ -1747,6 +1746,8 @@ class Language: source_nlp_vectors_hashes[model] = hash( source_nlps[model].vocab.vectors.to_bytes() ) + if "_sourced_vectors_hashes" not in nlp.meta: + nlp.meta["_sourced_vectors_hashes"] = {} nlp.meta["_sourced_vectors_hashes"][ pipe_name ] = source_nlp_vectors_hashes[model]