1919from typing import Any , Dict , List , Optional , Type
2020
2121import yaml
22- from pydantic import Field
22+ from pydantic import Field , model_validator
2323
2424from ...base_generator import CommandGenerator
2525from ...interface import BasePluginConfig , WorkloadPlugin
@@ -77,7 +77,7 @@ class PhoronixConfig(BasePluginConfig):
7777
7878 batch_mode : bool = Field (
7979 default = True ,
80- description = "Prefer batch-* PTS commands to avoid interactive prompts ." ,
80+ description = "Batch mode is required for PTS workloads (non-batch is unsupported) ." ,
8181 )
8282 install_system_packages : bool = Field (
8383 default = True ,
@@ -95,6 +95,12 @@ class PhoronixConfig(BasePluginConfig):
9595 description = "Additional arguments appended to the PTS command." ,
9696 )
9797
98+ @model_validator (mode = "after" )
99+ def _require_batch_mode (self ) -> "PhoronixConfig" :
100+ if not self .batch_mode :
101+ raise ValueError ("PTS workloads require batch mode (batch_mode=True)." )
102+ return self
103+
98104
99105class PhoronixGenerator (CommandGenerator ):
100106 """Workload generator that runs a single PTS test-profile."""
@@ -144,8 +150,6 @@ def _require_batch_setup(self, env: Dict[str, str]) -> None:
144150 pts_user_path = env .get ("PTS_USER_PATH_OVERRIDE" , "" )
145151 if not pts_user_path :
146152 return
147- if not self .config .batch_mode :
148- return
149153 if self ._is_batch_configured (pts_user_path ):
150154 return
151155 raise RuntimeError (
@@ -234,8 +238,7 @@ def _build_command_for(self, subcommand: str) -> List[str]:
234238 return cmd
235239
236240 def _build_command (self ) -> List [str ]:
237- subcommand = "batch-benchmark" if self .config .batch_mode else "benchmark"
238- return self ._build_command_for (subcommand )
241+ return self ._build_command_for ("batch-benchmark" )
239242
240243 def _run_command (self ) -> None :
241244 start = time .time ()
@@ -257,10 +260,7 @@ def _run_command(self) -> None:
257260 except Exception :
258261 before = set ()
259262
260- cmd = self ._build_command_for (
261- "batch-benchmark" if self .config .batch_mode else "benchmark"
262- )
263- cmd_fallback = self ._build_command_for ("benchmark" )
263+ cmd = self ._build_command_for ("batch-benchmark" )
264264
265265 def _run (cmd_to_run : List [str ]) -> tuple [int , str ]:
266266 logger .info ("Running PTS command: %s" , " " .join (cmd_to_run ))
@@ -301,18 +301,6 @@ def _run(cmd_to_run: List[str]) -> tuple[int, str]:
301301
302302 try :
303303 rc , out = _run (cmd )
304- # If batch mode is not supported or not configured, fall back to benchmark.
305- if rc != 0 and self .config .batch_mode and any (
306- token in out .lower ()
307- for token in (
308- "unknown command" ,
309- "invalid command" ,
310- "not a supported command" ,
311- "the batch mode must first be configured" ,
312- )
313- ):
314- rc , out = _run (cmd_fallback )
315-
316304 output_lower = out .lower ()
317305 if (
318306 "[problem]" in output_lower
0 commit comments