[Code scan] Avoid mutating caller step and executor configuration dictionaries

Open Beginner friendly
#34 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
78/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Quiet
Tech stack
python
Domain
tooling

Research direction

Start with _prep_run_fp() in fpop/preprun_fp.py and init_executor() in fpop/utils/step_config.py, then run the minimal reproduction from the issue. Verify that the original prep and run configuration dictionaries retain their executor and type entries after constructing PrepRunFp and can be reused without losing the dispatcher executor.

Written by the indexing model from the issue text.

Description

bug

This issue is a result of a Codex global code scan of deepmodeling/fpop at commit b05b337590c31a5237b2dcbd9c0833b841c08cd4.

Relevant code:
https://github.com/deepmodeling/fpop/blob/b05b337590c31a5237b2dcbd9c0833b841c08cd4/fpop/preprun_fp.py#L127-L138
https://github.com/deepmodeling/fpop/blob/b05b337590c31a5237b2dcbd9c0833b841c08cd4/fpop/utils/step_config.py#L5-L12

Problem:
_prep_run_fp() and init_executor() destructively modify caller-owned configuration dictionaries:

prep_executor = init_executor(prep_step_config.pop("executor"))
run_executor = init_executor(run_step_config.pop("executor"))
etype = executor_dict.pop("type")

After constructing one PrepRunFp, the original prep_step_config / run_step_config no longer contain executor, and the nested executor dict no longer contains type. Reusing the same config object for another workflow can silently drop the dispatcher executor or fail with KeyError.

Minimal reproduction:

run_step_config = {"executor": {"type": "dispatcher", "machine_dict": {...}}}
PrepRunFp(..., run_step_config=run_step_config)
print(run_step_config)
# {'executor'} has been removed from the caller's dict

Expected behavior:
The workflow builder should copy configuration dictionaries before removing internal keys, preserving caller-owned input objects for reuse and inspection.

Dominant language
Python
Stars
3
Forks
13
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from deepmodeling/fpop

All issues in deepmodeling/fpop

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.