Only add sourced vectors hashes to meta if necessary (#8830)

This commit is contained in:
Adriane Boyd 2021-08-02 18:22:35 +02:00 committed by GitHub
parent 0485cdefcc
commit 9ad3b8cf8d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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]