Restore a specific version of a benchmark.
(self, name: str, version: str, auto_initialize: bool = True)
| 389 | return config.instance if config else None |
| 390 | |
| 391 | async def restore(self, name: str, version: str, auto_initialize: bool = True) -> Optional[BenchmarkConfig]: |
| 392 | """Restore a specific version of a benchmark.""" |
| 393 | version_config = None |
| 394 | if name in self._benchmark_history_versions: |
| 395 | version_config = self._benchmark_history_versions[name].get(version) |
| 396 | |
| 397 | if version_config is None: |
| 398 | logger.warning(f"| ⚠️ Version {version} not found for benchmark {name}") |
| 399 | return None |
| 400 | |
| 401 | restored_config = BenchmarkConfig(**version_config.model_dump()) |
| 402 | self._benchmark_configs[name] = restored_config |
| 403 | |
| 404 | version_history = await version_manager.get_version_history("benchmark", name) |
| 405 | if version_history: |
| 406 | if version not in version_history.versions: |
| 407 | await version_manager.register_version("benchmark", name, version) |
| 408 | version_history.current_version = version |
| 409 | else: |
| 410 | await version_manager.register_version("benchmark", name, version) |
| 411 | |
| 412 | if auto_initialize and restored_config.cls is not None: |
| 413 | await self.build(restored_config) |
| 414 | |
| 415 | await self.save_to_json() |
| 416 | logger.info(f"| 🔄 Restored benchmark {name} to version {version}") |
| 417 | return restored_config |
| 418 | |
| 419 | async def save_to_json(self): |
| 420 | """Save all benchmark configurations with history to JSON.""" |
nothing calls this directly
no test coverage detected