-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can't redirect stdout from calculator singlepoint() #31
Comments
The Fortran library is writing to a formatted unit, not sure if Python is actually able to intercept this. For this purpose you can create a formatted unit by an API call instead: calc.set_output('log.txt')
res = calc.singlepoint()
calc.release_output() |
Thanks for the response. This prevents output for a little while then it all dumps to stdout anyway. For example, here I am doing a geometry optimization that calls xTB, the xTB output is suppressed until optimization step 3. It's not super important.
|
There is a way to workaround the discrepancy between C/Fortran output and Python file handle described in grimme-lab/xtb#160 (comment) for the old Python API, it should work with the new one as well. |
I encountered a similar issue in relation to the QCEngine implementation of xtb, where the default is to write output to stdout. Maybe one solution would be to allow different levels of verbosity. Currently, the harness defaults to VERBOSITY_FULL. VERBOSITY_MUTED does seem to do the trick for GFN2-xTB, but for GFN-FF there is still output printed. xtb-python/xtb/qcschema/harness.py Line 141 in 43a680b
|
For the tblite library I circumvented this problem by allowing the Python API to provide the IO functionality via a callback: This solution will be adopted in xtb as well once we switch to the library as backend for implementing the xTB Hamiltonian. For GFN-FF this would completely resolve the problem that the Calculator can write in the |
Ok, sounds good! |
I have an application that will be running a lot of xtb calculations. I don't want my main output to be clogged with a lot of output from xtb itself but instead would like to write this information to a different file using redirection.
Normally this is possible with
contextlib
in python but contextlib can't capture the stdout from Calculator.For example, the following code still prints out the SCC iteration information to the standard output (which I don't want). It should be written to log.txt instead.
The text was updated successfully, but these errors were encountered: