Skip to content

Commit

Permalink
update docstring of callbacks.py
Browse files Browse the repository at this point in the history
  • Loading branch information
HydrogenSulfate committed Apr 30, 2024
1 parent b8e39c9 commit 64eedf7
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions ppsci/utils/callbacks.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,10 @@

class InitCallback(Callback):
"""Callback class for:
1. Parse config dict from given yaml file and check its validity, complete missing items by its' default values.
1. Parse config dict from given yaml file and check its validity.
2. Fixing random seed to 'config.seed'.
3. Initialize logger while creating output directory(if not exist).
4. Enable prim mode if specified.
NOTE: This callback is mainly for reducing unnecessary duplicate code in each
examples code when runing with hydra.
Expand All @@ -60,8 +61,6 @@ class InitCallback(Callback):
"""

def on_job_start(self, config: DictConfig, **kwargs: Any) -> None:
# check given cfg using pre-defined pydantic schema in 'SolverConfig', error(s) will be raised
# if any checking failed at this step
if importlib.util.find_spec("pydantic") is not None:
from pydantic import ValidationError
else:
Expand All @@ -76,8 +75,6 @@ def on_job_start(self, config: DictConfig, **kwargs: Any) -> None:
# error(s) will be printed and exit program if any checking failed at this step
try:
_model_pydantic = config_module.SolverConfig(**dict(config))
# complete missing items with default values pre-defined in pydantic schema in
# 'SolverConfig'
full_cfg = DictConfig(_model_pydantic.model_dump())
except ValidationError as e:
print(e)
Expand All @@ -100,7 +97,7 @@ def on_job_start(self, config: DictConfig, **kwargs: Any) -> None:

# enable prim if specified
if "prim" in full_cfg and bool(full_cfg.prim):
# Mostly for dy2st running, will be removed in the future
# Mostly for compiler running with dy2st.
from paddle.framework import core

core.set_prim_eager_enabled(True)
Expand Down

0 comments on commit 64eedf7

Please sign in to comment.