refactor(processor): replace ModelHubMixin with HubMixin and enhance save_pretrained method (#1937)

- Updated DataProcessorPipeline to use HubMixin instead of ModelHubMixin for improved functionality.
- Refactored save_pretrained method to handle saving
This commit is contained in:
Adil Zouitine
2025-09-15 13:13:35 +02:00
committed by GitHub
parent 40e9ddd1ed
commit 066308ceb8
2 changed files with 142 additions and 74 deletions
+7 -4
View File
@@ -1736,12 +1736,14 @@ def test_from_pretrained_nonexistent_path():
with pytest.raises(FileNotFoundError):
DataProcessorPipeline.from_pretrained("/path/that/does/not/exist")
# Test with a Hub repo format that would be a local path (too many slashes)
# Test with a path that doesn't exist as a directory
with pytest.raises(FileNotFoundError):
DataProcessorPipeline.from_pretrained("user/repo/extra/path")
# Test with a non-existent but valid Hub repo format (now requires config_filename)
with pytest.raises(ValueError, match="you must specify the config_filename parameter"):
# Test with a Hub repo without specifying config_filename (should raise ValueError)
with pytest.raises(
ValueError, match="When loading from Hugging Face Hub, 'config_filename' must be specified"
):
DataProcessorPipeline.from_pretrained("nonexistent-user/nonexistent-repo")
# Test with a non-existent Hub repo when config_filename is provided
@@ -1752,7 +1754,8 @@ def test_from_pretrained_nonexistent_path():
# Test with a local directory that exists but has no config files
with tempfile.TemporaryDirectory() as tmp_dir:
with pytest.raises(FileNotFoundError, match="No .json configuration files found"):
# Since the directory exists but has no config, it will try Hub and fail
with pytest.raises(FileNotFoundError):
DataProcessorPipeline.from_pretrained(tmp_dir)