ci: Add script to check for pickle usage in community (#22863)

Add script to check for pickle usage in community.
This commit is contained in:
Eugene Yurtsev
2024-06-13 16:13:15 -04:00
committed by GitHub
parent 77209f315e
commit 8f7cc73817
9 changed files with 65 additions and 8 deletions

View File

@@ -456,7 +456,14 @@ class Annoy(VectorStore):
annoy = guard_import("annoy")
# load docstore and index_to_docstore_id
with open(path / "index.pkl", "rb") as file:
docstore, index_to_docstore_id, config_object = pickle.load(file)
# Code path can only be reached if allow_dangerous_deserialization is True
(
docstore,
index_to_docstore_id,
config_object,
) = pickle.load( # ignore[pickle]: explicit-opt-in
file
)
f = int(config_object["ANNOY"]["f"])
metric = config_object["ANNOY"]["metric"]