From 923110b74fbef83909035b88c7eb6f7c4b6a8397 Mon Sep 17 00:00:00 2001 From: Lucain Date: Thu, 9 Mar 2023 15:23:48 +0100 Subject: [PATCH] Remove set_access_token usage + fail tests if FutureWarning (#22051) * Remove set_access_token usage + fail tests if FutureWarning * do not fail on FutureWarning in CI --------- Co-authored-by: testbot --- tests/generation/test_configuration_utils.py | 3 +-- tests/models/auto/test_processor_auto.py | 3 +-- tests/pipelines/test_pipelines_common.py | 3 +-- tests/test_configuration_common.py | 3 +-- tests/test_feature_extraction_common.py | 3 +-- tests/test_image_processing_common.py | 3 +-- tests/test_modeling_common.py | 3 +-- tests/test_modeling_flax_common.py | 3 +-- tests/test_modeling_tf_common.py | 3 +-- tests/test_tokenization_common.py | 3 +-- tests/trainer/test_trainer.py | 3 +-- 11 files changed, 11 insertions(+), 22 deletions(-) diff --git a/tests/generation/test_configuration_utils.py b/tests/generation/test_configuration_utils.py index 8add735a0b..a12b359682 100644 --- a/tests/generation/test_configuration_utils.py +++ b/tests/generation/test_configuration_utils.py @@ -17,7 +17,7 @@ import copy import tempfile import unittest -from huggingface_hub import HfFolder, delete_repo, set_access_token +from huggingface_hub import HfFolder, delete_repo from parameterized import parameterized from requests.exceptions import HTTPError @@ -99,7 +99,6 @@ class ConfigPushToHubTester(unittest.TestCase): @classmethod def setUpClass(cls): cls._token = TOKEN - set_access_token(TOKEN) HfFolder.save_token(TOKEN) @classmethod diff --git a/tests/models/auto/test_processor_auto.py b/tests/models/auto/test_processor_auto.py index a880bc0a08..e0bb4946f7 100644 --- a/tests/models/auto/test_processor_auto.py +++ b/tests/models/auto/test_processor_auto.py @@ -21,7 +21,7 @@ import unittest from pathlib import Path from shutil import copyfile -from huggingface_hub import HfFolder, Repository, create_repo, delete_repo, set_access_token +from huggingface_hub import HfFolder, Repository, create_repo, delete_repo from requests.exceptions import HTTPError from transformers import ( @@ -219,7 +219,6 @@ class ProcessorPushToHubTester(unittest.TestCase): @classmethod def setUpClass(cls): cls._token = TOKEN - set_access_token(TOKEN) HfFolder.save_token(TOKEN) @classmethod diff --git a/tests/pipelines/test_pipelines_common.py b/tests/pipelines/test_pipelines_common.py index 68207b9ca1..f43f439ac2 100644 --- a/tests/pipelines/test_pipelines_common.py +++ b/tests/pipelines/test_pipelines_common.py @@ -21,7 +21,7 @@ from pathlib import Path import datasets import numpy as np -from huggingface_hub import HfFolder, Repository, create_repo, delete_repo, set_access_token +from huggingface_hub import HfFolder, Repository, create_repo, delete_repo from requests.exceptions import HTTPError from transformers import ( @@ -759,7 +759,6 @@ class DynamicPipelineTester(unittest.TestCase): @classmethod def setUpClass(cls): cls._token = TOKEN - set_access_token(TOKEN) HfFolder.save_token(TOKEN) @classmethod diff --git a/tests/test_configuration_common.py b/tests/test_configuration_common.py index dc9927f193..d2172491f9 100644 --- a/tests/test_configuration_common.py +++ b/tests/test_configuration_common.py @@ -23,7 +23,7 @@ import unittest import unittest.mock as mock from pathlib import Path -from huggingface_hub import HfFolder, delete_repo, set_access_token +from huggingface_hub import HfFolder, delete_repo from requests.exceptions import HTTPError from transformers import AutoConfig, BertConfig, GPT2Config, is_torch_available @@ -222,7 +222,6 @@ class ConfigPushToHubTester(unittest.TestCase): @classmethod def setUpClass(cls): cls._token = TOKEN - set_access_token(TOKEN) HfFolder.save_token(TOKEN) @classmethod diff --git a/tests/test_feature_extraction_common.py b/tests/test_feature_extraction_common.py index ee8dfefb84..f26709e2d9 100644 --- a/tests/test_feature_extraction_common.py +++ b/tests/test_feature_extraction_common.py @@ -22,7 +22,7 @@ import unittest import unittest.mock as mock from pathlib import Path -from huggingface_hub import HfFolder, delete_repo, set_access_token +from huggingface_hub import HfFolder, delete_repo from requests.exceptions import HTTPError from transformers import AutoFeatureExtractor, Wav2Vec2FeatureExtractor @@ -100,7 +100,6 @@ class FeatureExtractorPushToHubTester(unittest.TestCase): @classmethod def setUpClass(cls): cls._token = TOKEN - set_access_token(TOKEN) HfFolder.save_token(TOKEN) @classmethod diff --git a/tests/test_image_processing_common.py b/tests/test_image_processing_common.py index 32be6e0e63..12cdef7a47 100644 --- a/tests/test_image_processing_common.py +++ b/tests/test_image_processing_common.py @@ -22,7 +22,7 @@ import unittest import unittest.mock as mock from pathlib import Path -from huggingface_hub import HfFolder, delete_repo, set_access_token +from huggingface_hub import HfFolder, delete_repo from requests.exceptions import HTTPError from transformers import AutoImageProcessor, ViTImageProcessor @@ -232,7 +232,6 @@ class ImageProcessorPushToHubTester(unittest.TestCase): @classmethod def setUpClass(cls): cls._token = TOKEN - set_access_token(TOKEN) HfFolder.save_token(TOKEN) @classmethod diff --git a/tests/test_modeling_common.py b/tests/test_modeling_common.py index 5cb04edbb1..cb06400e9a 100755 --- a/tests/test_modeling_common.py +++ b/tests/test_modeling_common.py @@ -30,7 +30,7 @@ from pathlib import Path from typing import Dict, List, Tuple import numpy as np -from huggingface_hub import HfFolder, delete_repo, set_access_token +from huggingface_hub import HfFolder, delete_repo from huggingface_hub.file_download import http_get from pytest import mark from requests.exceptions import HTTPError @@ -3429,7 +3429,6 @@ class ModelPushToHubTester(unittest.TestCase): @classmethod def setUpClass(cls): cls._token = TOKEN - set_access_token(TOKEN) HfFolder.save_token(TOKEN) @classmethod diff --git a/tests/test_modeling_flax_common.py b/tests/test_modeling_flax_common.py index 76e4d6c881..5578b78936 100644 --- a/tests/test_modeling_flax_common.py +++ b/tests/test_modeling_flax_common.py @@ -21,7 +21,7 @@ import unittest from typing import List, Tuple import numpy as np -from huggingface_hub import HfFolder, delete_repo, set_access_token +from huggingface_hub import HfFolder, delete_repo from requests.exceptions import HTTPError import transformers @@ -1173,7 +1173,6 @@ class FlaxModelPushToHubTester(unittest.TestCase): @classmethod def setUpClass(cls): cls._token = TOKEN - set_access_token(TOKEN) HfFolder.save_token(TOKEN) @classmethod diff --git a/tests/test_modeling_tf_common.py b/tests/test_modeling_tf_common.py index 42db9aea26..26e567530e 100644 --- a/tests/test_modeling_tf_common.py +++ b/tests/test_modeling_tf_common.py @@ -28,7 +28,7 @@ from math import isnan from typing import List, Tuple, get_type_hints from datasets import Dataset -from huggingface_hub import HfFolder, Repository, delete_repo, set_access_token +from huggingface_hub import HfFolder, Repository, delete_repo from huggingface_hub.file_download import http_get from requests.exceptions import HTTPError @@ -2409,7 +2409,6 @@ class TFModelPushToHubTester(unittest.TestCase): @classmethod def setUpClass(cls): cls._token = TOKEN - set_access_token(TOKEN) HfFolder.save_token(TOKEN) @classmethod diff --git a/tests/test_tokenization_common.py b/tests/test_tokenization_common.py index 965a059c77..a8bdb7372b 100644 --- a/tests/test_tokenization_common.py +++ b/tests/test_tokenization_common.py @@ -30,7 +30,7 @@ from itertools import takewhile from pathlib import Path from typing import TYPE_CHECKING, Any, Dict, List, Tuple, Union -from huggingface_hub import HfFolder, delete_repo, set_access_token +from huggingface_hub import HfFolder, delete_repo from huggingface_hub.file_download import http_get from parameterized import parameterized from requests.exceptions import HTTPError @@ -3971,7 +3971,6 @@ class TokenizerPushToHubTester(unittest.TestCase): @classmethod def setUpClass(cls): cls._token = TOKEN - set_access_token(TOKEN) HfFolder.save_token(TOKEN) @classmethod diff --git a/tests/trainer/test_trainer.py b/tests/trainer/test_trainer.py index 2ff81e5fe7..274ee76e53 100644 --- a/tests/trainer/test_trainer.py +++ b/tests/trainer/test_trainer.py @@ -29,7 +29,7 @@ from pathlib import Path from unittest.mock import Mock, patch import numpy as np -from huggingface_hub import HfFolder, Repository, delete_repo, set_access_token +from huggingface_hub import HfFolder, Repository, delete_repo from parameterized import parameterized from requests.exceptions import HTTPError @@ -2005,7 +2005,6 @@ class TrainerIntegrationWithHubTester(unittest.TestCase): @classmethod def setUpClass(cls): cls._token = TOKEN - set_access_token(TOKEN) HfFolder.save_token(TOKEN) @classmethod