33from __future__ import annotations
44
55from dataclasses import dataclass , field
6- from typing import Any , Dict , List , Optional
6+ from typing import Any
77
88from llama_stack .apis .eval import BenchmarkConfig , EvalCandidate
99from llama_stack .schema_utils import json_schema_type
@@ -18,8 +18,8 @@ class TLSConfig:
1818 """TLS configuration for the LMEval provider."""
1919
2020 enable : bool
21- cert_file : Optional [ str ] = None
22- cert_secret : Optional [ str ] = None
21+ cert_file : str | None = None
22+ cert_secret : str | None = None
2323
2424 def __post_init__ (self ):
2525 """Validate the configuration"""
@@ -30,10 +30,10 @@ def __post_init__(self):
3030 )
3131
3232 # Validate certificate file name is safe
33- if not isinstance (self .cert_file , str ) or not isinstance (self . cert_secret , str ):
34- raise LMEvalConfigError (
35- "cert_file and cert_secret must be strings"
36- )
33+ if not isinstance (self .cert_file , str ) or not isinstance (
34+ self . cert_secret , str
35+ ):
36+ raise LMEvalConfigError ( "cert_file and cert_secret must be strings" )
3737
3838 if not self .cert_file .strip () or not self .cert_secret .strip ():
3939 raise LMEvalConfigError (
@@ -48,14 +48,18 @@ def __post_init__(self):
4848
4949 # Allow only alphanumeric characters, dots, hyphens, underscores, and forward slashes
5050 # Remove allowed characters to check if remaining characters are safe
51- safe_chars = self .cert_file .replace ('.' , '' ).replace ('-' , '' ).replace ('_' , '' ).replace ('/' , '' )
51+ safe_chars = (
52+ self .cert_file .replace ("." , "" )
53+ .replace ("-" , "" )
54+ .replace ("_" , "" )
55+ .replace ("/" , "" )
56+ )
5257 if not safe_chars .isalnum ():
5358 raise LMEvalConfigError (
5459 f"cert_file contains potentially unsafe characters: { self .cert_file } "
5560 )
5661
5762
58-
5963@json_schema_type
6064@dataclass
6165class LMEvalBenchmarkConfig (BenchmarkConfig ):
@@ -74,8 +78,8 @@ class LMEvalBenchmarkConfig(BenchmarkConfig):
7478 model : str = Field (description = "Name of the model" )
7579 # FIXME: mode is only present temporarily and for debug purposes, it will be removed
7680 # mode: str = Field(description="Mode of the benchmark", default="production")
77- env_vars : Optional [ List [ Dict [ str , str ]]] = None
78- metadata : Optional [ Dict [ str , Any ]] = None
81+ env_vars : list [ dict [ str , str ]] | None = None
82+ metadata : dict [ str , Any ] | None = None
7983
8084 def __post_init__ (self ):
8185 """Validate the configuration"""
@@ -89,11 +93,11 @@ class K8sLMEvalConfig:
8993 """Configuration for Kubernetes LMEvalJob CR"""
9094
9195 model : str
92- model_args : Optional [ List [ Dict [ str , str ]]] = field (default_factory = list )
93- task_list : Optional [ Dict [ str , List [str ]]] = None
96+ model_args : list [ dict [ str , str ]] | None = field (default_factory = list )
97+ task_list : dict [ str , list [str ]] | None = None
9498 log_samples : bool = True
9599 namespace : str = "default"
96- env_vars : Optional [ List [ Dict [ str , str ]]] = None
100+ env_vars : list [ dict [ str , str ]] | None = None
97101
98102 def __post_init__ (self ):
99103 """Validate the configuration"""
@@ -113,14 +117,14 @@ class LMEvalEvalProviderConfig:
113117 # FIXME: Hardcoded just for debug purposes
114118 base_url : str = "http://llamastack-service:8321"
115119 namespace : str | None = None
116- kubeconfig_path : Optional [ str ] = None
120+ kubeconfig_path : str | None = None
117121 # Service account to use for Kubernetes deployment
118- service_account : Optional [ str ] = None
122+ service_account : str | None = None
119123 # Default tokenizer to use when none is specified in the ModelCandidate
120124 default_tokenizer : str = "google/flan-t5-base"
121- metadata : Optional [ Dict [ str , Any ]] = None
125+ metadata : dict [ str , Any ] | None = None
122126 # TLS configuration - structured approach
123- tls : Optional [ TLSConfig ] = None
127+ tls : TLSConfig | None = None
124128
125129 def __post_init__ (self ):
126130 """Validate the configuration"""
0 commit comments