From b39eead2557368a3b9fa9c859c8453a55c57aad7 Mon Sep 17 00:00:00 2001 From: Ella Charlaix <80481427+echarlaix@users.noreply.github.com> Date: Tue, 11 Jun 2024 17:19:37 +0200 Subject: [PATCH] Update token (#762) * Update token test * udpate model id --- .github/workflows/test_openvino.yml | 2 ++ tests/openvino/test_modeling.py | 14 +++++++------- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/.github/workflows/test_openvino.yml b/.github/workflows/test_openvino.yml index 37cf81fecc..ff38fb41df 100644 --- a/.github/workflows/test_openvino.yml +++ b/.github/workflows/test_openvino.yml @@ -39,6 +39,8 @@ jobs: pip install transformers==${{ matrix.transformers-version }} pip install .[openvino,openvino-tokenizers,tests,diffusers] onnxruntime - name: Test with Pytest + env: + HF_HUB_READ_TOKEN: ${{ secrets.HF_HUB_READ_TOKEN }} run: | pytest tests/openvino/ --ignore tests/openvino/test_modeling_basic.py --durations=0 - name: Test basic diff --git a/tests/openvino/test_modeling.py b/tests/openvino/test_modeling.py index fefb2b4923..5f47114518 100644 --- a/tests/openvino/test_modeling.py +++ b/tests/openvino/test_modeling.py @@ -14,7 +14,6 @@ import gc import os -import subprocess import tempfile import time import unittest @@ -249,13 +248,14 @@ def test_load_from_hub_and_save_stable_diffusion_model(self): gc.collect() def test_load_model_from_hub_private_with_token(self): - subprocess.run("huggingface-cli logout", shell=True) + token = os.environ.get("HF_HUB_READ_TOKEN", None) + if token is None: + self.skipTest("Test requires a token `HF_HUB_READ_TOKEN` in the environment variable") - # a fine-grained read-only token of private repo "IlyasMoutawwakil/test-hub-bert" - token = "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" - - loaded_model = OVModelForMaskedLM.from_pretrained("IlyasMoutawwakil/test-hub-bert", use_auth_token=token) - self.assertIsInstance(loaded_model.config, PretrainedConfig) + model = OVModelForCausalLM.from_pretrained( + "optimum-internal-testing/tiny-random-phi-private", use_auth_token=token, revision="openvino" + ) + self.assertIsInstance(model.config, PretrainedConfig) class OVModelForSequenceClassificationIntegrationTest(unittest.TestCase):