@@ -152,7 +152,7 @@ def create(
152
152
f"Logging is required for fine tuning if replica is larger than { DEFAULT_FT_REPLICA } ."
153
153
)
154
154
155
- ft_parameters = self ._validate_finetuning_params (
155
+ ft_parameters = self ._get_finetuning_params (
156
156
create_fine_tuning_details .ft_parameters
157
157
)
158
158
@@ -591,8 +591,9 @@ def get_finetuning_default_params(self, model_id: str) -> Dict:
591
591
default_params = {"params" : {}}
592
592
finetuning_config = self .get_finetuning_config (model_id )
593
593
config_parameters = finetuning_config .get ("configuration" , UNKNOWN_DICT )
594
- config_parameters ["_validate" ] = False
595
- dataclass_fields = AquaFineTuningParams (** config_parameters ).to_dict ()
594
+ dataclass_fields = self ._get_finetuning_params (
595
+ config_parameters , validate = False
596
+ ).to_dict ()
596
597
for name , value in config_parameters .items ():
597
598
if name in dataclass_fields :
598
599
if name == "micro_batch_size" :
@@ -602,9 +603,17 @@ def get_finetuning_default_params(self, model_id: str) -> Dict:
602
603
return default_params
603
604
604
605
@staticmethod
605
- def _validate_finetuning_params (params : Dict = None ) -> AquaFineTuningParams :
606
+ def _get_finetuning_params (
607
+ params : Dict = None , validate : bool = True
608
+ ) -> AquaFineTuningParams :
609
+ """
610
+ Get and validate the fine-tuning params, and return an error message if validation fails. In order to skip
611
+ @model_validator decorator's validation, pass validate=False.
612
+ """
606
613
try :
607
- finetuning_params = AquaFineTuningParams (** params )
614
+ finetuning_params = AquaFineTuningParams (
615
+ ** {** params , ** {"_validate" : validate }}
616
+ )
608
617
except ValidationError as ex :
609
618
# combine both loc and msg for errors where loc (field) is present in error details, else only build error
610
619
# message using msg field. Added to handle error messages from pydantic model validator handler.
@@ -631,5 +640,5 @@ def validate_finetuning_params(self, params: Dict = None) -> Dict:
631
640
-------
632
641
Return a list of restricted params.
633
642
"""
634
- self ._validate_finetuning_params (params or {})
643
+ self ._get_finetuning_params (params or {})
635
644
return {"valid" : True }
0 commit comments