Recipe record for scenario list.
| 29 | |
| 30 | |
| 31 | class Recipe(BaseModel): |
| 32 | """Recipe record for scenario list.""" |
| 33 | |
| 34 | model: str = Field(description="Model name") |
| 35 | gpu: str = Field(description="GPU name") |
| 36 | isl: int = Field(description="Input sequence length") |
| 37 | osl: int = Field(description="Output sequence length") |
| 38 | concurrency: int = Field(description="Concurrency") |
| 39 | config_path: str = Field(description="Configuration path") |
| 40 | num_gpus: int = Field(description="Number of GPUs") |
| 41 | |
| 42 | def load_config(self) -> Dict[str, Any]: |
| 43 | """Load and return the YAML config at config_path.""" |
| 44 | config_relative_path = Path(self.config_path) |
| 45 | # Ensure config path is within the repo root |
| 46 | if config_relative_path.is_absolute() or ".." in config_relative_path.parts: |
| 47 | raise ValueError(f"Invalid config path: {self.config_path}") |
| 48 | full_path = REPO_ROOT / self.config_path |
| 49 | if not full_path.exists(): |
| 50 | raise FileNotFoundError(f"Config not found: {full_path}") |
| 51 | with open(full_path, encoding="utf-8") as f: |
| 52 | return yaml.safe_load(f) |
| 53 | |
| 54 | |
| 55 | class RecipeList(RootModel[List[Recipe]]): |