Skip to content

[Code scan] Make example template_script references self-contained and tested #360

Description

@njzjz

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

Workflow submission reads train.template_script from disk immediately:

type_map = config["inputs"]["type_map"]
numb_models = config["train"]["numb_models"]
template_script_ = config["train"]["template_script"]
if isinstance(template_script_, list):
template_script = [json.loads(Path(ii).read_text()) for ii in template_script_]
else:
template_script = json.loads(Path(template_script_).read_text())

Several examples point template_script at train.json, but their example directories do not include that file. Examples include:

"template_script": "train.json",

"template_script": "train.json",

"template_script": "train.json",

"template_script": "train.json",

The current example test only loads and normalizes the JSON, so it does not catch missing referenced files:

class TestExamples(unittest.TestCase):
def test_arguments(self):
for fn in input_files:
with self.subTest(fn=fn):
with open(fn) as f:
jdata = json.load(f)
normalize(jdata)

Suggested fix: make examples self-contained by pointing at files that exist in their directories, add the missing templates, or enhance the example test to resolve and validate template_script paths.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    Status
    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions