Run dftbplus_thermo in an optional isolated working directory - #55
Merged
Conversation
The DFTB+ steps read and write fixed filenames (geo_opt.gen, hessian.out, vibrations.tag, ...) in the current directory, so running more than one molecule in the same directory clobbers the previous result. Add a directory argument to dftbplus_thermo that runs the pipeline in its own directory via a context manager, restoring the previous working directory afterwards. Defaults to the current directory, so existing behaviour is unchanged.
dftbplus_thermo only runs under the DFTB+ binaries, which CI skips, so the new directory branch showed as uncovered. Add a test that mocks the calculator pipeline (Geoopt/Hessian/Modes/run_thermo) and asserts the steps run inside the given directory and the working directory is restored.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #55 +/- ##
==========================================
+ Coverage 94.27% 95.00% +0.72%
==========================================
Files 21 21
Lines 1206 1221 +15
==========================================
+ Hits 1137 1160 +23
+ Misses 69 61 -8
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
galjos
added a commit
that referenced
this pull request
Jun 29, 2026
Implements the core screening framework from #33 (first slice). Builds on the per-job directory isolation (#55) and ASE-atoms passthrough (#52). ## What it does A \`screen()\` entry point (exported as \`ThermoScreening.screen\`) and a \`thermo screen\` CLI subcommand that, for each molecule, run the DFTB+ geometry-optimisation/Hessian/modes pipeline in its own working directory and collect the key thermochemistry into \`results.csv\` and \`results.json\`. - **Input (both):** a directory of \`.xyz\`/\`.gen\` structures (run at a global \`--charge\`), or a CSV manifest with \`path\` plus optional \`name\`/\`charge\` columns (per-molecule charge — e.g. anthraquinone at -1/-2). - **Output (both):** a CSV summary table and a JSON file (name, path, charge, status, E/H/G in Hartree, S/Cv in cal/(mol*K), error). - **Error isolation:** a molecule that fails is recorded with \`status=error\` and does not abort the run. - **Per-job isolation:** each molecule runs in \`<directory>/<name>\`. ``` # Python from ThermoScreening import screen screen("molecules.csv", out="results") # CLI thermo screen ./structures/ -o results --charge 0 thermo screen molecules.csv -o results ``` ## Tests - Job loading from a directory and a CSV manifest (per-row + default charge, relative path resolution), and rejection of empty/unknown inputs. - \`screen()\` with the pipeline mocked: collects results, writes CSV + JSON, runs each molecule in its own directory, and isolates a failing molecule. - CLI routing for the \`screen\` subcommand and the failure-count return code. - Verified locally with the real DFTB+ binaries over a directory of CH4/H2O/NH3 plus a deliberately broken structure: the three succeed (entropies 44.44 / 45.05 / 45.97 cal/(mol*K), matching literature), the broken one is isolated as an error. 152 passed, 5 skipped (no binaries); pylint 8.09/10. ## Deferred to follow-ups (not in this PR) - Resume/checkpoint (this PR always recomputes, per the agreed scope). - Parallel execution (chdir-based isolation is correct for sequential and multi-process batches; per-thread parallelism would need the calculators to thread a directory through).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #53. Re-targets the work from #54 onto main: #54 was stacked on the #52 branch and got merged into that branch instead of main (which was squash-merged separately), so the change never landed. These are the same commits, cleanly rebased onto current main.
The DFTB+ steps read and write fixed filenames (
geo_opt.gen,hessian.out,vibrations.tag,modes_in.hsd, ...) in the current directory, so running more than one molecule in the same directory clobbers the previous molecule's geometry/Hessian/frequencies. This blocks any batch/screening loop (#33).Change
directoryargument todftbplus_thermo; the pipeline runs there via a_run_in_directorycontext manager that creates the directory and restores the previous working directory afterwards (including on error).Tests
_run_in_directory: isolates into the target dir and restores the cwd, restores on exception, no-op forNone.dftbplus_thermo(..., directory=...)without the binaries, covering the directory wiring in CI (api.py coverage 87% -> 93%).144 passed, 5 skipped (no binaries); pylint 8.04/10.