[BugFix] HFValidationError with cloud storage URIs when HF_HUB_OFFLINE=1 (#39155)
Signed-off-by: Injae Ryou <injaeryou@gmail.com>
This commit is contained in:
@@ -613,3 +613,31 @@ def test_ir_op_priority():
|
||||
)
|
||||
def test_expand_json_human_readable_numbers(input_json, expected_json):
|
||||
assert _expand_json_human_readable_numbers(input_json) == expected_json
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"uri",
|
||||
["s3://bucket/model", "gs://bucket/model", "az://container/model"],
|
||||
)
|
||||
def test_cloud_storage_uri_skips_get_model_path(uri, monkeypatch):
|
||||
"""Cloud storage URIs should not be passed to get_model_path()
|
||||
when HF_HUB_OFFLINE=1, as they are not valid HF repo IDs."""
|
||||
import huggingface_hub
|
||||
|
||||
monkeypatch.setattr(huggingface_hub.constants, "HF_HUB_OFFLINE", True)
|
||||
|
||||
args = EngineArgs(model=uri)
|
||||
# model should remain the original cloud URI, not raise
|
||||
assert args.model == uri
|
||||
|
||||
|
||||
def test_cloud_storage_tokenizer_skips_get_model_path(monkeypatch):
|
||||
"""Cloud storage tokenizer URI should not be passed to
|
||||
get_model_path() when HF_HUB_OFFLINE=1."""
|
||||
import huggingface_hub
|
||||
|
||||
monkeypatch.setattr(huggingface_hub.constants, "HF_HUB_OFFLINE", True)
|
||||
|
||||
args = EngineArgs(model="s3://bucket/model", tokenizer="s3://bucket/tokenizer")
|
||||
assert args.model == "s3://bucket/model"
|
||||
assert args.tokenizer == "s3://bucket/tokenizer"
|
||||
|
||||
@@ -754,6 +754,26 @@ def test_s3_url_different_models_create_different_directories(mock_pull_files):
|
||||
assert os.path.exists(config2.tokenizer) and os.path.isdir(config2.tokenizer)
|
||||
|
||||
|
||||
@patch("vllm.transformers_utils.runai_utils.ObjectStorageModel.pull_files")
|
||||
def test_s3_url_different_model_and_tokenizer(mock_pull_files):
|
||||
"""Test that when model and tokenizer are different cloud URIs,
|
||||
pull_files receives the correct URI for each."""
|
||||
mock_pull_files.return_value = None
|
||||
|
||||
model_url = "s3://bucket/model/"
|
||||
tokenizer_url = "s3://bucket/tokenizer/"
|
||||
|
||||
config = MockConfig(model=model_url, tokenizer=tokenizer_url)
|
||||
ModelConfig.maybe_pull_model_tokenizer_for_runai(config, model_url, tokenizer_url)
|
||||
|
||||
# pull_files should be called twice: once for model, once for tokenizer
|
||||
assert mock_pull_files.call_count == 2
|
||||
# First call: model URI with allow_pattern
|
||||
assert mock_pull_files.call_args_list[0][0][0] == model_url
|
||||
# Second call: tokenizer URI with ignore_pattern
|
||||
assert mock_pull_files.call_args_list[1][0][0] == tokenizer_url
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("model_id", "expected_attn_type", "expected_result", "reason"),
|
||||
[
|
||||
|
||||
Reference in New Issue
Block a user