Skip to content

Commit 73d22e2

Browse files
authored
test: OpenAI frontend invalid chat tokenizer network issue WAR (#7779)
1 parent 8b5f33e commit 73d22e2

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ skip = "./.git,./.github"
3131
# ignore short words, and typename parameters like OffsetT
3232
ignore-regex = "\\b(.{1,4}|[A-Z]\\w*T)\\b"
3333
# ignore allowed words
34-
ignore-words-list = "passin"
34+
ignore-words-list = "passin,couldn"
3535
# use the 'clear' dictionary for unambiguous spelling mistakes
3636
builtin = "clear"
3737
# disable warnings about binary files and wrong encoding

python/openai/tests/test_chat_completions.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -564,9 +564,15 @@ def test_chat_completions_invalid_chat_tokenizer(
564564

565565
# Pick a tokenizer with no chat template defined
566566
invalid_chat_tokenizer = "gpt2"
567-
app = setup_fastapi_app(
568-
tokenizer=invalid_chat_tokenizer, server=server, backend=backend
569-
)
567+
try:
568+
app = setup_fastapi_app(
569+
tokenizer=invalid_chat_tokenizer, server=server, backend=backend
570+
)
571+
except OSError as e:
572+
expected_msg = f"We couldn't connect to 'https://huggingface.co' to load this file, couldn't find it in the cached files and it looks like {invalid_chat_tokenizer} is not the path to a directory containing a file named config.json."
573+
if expected_msg in str(e):
574+
pytest.skip("HuggingFace network issues")
575+
raise e
570576
with TestClient(app) as client:
571577
response = client.post(
572578
"/v1/chat/completions",

0 commit comments

Comments
 (0)