From cd25bc5c6e3d8d12421990e28666bee6ce120b73 Mon Sep 17 00:00:00 2001 From: codingma Date: Mon, 15 Jul 2024 10:28:07 +0800 Subject: [PATCH 1/5] add IN_GITHUB_ACTIONS Former-commit-id: 3681966a3fe37a1c3d2dd60e54047ced1b2925e5 --- tests/data/test_template.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/data/test_template.py b/tests/data/test_template.py index 1ce1b0d8..4a0dfaa8 100644 --- a/tests/data/test_template.py +++ b/tests/data/test_template.py @@ -26,6 +26,7 @@ if TYPE_CHECKING: HF_TOKEN = os.environ.get("HF_TOKEN", None) +IN_GITHUB_ACTIONS = os.getenv("GITHUB_ACTIONS") == "true" TINY_LLAMA = os.environ.get("TINY_LLAMA", "llamafactory/tiny-random-Llama-3") @@ -121,7 +122,7 @@ def test_jinja_template(use_fast: bool): assert tokenizer.apply_chat_template(MESSAGES) == ref_tokenizer.apply_chat_template(MESSAGES) -@pytest.mark.skipif(HF_TOKEN is None, reason="Gated model.") +@pytest.mark.skipif(IN_GITHUB_ACTIONS or HF_TOKEN is None, reason="Gated model.") def test_gemma_template(): prompt_str = ( "user\nHow are you\n" @@ -133,7 +134,7 @@ def test_gemma_template(): _check_template("google/gemma-2-9b-it", "gemma", prompt_str, answer_str, extra_str="\n") -@pytest.mark.skipif(HF_TOKEN is None, reason="Gated model.") +@pytest.mark.skipif(IN_GITHUB_ACTIONS or HF_TOKEN is None, reason="Gated model.") def test_llama3_template(): prompt_str = ( "<|begin_of_text|><|start_header_id|>user<|end_header_id|>\n\nHow are you<|eot_id|>" From e6b9a7f2e132be51d0fb7e6d64c6df71bd319291 Mon Sep 17 00:00:00 2001 From: hoshi-hiyouga Date: Mon, 15 Jul 2024 22:52:25 +0800 Subject: [PATCH 2/5] Update test_template.py Former-commit-id: 0ada82c60ed3df637acc624e8a382765d4c5f743 --- tests/data/test_template.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/data/test_template.py b/tests/data/test_template.py index 4a0dfaa8..13f9b7bc 100644 --- a/tests/data/test_template.py +++ b/tests/data/test_template.py @@ -26,7 +26,7 @@ if TYPE_CHECKING: HF_TOKEN = os.environ.get("HF_TOKEN", None) -IN_GITHUB_ACTIONS = os.getenv("GITHUB_ACTIONS") == "true" +print(HF_TOKEN) TINY_LLAMA = os.environ.get("TINY_LLAMA", "llamafactory/tiny-random-Llama-3") From 9d22c6877698ef660c0c1f02eaca02e738720046 Mon Sep 17 00:00:00 2001 From: hoshi-hiyouga Date: Mon, 15 Jul 2024 22:55:05 +0800 Subject: [PATCH 3/5] Update test_template.py Former-commit-id: 352afce20adf26f5e616e5aa4e6c7295a865fb1a --- tests/data/test_template.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/data/test_template.py b/tests/data/test_template.py index 13f9b7bc..76bbdfd2 100644 --- a/tests/data/test_template.py +++ b/tests/data/test_template.py @@ -122,7 +122,7 @@ def test_jinja_template(use_fast: bool): assert tokenizer.apply_chat_template(MESSAGES) == ref_tokenizer.apply_chat_template(MESSAGES) -@pytest.mark.skipif(IN_GITHUB_ACTIONS or HF_TOKEN is None, reason="Gated model.") +@pytest.mark.skipif(HF_TOKEN is None, reason="Gated model.") def test_gemma_template(): prompt_str = ( "user\nHow are you\n" @@ -134,7 +134,7 @@ def test_gemma_template(): _check_template("google/gemma-2-9b-it", "gemma", prompt_str, answer_str, extra_str="\n") -@pytest.mark.skipif(IN_GITHUB_ACTIONS or HF_TOKEN is None, reason="Gated model.") +@pytest.mark.skipif(HF_TOKEN is None, reason="Gated model.") def test_llama3_template(): prompt_str = ( "<|begin_of_text|><|start_header_id|>user<|end_header_id|>\n\nHow are you<|eot_id|>" From b024682d80dcf11f3dcdd250ca37a41dff3facdc Mon Sep 17 00:00:00 2001 From: hoshi-hiyouga Date: Mon, 15 Jul 2024 23:00:27 +0800 Subject: [PATCH 4/5] Update test_template.py Former-commit-id: 7da56ea6d4c08d555e179d419c245b27e5611b97 --- tests/data/test_template.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/data/test_template.py b/tests/data/test_template.py index 76bbdfd2..56c57074 100644 --- a/tests/data/test_template.py +++ b/tests/data/test_template.py @@ -26,7 +26,7 @@ if TYPE_CHECKING: HF_TOKEN = os.environ.get("HF_TOKEN", None) -print(HF_TOKEN) +raise ValueError("test: " + str(HF_TOKEN)) TINY_LLAMA = os.environ.get("TINY_LLAMA", "llamafactory/tiny-random-Llama-3") From 2e4b2ed1aa6b89a2697e1497fa18c8898f1eccec Mon Sep 17 00:00:00 2001 From: hoshi-hiyouga Date: Mon, 15 Jul 2024 23:04:39 +0800 Subject: [PATCH 5/5] Update test_template.py Former-commit-id: 470dd92f954a06939d83557fed1201632b0c966b --- tests/data/test_template.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tests/data/test_template.py b/tests/data/test_template.py index 56c57074..c1bc1b4b 100644 --- a/tests/data/test_template.py +++ b/tests/data/test_template.py @@ -26,7 +26,6 @@ if TYPE_CHECKING: HF_TOKEN = os.environ.get("HF_TOKEN", None) -raise ValueError("test: " + str(HF_TOKEN)) TINY_LLAMA = os.environ.get("TINY_LLAMA", "llamafactory/tiny-random-Llama-3") @@ -122,7 +121,7 @@ def test_jinja_template(use_fast: bool): assert tokenizer.apply_chat_template(MESSAGES) == ref_tokenizer.apply_chat_template(MESSAGES) -@pytest.mark.skipif(HF_TOKEN is None, reason="Gated model.") +@pytest.mark.skipif(not HF_TOKEN, reason="Gated model.") def test_gemma_template(): prompt_str = ( "user\nHow are you\n" @@ -134,7 +133,7 @@ def test_gemma_template(): _check_template("google/gemma-2-9b-it", "gemma", prompt_str, answer_str, extra_str="\n") -@pytest.mark.skipif(HF_TOKEN is None, reason="Gated model.") +@pytest.mark.skipif(not HF_TOKEN, reason="Gated model.") def test_llama3_template(): prompt_str = ( "<|begin_of_text|><|start_header_id|>user<|end_header_id|>\n\nHow are you<|eot_id|>"