deepmodeling / deepmodeling/dpti

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

Open
#138 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
42
Forks
27
PR merge metrics
No merged PRs in 30d

Description

Source: Codex global repository scan of deepmodeling/dpti at commit b719828e7eeb571bd26411430197cd74ea78e38c.
Project: https://github.com/orgs/deepmodeling/projects/27

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
https://github.com/deepmodeling/dpti/blob/b719828e7eeb571bd26411430197cd74ea78e38c/workflow/DpFreeEnergy-aiida.py#L14
https://github.com/deepmodeling/dpti/blob/b719828e7eeb571bd26411430197cd74ea78e38c/workflow/DpFreeEnergy-aiida.py#L326
https://github.com/deepmodeling/dpti/blob/b719828e7eeb571bd26411430197cd74ea78e38c/workflow/DpFreeEnergy-aiida.py#L331

Reproduction
Run from the repository root:

```bash
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.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.