Skip to content

Commit 9b3f34b

Browse files
nv-alichengclaude
andcommitted
test(templates): unblock TestTemplateIntegration without HF_TOKEN
The 6 generated-template integration tests were skipped unconditionally in CI/dev because the template placeholders default to gated meta-llama/Llama-3.1-* repos that require HF_TOKEN to fetch the tokenizer. Substitute TinyLlama/TinyLlama-1.1B-Chat-v1.0 for the model name in _resolve_template after placeholder expansion. TinyLlama is non-gated (~1MB tokenizer download), shares the Llama-family tokenizer the templates were written against, and the echo-server path doesn't care about model identity — only that AutoTokenizer.from_pretrained succeeds for the metrics aggregator's ISL/OSL/TPOT triggers. Drops the @pytest.mark.skipif(not HF_TOKEN) decorator, removes the now- unused os import. Effect: integration suite goes from 20 passed / 8 skipped to 26 passed / 2 skipped. The remaining 2 skips need real LLM servers (vLLM/SGLang) which aren't in scope. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 78d2573 commit 9b3f34b

1 file changed

Lines changed: 20 additions & 7 deletions

File tree

tests/integration/commands/test_benchmark_command.py

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
"""Integration tests for benchmark commands against echo server."""
1717

1818
import json
19-
import os
2019
import re
2120
from pathlib import Path
2221

@@ -184,11 +183,22 @@ def test_mode_logging(self, mock_http_echo_server, ds_dataset_path, caplog):
184183
)
185184

186185

186+
# Non-gated tokenizer model used in place of the templates' default
187+
# (which references gated meta-llama/Llama-3.1-*). The echo-server e2e
188+
# path doesn't care about the model identity, only that the tokenizer
189+
# exists for the metrics aggregator's ISL/OSL/TPOT triggers. TinyLlama's
190+
# tokenizer is ~1MB and matches the Llama-family tokenizer the templates
191+
# were written against.
192+
_TEST_MODEL_NAME = "TinyLlama/TinyLlama-1.1B-Chat-v1.0"
193+
194+
187195
def _resolve_template(template_path: Path, server_url: str) -> dict:
188196
"""Load a template YAML, strip <PLACEHOLDER> wrappers, and patch for testing.
189197
190-
Only replaces placeholders with working values and caps n_samples_to_issue.
191-
Everything else stays as the template defines it.
198+
Replaces placeholders with working values, swaps the gated default
199+
model for a non-gated tokenizer (so tests run without ``HF_TOKEN``),
200+
and caps ``n_samples_to_issue``. Everything else stays as the template
201+
defines it.
192202
"""
193203
raw = template_path.read_text()
194204
# Strip <PLACEHOLDER eg: value> → value (all templates use eg: form)
@@ -197,6 +207,13 @@ def _resolve_template(template_path: Path, server_url: str) -> dict:
197207
raw = re.sub(r"http://localhost:\d+", server_url, raw)
198208
data = yaml.safe_load(raw)
199209

210+
# Swap any gated default model name for a non-gated tokenizer. The
211+
# generated templates' "eg: meta-llama/Llama-3.1-8B-Instruct" placeholder
212+
# points at a gated repo; substituting gpt2 lets these tests run in CI
213+
# without HF_TOKEN.
214+
if "model_params" in data and isinstance(data["model_params"], dict):
215+
data["model_params"]["name"] = _TEST_MODEL_NAME
216+
200217
# Cap total samples so test finishes in seconds
201218
data.setdefault("settings", {})
202219
data["settings"].setdefault("runtime", {})
@@ -213,10 +230,6 @@ class TestTemplateIntegration:
213230
"""Verify generated templates run end-to-end against a local server."""
214231

215232
@pytest.mark.integration
216-
@pytest.mark.skipif(
217-
not os.environ.get("HF_TOKEN"),
218-
reason="Templates reference gated HF models; requires HF_TOKEN to fetch tokenizer",
219-
)
220233
@pytest.mark.parametrize("template", _GENERATED_TEMPLATES)
221234
def test_template_runs(self, mock_http_echo_server, tmp_path, caplog, template):
222235
data = _resolve_template(TEMPLATE_DIR / template, mock_http_echo_server.url)

0 commit comments

Comments
 (0)