Skip to content

Commit d06c6bb

Browse files
committed
fix tests.
Signed-off-by: Yuchuan <[email protected]>
1 parent 807980f commit d06c6bb

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

tests/python/test_structural_tag_converter.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,20 @@
1212
tokenizer_id = "meta-llama/Llama-3.1-8B-Instruct"
1313

1414

15+
@pytest.fixture(autouse=True)
16+
def disable_profiler(request):
17+
global PROFILER_ON
18+
global profiler
19+
markexpr = getattr(request.config.option, "markexpr", "") or request.config.getoption(
20+
"markexpr", ""
21+
)
22+
hf_token_not_provided = "not hf_token_required" in (markexpr or "")
23+
if hf_token_not_provided:
24+
PROFILER_ON = False
25+
if PROFILER_ON:
26+
profiler = Profiler(tokenizer_id)
27+
28+
1529
class Profiler:
1630
def __init__(self, tokenizer_id: str):
1731
tokenizer = AutoTokenizer.from_pretrained(
@@ -45,10 +59,6 @@ def profile_stag(self, structural_tag_format: Dict[str, Any], instance: str):
4559
print(f"Time to generate mask: {duration / 1000} us, Character: '{char}'")
4660

4761

48-
if PROFILER_ON:
49-
profiler = Profiler(tokenizer_id)
50-
51-
5262
def check_stag_with_grammar(structural_tag_format: Dict[str, Any], expected_grammar_ebnf: str):
5363
structural_tag = {"type": "structural_tag", "format": structural_tag_format}
5464
stag_ebnf = xgr.Grammar.from_structural_tag(structural_tag)

0 commit comments

Comments
 (0)