Skip to content

Commit

Permalink
Fix: calling functions for the default value of argument. (#253)
Browse files Browse the repository at this point in the history
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

- **New Features**
- Enhanced flexibility in parameter handling by allowing `prep_config`
and `run_config` to be optional inputs across multiple classes.
- Improved clarity of intent in the constructors by utilizing default
values of `None` for configuration parameters.

- **Bug Fixes**
- Ensured that `prep_config` and `run_config` are initialized to a valid
dictionary structure if not provided, enhancing robustness.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Signed-off-by: zjgemi <[email protected]>
Co-authored-by: zjgemi <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: Han Wang <[email protected]>
  • Loading branch information
5 people committed Aug 22, 2024
1 parent 4967951 commit c9b7c9d
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 10 deletions.
6 changes: 4 additions & 2 deletions dpgen2/superop/prep_run_calypso.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,12 @@ def __init__(
prep_caly_model_devi_op: Type[OP],
run_caly_model_devi_op: Type[OP],
expl_mode: str = "default",
prep_config: dict = normalize_step_dict({}),
run_config: dict = normalize_step_dict({}),
prep_config: Optional[dict] = None,
run_config: Optional[dict] = None,
upload_python_packages: Optional[List[os.PathLike]] = None,
):
prep_config = normalize_step_dict({}) if prep_config is None else prep_config
run_config = normalize_step_dict({}) if run_config is None else run_config
self._input_parameters = {
"block_id": InputParameter(type=str, value=""),
"expl_task_grp": InputParameter(),
Expand Down
6 changes: 4 additions & 2 deletions dpgen2/superop/prep_run_diffcsp.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,12 @@ def __init__(
diffcsp_gen_op: Type[OP],
prep_relax_op: Type[OP],
run_relax_op: Type[OP],
prep_config: dict = normalize_step_dict({}),
run_config: dict = normalize_step_dict({}),
prep_config: Optional[dict] = None,
run_config: Optional[dict] = None,
upload_python_packages: Optional[List[os.PathLike]] = None,
):
prep_config = normalize_step_dict({}) if prep_config is None else prep_config
run_config = normalize_step_dict({}) if run_config is None else run_config
self._input_parameters = {
"block_id": InputParameter(type=str, value=""),
"expl_task_grp": InputParameter(),
Expand Down
6 changes: 4 additions & 2 deletions dpgen2/superop/prep_run_dp_train.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,14 @@ def __init__(
name: str,
prep_train_op: Type[OP],
run_train_op: Type[RunDPTrain],
prep_config: dict = normalize_step_dict({}),
run_config: dict = normalize_step_dict({}),
prep_config: Optional[dict] = None,
run_config: Optional[dict] = None,
upload_python_packages: Optional[List[os.PathLike]] = None,
valid_data: Optional[S3Artifact] = None,
optional_files: Optional[List[str]] = None,
):
prep_config = normalize_step_dict({}) if prep_config is None else prep_config
run_config = normalize_step_dict({}) if run_config is None else run_config
self._input_parameters = {
"block_id": InputParameter(type=str, value=""),
"numb_models": InputParameter(type=int),
Expand Down
6 changes: 4 additions & 2 deletions dpgen2/superop/prep_run_fp.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,12 @@ def __init__(
name: str,
prep_op: Type[OP],
run_op: Type[OP],
prep_config: dict = normalize_step_dict({}),
run_config: dict = normalize_step_dict({}),
prep_config: Optional[dict] = None,
run_config: Optional[dict] = None,
upload_python_packages: Optional[List[os.PathLike]] = None,
):
prep_config = normalize_step_dict({}) if prep_config is None else prep_config
run_config = normalize_step_dict({}) if run_config is None else run_config
self._input_parameters = {
"block_id": InputParameter(type=str, value=""),
"fp_config": InputParameter(),
Expand Down
6 changes: 4 additions & 2 deletions dpgen2/superop/prep_run_lmp.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,12 @@ def __init__(
name: str,
prep_op: Type[OP],
run_op: Type[OP],
prep_config: dict = normalize_step_dict({}),
run_config: dict = normalize_step_dict({}),
prep_config: Optional[dict] = None,
run_config: Optional[dict] = None,
upload_python_packages: Optional[List[os.PathLike]] = None,
):
prep_config = normalize_step_dict({}) if prep_config is None else prep_config
run_config = normalize_step_dict({}) if run_config is None else run_config
self._input_parameters = {
"block_id": InputParameter(type=str, value=""),
"explore_config": InputParameter(),
Expand Down

0 comments on commit c9b7c9d

Please sign in to comment.