Skip to content

[Code scan] Keep full from_poscar_path when building surface examples #1912

Description

@njzjz

This issue is from a Codex global scan of the repository.

init_surf loses the directory component of from_poscar_path.

Evidence:

dpgen/dpgen/data/surf.py

Lines 228 to 233 in 7af5246

from_poscar = jdata.get("from_poscar", False)
if from_poscar:
from_poscar_path = jdata["from_poscar_path"]
poscar_name = os.path.basename(from_poscar_path)
ss = Structure.from_file(poscar_name)

When from_poscar is true, the code reads from_poscar_path, takes only os.path.basename(from_poscar_path), and then calls Structure.from_file(poscar_name). A valid POSCAR path outside the current working directory fails because the directory part has been discarded.

Expected behavior: pass from_poscar_path itself to Structure.from_file() or resolve it to an absolute path before changing directories.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    Status
    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions