Skip to content

[Code scan] Preserve caller-provided conf_idx in make_lmp_task_group_from_config #358

Description

@njzjz

Found by Codex global repository scan of deepmodeling/dpgen2 at commit 2679611a3704f5c2646c8cb353e34177518db758.

make_lmp_task_group_from_config overwrites caller-provided conf_idx with None:

def make_lmp_task_group_from_config(
numb_models,
mass_map,
config,
):
# Work around the required conf_idx.
# May not be a good design!!!
config["conf_idx"] = [] if "conf_idx" not in config else None
config = lmp_normalize(config)
config = config_strip_confidx(config)

The comment says this is a workaround for required conf_idx, but the conditional is reversed for preserving user input:

config["conf_idx"] = [] if "conf_idx" not in config else None

If conf_idx is present, the helper discards it before normalization and before config_strip_confidx can process it. Direct users of the exported helper can lose their selected configuration indices or fail validation with None.

Suggested fix: preserve an existing conf_idx value, only insert the empty default when the key is absent, and add a regression test that passes an explicit conf_idx through this helper.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    Status
    In Progress

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions