From f32303d519d75782c61259daf10c0d657f714c9d Mon Sep 17 00:00:00 2001 From: Sylvain Gugger <35901082+sgugger@users.noreply.github.com> Date: Thu, 13 Jul 2023 15:25:45 -0400 Subject: [PATCH] Run hub tests (#24807) * Run hub tests * [all-test] Run tests please! * [all-test] Add vision dep for hub tests * Fix tests --- .circleci/create_circleci_config.py | 3 ++- tests/test_image_processing_utils.py | 24 ++++++++++++------------ 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/.circleci/create_circleci_config.py b/.circleci/create_circleci_config.py index f44b500a80a..63894cddd1b 100644 --- a/.circleci/create_circleci_config.py +++ b/.circleci/create_circleci_config.py @@ -398,12 +398,13 @@ examples_flax_job = CircleCIJob( hub_job = CircleCIJob( "hub", + additional_env={"HUGGINGFACE_CO_STAGING": True}, install_steps=[ "sudo apt-get -y update && sudo apt-get install git-lfs", 'git config --global user.email "ci@dummy.com"', 'git config --global user.name "ci"', "pip install --upgrade --upgrade-strategy eager pip", - "pip install -U --upgrade-strategy eager .[torch,sentencepiece,testing]", + "pip install -U --upgrade-strategy eager .[torch,sentencepiece,testing,vision]", ], marker="is_staging_test", pytest_num_workers=1, diff --git a/tests/test_image_processing_utils.py b/tests/test_image_processing_utils.py index d74da63249b..5211a541d3e 100644 --- a/tests/test_image_processing_utils.py +++ b/tests/test_image_processing_utils.py @@ -57,6 +57,17 @@ class ImageProcessorUtilTester(unittest.TestCase): "https://huggingface.co/hf-internal-testing/tiny-random-vit/resolve/main/preprocessor_config.json" ) + def test_image_processor_from_pretrained_subfolder(self): + with self.assertRaises(OSError): + # config is in subfolder, the following should not work without specifying the subfolder + _ = AutoImageProcessor.from_pretrained("hf-internal-testing/stable-diffusion-all-variants") + + config = AutoImageProcessor.from_pretrained( + "hf-internal-testing/stable-diffusion-all-variants", subfolder="feature_extractor" + ) + + self.assertIsNotNone(config) + @is_staging_test class ImageProcessorPushToHubTester(unittest.TestCase): @@ -133,7 +144,7 @@ class ImageProcessorPushToHubTester(unittest.TestCase): # This has added the proper auto_map field to the config self.assertDictEqual( image_processor.auto_map, - {"ImageProcessor": "custom_image_processing.CustomImageProcessor"}, + {"AutoImageProcessor": "custom_image_processing.CustomImageProcessor"}, ) new_image_processor = AutoImageProcessor.from_pretrained( @@ -141,14 +152,3 @@ class ImageProcessorPushToHubTester(unittest.TestCase): ) # Can't make an isinstance check because the new_image_processor is from the CustomImageProcessor class of a dynamic module self.assertEqual(new_image_processor.__class__.__name__, "CustomImageProcessor") - - def test_image_processor_from_pretrained_subfolder(self): - with self.assertRaises(OSError): - # config is in subfolder, the following should not work without specifying the subfolder - _ = AutoImageProcessor.from_pretrained("hf-internal-testing/stable-diffusion-all-variants") - - config = AutoImageProcessor.from_pretrained( - "hf-internal-testing/stable-diffusion-all-variants", subfolder="feature_extractor" - ) - - self.assertIsNotNone(config)