Repository navigation
propSAPT logs through Python's logging; one handler writes into Psi4's output file - #13
Merged
Merged
Conversation
…s output file prop_sapt.log sets up the `prop_sapt` logger: INFO and above, written into Psi4's output file by Psi4OutputHandler, warnings and errors after their level. Module loggers are its children, so the standard logging calls quiet or redirect propSAPT's output. The package imports it first, and a reload keeps one handler. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019ZeFQEY3P12DGTNcvWEyhT
…_out Dimer and helper_SAPT, the SAPT driver, the densities, the CPSCF solver and batching, S^inf, the checks, the basis overrides and the timers log through logging.getLogger(__name__). Messages have no blank lines around them, and multi-line tables are one record. The warnings of the checks, the CPSCF solver, the deprecations and a missing GRAC shift are WARNING records next to their Python warnings. Modules that no longer use Psi4 stop importing it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019ZeFQEY3P12DGTNcvWEyhT
The cube setup, timings and isocontours and the finite-field banners and steps are INFO records. The progress of make_cube over the x-slices, a line rewritten with \r in Psi4's output file, is a DEBUG record per slice. A test checks that only prop_sapt.log writes into Psi4's output file. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019ZeFQEY3P12DGTNcvWEyhT
The 36 psi4.core.clean() calls before a raise go: Psi4 cleans its scratch files at exit and between jobs, which calc_sapt_energy, calc_property and the runner still do. calc_property checks the response without a try/except, and the densities module no longer imports Psi4. A test checks that clean is called only at the ends of jobs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019ZeFQEY3P12DGTNcvWEyhT
…n sections print_sapt_summary builds the table from format_energy, the line energy_printer writes, and logs it at once, so the table keeps the layout it had in Psi4's output file. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019ZeFQEY3P12DGTNcvWEyhT
The usage guide's Output and logging section shows how to quiet or redirect propSAPT's output, the API reference lists prop_sapt.log, and the changelog says the output goes through logging, still into Psi4's output file. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019ZeFQEY3P12DGTNcvWEyhT
The banner is one INFO record now, so the test reads it with caplog: its logger, level, title and formatted details. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019ZeFQEY3P12DGTNcvWEyhT
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.
prop_sapt/log.py: theprop_saptlogger, at INFO by default, andPsi4OutputHandler, which writes its records into Psi4's output file, putting the level before warnings and errors ("Warning: ..."). It is the only code left that callspsi4.core.print_out. Every module logs throughlogging.getLogger(__name__), so the standardloggingcalls quiet or redirect all of propSAPT's output or one module's, e.g. the CPSCF iteration tables (prop_sapt.cpscf_solver).format_energyhelper, andenergy_printerkeeps its API.make_cubeover the x-slices, a line rewritten with\rin the output file, is a DEBUG record per slice.psi4.core.clean()calls just before araiseare removed: Psi4 cleans its scratch files at exit, andcalc_sapt_energy,calc_propertyand the runner still clean at the end of a job.prop_sapt.login the API reference, and a changelog entry.Out of scope: Psi4's own
tstart/tstop,BasisSet.print_out(),Molecule.print_out_in_angstrom(),be_quietin the CLI and the 3 end-of-jobclean()calls. These are Psi4 calls that a backend will make.Tested: new tests of the logger and handler (records in Psi4's output file, levels, a reload keeping one handler,
caplogcapturing the CPSCF table and an unconverged-solve warning), and source scans that onlyprop_sapt.logwrites to Psi4's output and thatclean()is called only at the ends of jobs. The finite-field banner test reads the log record. The full suite passes locally, and the docs build with-W. A He–H2 run (aug-cc-pVDZ) covering the SAPT energy, dipole, densities, a cube, finite field and an RKS dimer gives the same results asmainwithin run-to-run round-off. Its output differs only in the dropped blank lines, the GRAC warning and the cube progress line.🤖 Generated with Claude Code
https://claude.ai/code/session_019ZeFQEY3P12DGTNcvWEyhT