langchain/libs/community/scripts/check_pickle.sh
Eugene Yurtsev 8f7cc73817
ci: Add script to check for pickle usage in community (#22863)
Add script to check for pickle usage in community.
2024-06-13 16:13:15 -04:00

28 lines
790 B
Bash
Executable File

#!/bin/bash
#
# This checks for usage of pickle in the package.
#
# Usage: ./scripts/check_pickle.sh /path/to/repository
#
# Check if a path argument is provided
if [ $# -ne 1 ]; then
echo "Usage: $0 /path/to/repository"
exit 1
fi
repository_path="$1"
# Search for lines matching the pattern within the specified repository
result=$(git -C "$repository_path" grep -E 'pickle.load\(|pickle.loads\(' | grep -v '# ignore\[pickle\]: explicit-opt-in')
# Check if any matching lines were found
if [ -n "$result" ]; then
echo "ERROR: The following lines need to be updated:"
echo "$result"
echo "Please avoid using pickle or cloudpickle."
echo "If you must, then add:"
echo "1. A security notice (scan the code for examples)"
echo "2. Code path should be opt-in."
exit 1
fi