feat(pipeline): Enhance configuration filename handling and state file naming

- Introduced support for custom configuration filenames in the `save_pretrained` method, allowing users to specify a filename instead of the default.
- Improved state file naming to include step indices, preventing conflicts when multiple processors of the same type are saved.
- Added automatic detection for configuration files when loading from a directory, with error handling for multiple files.
- Updated tests to validate new features, including custom filenames and automatic config detection.
This commit is contained in:
Adil Zouitine
2025-07-22 14:35:34 +02:00
parent 409ac0baca
commit 4ba23ea029
3 changed files with 535 additions and 16 deletions
+2 -2
View File
@@ -225,7 +225,7 @@ def test_save_and_load_pretrained():
pipeline.save_pretrained(tmp_dir)
# Check files were created
config_path = Path(tmp_dir) / "processor.json"
config_path = Path(tmp_dir) / "testrenameprocessor.json" # Based on name="TestRenameProcessor"
assert config_path.exists()
# No state files should be created for RenameProcessor
@@ -283,7 +283,7 @@ def test_registry_based_save_load():
# Verify config uses registry name
import json
with open(Path(tmp_dir) / "processor.json") as f:
with open(Path(tmp_dir) / "robotprocessor.json") as f: # Default name is "RobotProcessor"
config = json.load(f)
assert "registry_name" in config["steps"][0]