Clean up utils.hub using the latest from hf_hub (#18857)

* Clean up utils.hub using the latest from hf_hub

* Adapt test

* Address review comment

* Fix test
This commit is contained in:
Sylvain Gugger
2022-09-02 10:30:06 -04:00
committed by GitHub
parent 17981faf67
commit 38c3cd52fb
5 changed files with 44 additions and 70 deletions

View File

@@ -14,10 +14,10 @@
import os
import unittest
from unittest.mock import patch
import transformers.models.bart.tokenization_bart
from transformers import AutoConfig, logging
from huggingface_hub.utils import are_progress_bars_disabled
from transformers import logging
from transformers.testing_utils import CaptureLogger, mockenv, mockenv_context
from transformers.utils.logging import disable_progress_bar, enable_progress_bar
@@ -126,14 +126,8 @@ class HfArgumentParserTest(unittest.TestCase):
def test_set_progress_bar_enabled():
TINY_MODEL = "hf-internal-testing/tiny-random-distilbert"
with patch("tqdm.auto.tqdm") as mock_tqdm:
disable_progress_bar()
_ = AutoConfig.from_pretrained(TINY_MODEL, force_download=True)
mock_tqdm.assert_not_called()
disable_progress_bar()
assert are_progress_bars_disabled()
mock_tqdm.reset_mock()
enable_progress_bar()
_ = AutoConfig.from_pretrained(TINY_MODEL, force_download=True)
mock_tqdm.assert_called()
enable_progress_bar()
assert not are_progress_bars_disabled()