3131
3232class InitCallback (Callback ):
3333 """Callback class for:
34- 1. Parse config dict from given yaml file and check its validity, complete missing items by its' default values .
34+ 1. Parse config dict from given yaml file and check its validity.
3535 2. Fixing random seed to 'config.seed'.
3636 3. Initialize logger while creating output directory(if not exist).
37+ 4. Enable prim mode if specified.
3738
3839 NOTE: This callback is mainly for reducing unnecessary duplicate code in each
3940 examples code when runing with hydra.
@@ -60,8 +61,6 @@ class InitCallback(Callback):
6061 """
6162
6263 def on_job_start (self , config : DictConfig , ** kwargs : Any ) -> None :
63- # check given cfg using pre-defined pydantic schema in 'SolverConfig', error(s) will be raised
64- # if any checking failed at this step
6564 if importlib .util .find_spec ("pydantic" ) is not None :
6665 from pydantic import ValidationError
6766 else :
@@ -76,8 +75,6 @@ def on_job_start(self, config: DictConfig, **kwargs: Any) -> None:
7675 # error(s) will be printed and exit program if any checking failed at this step
7776 try :
7877 _model_pydantic = config_module .SolverConfig (** dict (config ))
79- # complete missing items with default values pre-defined in pydantic schema in
80- # 'SolverConfig'
8178 full_cfg = DictConfig (_model_pydantic .model_dump ())
8279 except ValidationError as e :
8380 print (e )
@@ -100,7 +97,7 @@ def on_job_start(self, config: DictConfig, **kwargs: Any) -> None:
10097
10198 # enable prim if specified
10299 if "prim" in full_cfg and bool (full_cfg .prim ):
103- # Mostly for dy2st running, will be removed in the future
100+ # Mostly for compiler running with dy2st.
104101 from paddle .framework import core
105102
106103 core .set_prim_eager_enabled (True )
0 commit comments