Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Enh] add validation for hydra config #769

Merged

Conversation

HydrogenSulfate
Copy link
Collaborator

@HydrogenSulfate HydrogenSulfate commented Jan 23, 2024

PR types

Function optimization

PR changes

APIs

Describe

内容主要来自 #737 的部分commit,完成 #233 (review) 的TODO

  1. 在callbacks中添加对config的检查,当检查项不符合时抛出错误并退出程序(必须手动调用sys.exit退出,因为hydra的callback机制会将抛出的错误转为warnings),并添加对应单测
  2. 对部分函数和打印信息进行优化

Copy link

paddle-bot bot commented Jan 23, 2024

Thanks for your contribution!

ppsci/utils/config.py Outdated Show resolved Hide resolved
def log_freq_check(cls, v):
if not isinstance(v, int):
raise ValueError(
"'log_freq' should be a int" f", but got {misc.typename(v)}"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

此行修改下,把f 移到行首吧

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已修改

)
if not isinstance(info.data["wandb_config"], dict):
raise ValueError(
f"'wandb_config' should be a dict when 'use_wandb' is True, "
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

删除 f

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已删除

Copy link
Collaborator

@zhiminzhang0830 zhiminzhang0830 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@zhiminzhang0830 zhiminzhang0830 merged commit 67b5a61 into PaddlePaddle:develop Jan 23, 2024
3 checks passed
@HydrogenSulfate HydrogenSulfate deleted the add_config_validation branch January 23, 2024 13:19
huohuohuohuohuo123 pushed a commit to huohuohuohuohuo123/PaddleScience that referenced this pull request Aug 12, 2024
* add validation for hydra config

* update unitest for pydantic

* fix for OptimizerList

* fix
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants