Skip to content

[Code scan] AiiDA workflow script starts work at import time #138

Description

@njzjz

Source: Codex global repository scan of deepmodeling/dpti at commit b719828.
Project: DeepModeling Agent Code Scan

Problem
workflow/DpFreeEnergy-aiida.py performs side effects at import/module execution time: it loads an AiiDA profile, reads ../examples/FreeEnergy.json, constructs an AiiDA Dict, and calls TI_workflow(). This makes parser scans or accidental imports capable of starting work or failing on a cwd-dependent path.

Code references

aiida.load_profile()

with open("../examples/FreeEnergy.json", "r") as f:

result = TI_workflow(dag_run=dag_run)

Reproduction
Run from the repository root:

python workflow/DpFreeEnergy-aiida.py

The script tries to read ../examples/FreeEnergy.json, which is outside this repository's examples/ directory; if that path existed, it would proceed to run the workflow immediately.

Expected result
Executable workflow code should be guarded by if __name__ == '__main__': and should resolve example paths relative to the script or repository root.

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