From 02f954050963ccd75609aafbe35f368ff2987779 Mon Sep 17 00:00:00 2001 From: testbot Date: Thu, 9 Mar 2023 10:29:04 +0100 Subject: [PATCH 1/2] Remove set_access_token usage + fail tests if FutureWarning --- setup.cfg | 4 +++- 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 +-- 12 files changed, 14 insertions(+), 23 deletions(-) diff --git a/setup.cfg b/setup.cfg index 9a56ddc2fc65..fded0918d0c4 100644 --- a/setup.cfg +++ b/setup.cfg @@ -14,4 +14,6 @@ ignore = E203, E501, E741, W503, W605 max-line-length = 119 [tool:pytest] -doctest_optionflags=NUMBER NORMALIZE_WHITESPACE ELLIPSIS \ No newline at end of file +doctest_optionflags=NUMBER NORMALIZE_WHITESPACE ELLIPSIS +filterwarnings = + error::FutureWarning:huggingface_hub* # Test fails if a FutureWarning is thrown by `huggingface_hub` \ No newline at end of file diff --git a/tests/generation/test_configuration_utils.py b/tests/generation/test_configuration_utils.py index 8add735a0bf0..a12b35968283 100644 --- a/tests/generation/test_configuration_utils.py +++ b/tests/generation/test_configuration_utils.py @@ -17,7 +17,7 @@ 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 a880bc0a084a..e0bb4946f702 100644 --- a/tests/models/auto/test_processor_auto.py +++ b/tests/models/auto/test_processor_auto.py @@ -21,7 +21,7 @@ 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 68207b9ca189..f43f439ac279 100644 --- a/tests/pipelines/test_pipelines_common.py +++ b/tests/pipelines/test_pipelines_common.py @@ -21,7 +21,7 @@ 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 dc9927f19385..d2172491f982 100644 --- a/tests/test_configuration_common.py +++ b/tests/test_configuration_common.py @@ -23,7 +23,7 @@ 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 ee8dfefb8406..f26709e2d9a6 100644 --- a/tests/test_feature_extraction_common.py +++ b/tests/test_feature_extraction_common.py @@ -22,7 +22,7 @@ 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 32be6e0e6330..12cdef7a47c7 100644 --- a/tests/test_image_processing_common.py +++ b/tests/test_image_processing_common.py @@ -22,7 +22,7 @@ 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 5cb04edbb192..cb06400e9a77 100755 --- a/tests/test_modeling_common.py +++ b/tests/test_modeling_common.py @@ -30,7 +30,7 @@ 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 76e4d6c88154..5578b7893608 100644 --- a/tests/test_modeling_flax_common.py +++ b/tests/test_modeling_flax_common.py @@ -21,7 +21,7 @@ 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 42db9aea2698..26e567530ec2 100644 --- a/tests/test_modeling_tf_common.py +++ b/tests/test_modeling_tf_common.py @@ -28,7 +28,7 @@ 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 965a059c7719..a8bdb7372b8f 100644 --- a/tests/test_tokenization_common.py +++ b/tests/test_tokenization_common.py @@ -30,7 +30,7 @@ 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 2ff81e5fe7bf..274ee76e53c8 100644 --- a/tests/trainer/test_trainer.py +++ b/tests/trainer/test_trainer.py @@ -29,7 +29,7 @@ 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 From d95a6c5e673cb6a156330eecee289acf65ebcda6 Mon Sep 17 00:00:00 2001 From: testbot Date: Thu, 9 Mar 2023 14:43:15 +0100 Subject: [PATCH 2/2] do not fail on FutureWarning in CI --- setup.cfg | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/setup.cfg b/setup.cfg index fded0918d0c4..9a56ddc2fc65 100644 --- a/setup.cfg +++ b/setup.cfg @@ -14,6 +14,4 @@ ignore = E203, E501, E741, W503, W605 max-line-length = 119 [tool:pytest] -doctest_optionflags=NUMBER NORMALIZE_WHITESPACE ELLIPSIS -filterwarnings = - error::FutureWarning:huggingface_hub* # Test fails if a FutureWarning is thrown by `huggingface_hub` \ No newline at end of file +doctest_optionflags=NUMBER NORMALIZE_WHITESPACE ELLIPSIS \ No newline at end of file