Run hub tests (#24807)
* Run hub tests * [all-test] Run tests please! * [all-test] Add vision dep for hub tests * Fix tests
This commit is contained in:
parent
9d7a0871e2
commit
f32303d519
|
@ -398,12 +398,13 @@ examples_flax_job = CircleCIJob(
|
||||||
|
|
||||||
hub_job = CircleCIJob(
|
hub_job = CircleCIJob(
|
||||||
"hub",
|
"hub",
|
||||||
|
additional_env={"HUGGINGFACE_CO_STAGING": True},
|
||||||
install_steps=[
|
install_steps=[
|
||||||
"sudo apt-get -y update && sudo apt-get install git-lfs",
|
"sudo apt-get -y update && sudo apt-get install git-lfs",
|
||||||
'git config --global user.email "ci@dummy.com"',
|
'git config --global user.email "ci@dummy.com"',
|
||||||
'git config --global user.name "ci"',
|
'git config --global user.name "ci"',
|
||||||
"pip install --upgrade --upgrade-strategy eager pip",
|
"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",
|
marker="is_staging_test",
|
||||||
pytest_num_workers=1,
|
pytest_num_workers=1,
|
||||||
|
|
|
@ -57,6 +57,17 @@ class ImageProcessorUtilTester(unittest.TestCase):
|
||||||
"https://huggingface.co/hf-internal-testing/tiny-random-vit/resolve/main/preprocessor_config.json"
|
"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
|
@is_staging_test
|
||||||
class ImageProcessorPushToHubTester(unittest.TestCase):
|
class ImageProcessorPushToHubTester(unittest.TestCase):
|
||||||
|
@ -133,7 +144,7 @@ class ImageProcessorPushToHubTester(unittest.TestCase):
|
||||||
# This has added the proper auto_map field to the config
|
# This has added the proper auto_map field to the config
|
||||||
self.assertDictEqual(
|
self.assertDictEqual(
|
||||||
image_processor.auto_map,
|
image_processor.auto_map,
|
||||||
{"ImageProcessor": "custom_image_processing.CustomImageProcessor"},
|
{"AutoImageProcessor": "custom_image_processing.CustomImageProcessor"},
|
||||||
)
|
)
|
||||||
|
|
||||||
new_image_processor = AutoImageProcessor.from_pretrained(
|
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
|
# 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")
|
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)
|
|
||||||
|
|
Loading…
Reference in New Issue