diff --git a/check-requirements.sh b/check-requirements.sh index a38e6293f..b1f8ac313 100755 --- a/check-requirements.sh +++ b/check-requirements.sh @@ -32,6 +32,10 @@ log() { >&2 printf "$level: $format\n" "$@" } +debug () { + log 'DEBUG' "$@" +} + info() { log 'INFO' "$@" } @@ -72,12 +76,13 @@ else fi set -eu -o pipefail -this="$(realpath "$0")" -readonly this +this="$(realpath "$0")"; readonly this cd "$(dirname "$this")" shellcheck "$this" +readonly reqs_dir='./requirements' + workdir= if [[ -n ${1+x} ]]; then arg_dir="$(realpath "$1")" @@ -115,12 +120,13 @@ check_requirements() { check_convert_script() { assert_arg_count 1 "$@" - local py="$1" - local pyname="${py%.py}" + local py="$1"; shift # e.g. ./convert-hf-to-gguf.py + local pyname; pyname="$(basename "$py")" # e.g. convert-hf-to-gguf.py + pyname="${pyname%.py}" # e.g. convert-hf-to-gguf info "$py: beginning check" - local reqs="requirements-$pyname.txt" + local reqs="$reqs_dir/requirements-$pyname.txt" if [[ ! -r "$reqs" ]]; then fatal "$py missing requirements. Expected: $reqs" fi @@ -144,13 +150,19 @@ check_convert_script() { info "$py: imports OK" } -# Check requirements.txt +# Check that all sub-requirements are added to top-level requirements.txt +for req in "$reqs_dir"/*; do + if ! grep -qFe "$req" ./requirements.txt; then + fatal "$req needs to be added to ./requirements.txt" + fi +done + all_venv="$workdir/all-venv" python3 -m venv "$all_venv" -check_requirements "$all_venv" 'requirements.txt' +check_requirements "$all_venv" './requirements.txt' -check_convert_script 'convert.py' -for py in convert-*.py; do +check_convert_script './convert.py' +for py in ./convert-*.py;do check_convert_script "$py" done diff --git a/requirements-convert-llama-ggml-to-gguf.txt b/requirements-convert-llama-ggml-to-gguf.txt deleted file mode 100644 index 8a5377762..000000000 --- a/requirements-convert-llama-ggml-to-gguf.txt +++ /dev/null @@ -1 +0,0 @@ --r requirements-convert.txt diff --git a/requirements-convert-lora-to-ggml.txt b/requirements-convert-lora-to-ggml.txt deleted file mode 100644 index 30827c896..000000000 --- a/requirements-convert-lora-to-ggml.txt +++ /dev/null @@ -1,2 +0,0 @@ --r requirements-convert.txt -torch==2.1.1 diff --git a/requirements-convert-persimmon-to-gguf.txt b/requirements-convert-persimmon-to-gguf.txt deleted file mode 100644 index 30827c896..000000000 --- a/requirements-convert-persimmon-to-gguf.txt +++ /dev/null @@ -1,2 +0,0 @@ --r requirements-convert.txt -torch==2.1.1 diff --git a/requirements-hf-to-gguf.txt b/requirements-hf-to-gguf.txt deleted file mode 100644 index f4600539e..000000000 --- a/requirements-hf-to-gguf.txt +++ /dev/null @@ -1,3 +0,0 @@ --r requirements.txt -torch==2.1.1 -transformers==4.35.2 diff --git a/requirements.txt b/requirements.txt index da4f3f9a8..d36f74520 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,8 +4,9 @@ # Package versions must stay compatible across all top-level python scripts. # --r requirements-convert.txt +-r ./requirements/requirements-convert.txt --r requirements-convert-hf-to-gguf.txt --r requirements-convert-lora-to-ggml.txt --r requirements-convert-persimmon-to-gguf.txt +-r ./requirements/requirements-convert-hf-to-gguf.txt +-r ./requirements/requirements-convert-llama-ggml-to-gguf.txt +-r ./requirements/requirements-convert-lora-to-ggml.txt +-r ./requirements/requirements-convert-persimmon-to-gguf.txt diff --git a/requirements-convert-hf-to-gguf.txt b/requirements/requirements-convert-hf-to-gguf.txt similarity index 53% rename from requirements-convert-hf-to-gguf.txt rename to requirements/requirements-convert-hf-to-gguf.txt index 4d00b1966..ddde1431b 100644 --- a/requirements-convert-hf-to-gguf.txt +++ b/requirements/requirements-convert-hf-to-gguf.txt @@ -1,3 +1,3 @@ --r requirements-convert.txt +-r ./requirements-convert.txt torch==2.1.1 transformers==4.35.2 diff --git a/requirements/requirements-convert-llama-ggml-to-gguf.txt b/requirements/requirements-convert-llama-ggml-to-gguf.txt new file mode 100644 index 000000000..a0f37cd1c --- /dev/null +++ b/requirements/requirements-convert-llama-ggml-to-gguf.txt @@ -0,0 +1 @@ +-r ./requirements-convert.txt diff --git a/requirements/requirements-convert-lora-to-ggml.txt b/requirements/requirements-convert-lora-to-ggml.txt new file mode 100644 index 000000000..0605b9816 --- /dev/null +++ b/requirements/requirements-convert-lora-to-ggml.txt @@ -0,0 +1,2 @@ +-r ./requirements-convert.txt +torch==2.1.1 diff --git a/requirements/requirements-convert-persimmon-to-gguf.txt b/requirements/requirements-convert-persimmon-to-gguf.txt new file mode 100644 index 000000000..0605b9816 --- /dev/null +++ b/requirements/requirements-convert-persimmon-to-gguf.txt @@ -0,0 +1,2 @@ +-r ./requirements-convert.txt +torch==2.1.1 diff --git a/requirements-convert.txt b/requirements/requirements-convert.txt similarity index 100% rename from requirements-convert.txt rename to requirements/requirements-convert.txt