Skip to content

[Code scan] Resolve example input files relative to each script directory #36

Description

@njzjz

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

Relevant code:

confs = ["POSCAR-1","POSCAR-2","POSCAR-3"]
vasp_inputs = VaspInputs(0.4,'test_incar',{'Na':'test_potcar'},True) # kspacing incar potcar kgamma
prep_run_step = Step(
'prep-run-step',
template = steps,
parameters = {
'type_map' : ["Na"],
'prep_image_config' : prep_image_config,
'run_image_config' : run_image_config,
'inputs' : vasp_inputs,
'optional_input' : {"conf_format":"vasp/poscar"},
'backward_list' : ["OUTCAR","CONTCAR"],
},
artifacts = {
"confs" : upload_artifact(confs),
},

confs = ["POSCAR-1","POSCAR-2","POSCAR-3"]
cp2k_inputs = Cp2kInputs('input.inp') # input files
prep_run_step = Step(
'prep-run-step',
template = steps,
parameters = {
'type_map' : ["Na"],
'prep_image_config' : prep_image_config,
'run_image_config' : run_image_config,
"log_name" : "output.log",
'inputs' : cp2k_inputs,
'optional_input' : {"conf_format":"vasp/poscar"},
'backward_list' : ["output.log"],
},
artifacts = {
"confs" : upload_artifact(confs),
},

confs = ["POSCAR-1","POSCAR-2","POSCAR-3"]
abacus_inputs = AbacusInputs('INPUT',{'Na':'Na_ONCV_PBE-1.0.upf'})
prep_run_step = Step(
'prep-run-step',
template = steps,
parameters = {
'type_map' : ["Na"],
'prep_image_config' : prep_image_config,
'run_image_config' : run_image_config,
'inputs' :abacus_inputs,
'optional_input' : {"conf_format":"vasp/poscar"},
'backward_list' : ["OUT.ABACUS","log"],
},
artifacts = {
"confs" : upload_artifact(confs),
},

Problem:
The example scripts refer to bundled input files with current-working-directory-relative paths such as POSCAR-1, test_incar, test_potcar, input.inp, INPUT, and Na_ONCV_PBE-1.0.upf.

Running an example from the repository root with a normal command such as:

python examples/vasp/preprunvasp.py

makes the script look for test_incar and POSCAR-1 in the repository root, even though those files live under examples/vasp/. The same pattern exists in the CP2K and ABACUS examples.

Expected behavior:
Each example should resolve local inputs from Path(__file__).resolve().parent, so the examples work regardless of the caller's current working directory.

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