Repository navigation
Conversation
Fixes #64. In examples/generate_diatomic.py, MolecularData instances were created without specifying data_directory, causing them to default to openfermion.config.DATA_DIRECTORY (located within the installed openfermion package). In read-only or system installations, running the example raised PermissionError when run_pyscf and molecule.save() attempted to write HDF5 data into the package directory. This change: - Sets data_directory = os.getcwd() in examples/generate_diatomic.py and passes it to MolecularData calls so output is written to the working directory. - Removes redundant explicit molecule.save() calls since run_pyscf saves by default. - Adds an integration test in openfermionpyscf/tests/_run_pyscf_test.py verifying generate_diatomic.py runs and saves files to the working directory even when DATA_DIRECTORY is read-only.
mhucka
force-pushed
the
mh-fix-issue-64
branch
from
October 14, 2026 01:46
3ec80d1 to
65bb47d
Compare
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.
Summary
Fixes #64.
When running
examples/generate_diatomic.py,MolecularDatainstances were created without specifyingdata_directory. Consequently,MolecularDatadefaulted toopenfermion.config.DATA_DIRECTORY(which points totesting/datainside the installedopenfermionpackage). In read-only or system environments (e.g./usr/local/lib/python3.X/site-packages),run_pyscfandmolecule.save()raisedPermissionError: [Errno 13] Permission denied.Changes
examples/generate_diatomic.py:data_directory = os.getcwd()and pass it to bothMolecularData(...)calls so output is written to the local working directory.molecule.save()calls sincerun_pyscf()already saves by default.openfermionpyscf/tests/_run_pyscf_test.py:test_generate_diatomic()regression test to verify thatexamples/generate_diatomic.pyexecutes and writes 32.hdf5files to the working directory even whenDATA_DIRECTORYis unwritable (0o555).Testing
pytest -v(6 passed in 19.91s).Temporarily omitting
data_directoryfromgenerate_diatomic.pycausedtest_generate_diatomicto fail withPermissionError: [Errno 13] Permission denied.