tool-call: update scripts/fetch_server_test_models.py

This commit is contained in:
ochafik 2024-10-28 23:57:23 +00:00
parent b825440c81
commit aefac1e5cb
2 changed files with 22 additions and 4 deletions

View file

@ -62,3 +62,10 @@ After changing logic in `steps.py`, ensure that `@bug` and `@wrong_usage` scenar
```shell
./tests.sh --no-skipped --tags bug,wrong_usage || echo "should failed but compile"
```
Some tests (especially `@slow` ones) require model downloads. Since this can time out the tests, you can pre-download them in the cache ahead of time with:
```shell
pip install -r examples/server/tests/requirements.txt
python scripts/fetch_server_test_models.py
```

View file

@ -9,12 +9,13 @@
python scripts/fetch_server_test_models.py
( cd examples/server/tests && ./tests.sh --tags=slow )
'''
import os
from behave.parser import Parser
import glob
import re
import os
from pydantic import BaseModel
import re
import subprocess
import sys
class HuggingFaceModel(BaseModel):
@ -60,8 +61,18 @@ cli_path = os.environ.get(
os.path.dirname(__file__),
'../build/bin/Release/llama-cli.exe' if os.name == 'nt' else '../build/bin/llama-cli'))
for m in models:
for m in sorted(list(models), key=lambda m: m.hf_repo):
if '<' in m.hf_repo or '<' in m.hf_file:
continue
if '-of-' in m.hf_file:
print(f'# Skipping model at {m.hf_repo} / {m.hf_file} because it is a split file', file=sys.stderr)
continue
print(f'# Ensuring model at {m.hf_repo} / {m.hf_file} is fetched')
subprocess.check_call([cli_path, '-hfr', m.hf_repo, '-hff', m.hf_file, '-fa', '-n', '1', '-p', 'Hey', '--no-warmup'])
cmd = [cli_path, '-hfr', m.hf_repo, '-hff', m.hf_file, '-n', '1', '-p', 'Hey', '--no-warmup', '--log-disable']
if m.hf_file != 'tinyllamas/stories260K.gguf':
cmd.append('-fa')
try:
subprocess.check_call(cmd)
except subprocess.CalledProcessError:
print(f'# Failed to fetch model at {m.hf_repo} / {m.hf_file} with command:\n {" ".join(cmd)}', file=sys.stderr)
exit(1)