Skip to content

Commit

Permalink
Fix openbabel install to ensure q-chem tests run (#320)
Browse files Browse the repository at this point in the history
* Fix openbabel install to ensure q-chem tests run

* Update test.yml

* Update test.yml

* why u do this to me

* pre-commit auto-fixes

* Update test.yml

* Update test.yml

* Update test_cust.py

* Update test_cust.py

* fix

* Delete tests/files/qchem/new_test_files/FF_working/test_cust.py

* fix two missing files issues with .gz

* fixed

* unzip

* do we need conda myenv?

* change  QCJob exception type to ValueError and update test_jobs.py

* also test on windows+mac and oldest supported python 3.9

* don't test 3.9 due to glob(root_dir=...) unsupported, instead test on Python 3.12 and remove max-parallel: 1

* default shell config to login

* add pip caching and rename conda env to qchem

* delete unused compressed Q-Chem test files

* add comment for why not testing 3.9

* fix QChemErrorHandler file renaming on Windows: os.rename -> os.replace

os.rename(self.input_file, self.input_file + ".last")
E       FileExistsError: [WinError 183] Cannot create a file when that file already exists: 'mol.qin' -> 'mol.qin.last'

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: samblau <samblau1@gmail.com>
Co-authored-by: Janosh Riebesell <janosh.riebesell@gmail.com>
  • Loading branch information
4 people authored Mar 9, 2024
1 parent 9b67478 commit 123d16d
Show file tree
Hide file tree
Showing 16 changed files with 3,053 additions and 51 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/linting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ on:
jobs:
build:
runs-on: ubuntu-latest
strategy:
max-parallel: 1
steps:
- uses: actions/checkout@v4
with:
Expand Down
24 changes: 15 additions & 9 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,30 +14,36 @@ on:
jobs:
build:
strategy:
max-parallel: 1
matrix:
os: [ubuntu-latest]
python-version: ["3.10"]
os: [ubuntu-latest, windows-latest, macos-14]
# not testing on 3.9 because tests use glob("*", root_dir=TEST_FILES)
# and root_dir only added in 3.10
python-version: ["3.10", "3.12"]

runs-on: ${{ matrix.os }}
defaults:
run:
shell: bash -l {0}

steps:
- uses: actions/checkout@v4

- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: pip
cache-dependency-path: pyproject.toml

- uses: conda-incubator/setup-miniconda@v3
with:
python-version: ${{ matrix.python-version }}
activate-environment: qchem

- name: Install OpenBabel
shell: bash -l {0}
run: conda install -c conda-forge openbabel

- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: pip install -e '.[dev]'
run: pip install '.[dev]'

- name: pytest
env:
Expand Down
2 changes: 1 addition & 1 deletion custodian/qchem/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,6 @@ def correct(self):
) and str(self.qcinp.geom_opt["initial_hessian"]).lower() == "read":
del self.qcinp.geom_opt["initial_hessian"]
actions.append({"initial_hessian": "deleted"})
os.rename(self.input_file, self.input_file + ".last")
os.replace(self.input_file, f"{self.input_file}.last")
self.qcinp.write_file(self.input_file)
return {"errors": self.errors, "warnings": self.warnings, "actions": actions}
8 changes: 4 additions & 4 deletions custodian/qchem/jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,7 @@ def opt_with_frequency_flattener(
else:
good_child = copy.deepcopy(history[-1])
if good_child["num_neg_freqs"] > 1:
raise Exception(
raise ValueError(
"ERROR: Child with lower energy has more negative frequencies! Exiting..."
)
if good_child["energy"] < parent_hist["energy"] or (
Expand All @@ -602,17 +602,17 @@ def opt_with_frequency_flattener(
):
make_good_child_next_parent = True
else:
raise Exception("ERROR: Good child not good enough! Exiting...")
raise ValueError("ERROR: Good child not good enough! Exiting...")
if make_good_child_next_parent:
good_child["index"] = len(history)
history.append(good_child)
ref_mol = history[-1]["molecule"]
geom_to_perturb = history[-1]["geometry"]
negative_freq_vecs = history[-1]["frequency_mode_vectors"][perturb_index]
else:
raise Exception("ERROR: Can't deal with multiple neg frequencies yet! Exiting...")
raise ValueError("ERROR: Can't deal with multiple neg frequencies yet! Exiting...")
else:
raise AssertionError("ERROR: Parent cannot have more than two children! Exiting...")
raise ValueError("ERROR: Parent cannot have more than two children! Exiting...")
# Implicitly, if the number of negative frequencies decreased from parent to child,
# continue normally.
if standard:
Expand Down
24 changes: 0 additions & 24 deletions tests/files/qchem/new_test_files/FF_working/test_cust.py

This file was deleted.

98 changes: 98 additions & 0 deletions tests/files/qchem/new_test_files/fileman_cpscf.qin
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
$molecule
0 2
O 0.2914152612 -4.5445442042 3.0161751692
O -1.5304339813 -3.2367784149 2.9281824830
C 0.8295530097 -3.9366715322 4.2435768817
C -0.1230659566 -4.2007068432 5.3950468933
C 2.1314679452 -4.6891692104 4.4343334880
C 1.0891180123 -2.4551760936 4.0360799358
C -0.8605961838 -4.1422775145 2.4861350017
C -1.2116960079 -4.9374875952 1.2364985602
C -2.6517342220 -4.6163181541 0.8175486720
H -0.3280027986 -5.2718477365 5.4811047398
H 0.3385752508 -3.8702900027 6.3302131252
H -1.0648795958 -3.6651308672 5.2679406205
H 2.8060542012 -4.5134182893 3.5911657969
H 1.9470806743 -5.7639090000 4.5122126635
H 2.6262968839 -4.3565250871 5.3502869188
H 1.6558832285 -2.2928927340 3.1137215346
H 0.1610759990 -1.8839982580 3.9934806758
H 1.6896565513 -2.0812658626 4.8711834869
C -1.0164727255 -6.4347242690 1.4797433050
H -1.5581303737 -6.7836873265 2.3638647772
H 0.0398286180 -6.6745120675 1.6184484158
H -1.3829909813 -6.9970496209 0.6140214151
C -0.2642252347 -4.4709101412 0.1263230216
H -0.3925640144 -3.4049115606 -0.0773598657
H -0.4789826082 -5.0237708051 -0.7947386622
H 0.7815646456 -4.6470496024 0.3929852586
C -3.7386359783 -5.1159593031 1.7522230896
H -2.8000270794 -5.0438393410 -0.1827625673
H -2.7338896931 -3.5296566953 0.7024878530
H -3.7691013071 -6.2090022139 1.7949719714
H -4.7241345868 -4.7791401993 1.4163909720
H -3.5933064317 -4.7432620029 2.7707341718
S -3.1095688405 -0.8338328120 1.9223394071
C -1.4763090285 -0.6530852521 0.5550909541
C -1.7891128457 -0.8441888555 -0.7833876727
H -2.8272949027 -0.8142864366 -1.1170758647
C -0.7598974121 -1.0500002977 -1.7040885688
H -0.9909069977 -1.1779594339 -2.7596192371
C 0.5668601276 -1.0856329376 -1.2708524494
H 1.3694627147 -1.2422432626 -1.9871957374
C 0.8611607361 -0.9378379065 0.0855095498
H 1.8948169178 -0.9779391480 0.4236494734
C -0.1682729563 -0.7392449587 1.0085213741
H 0.0565492183 -0.6401064636 2.0671273707
C -2.3463554075 -0.1413857476 3.3511116054
C -1.6861008228 1.0969952276 3.3571269080
C -1.1464262498 1.5804639094 4.5468959620
H -0.6384784857 2.5416032340 4.5463233852
C -1.2451485056 0.8426672145 5.7244777657
H -0.8196610583 1.2241103280 6.6487441345
C -1.9004041859 -0.3950415761 5.7114055631
H -1.9807860619 -0.9794453631 6.6245370395
C -2.4557420740 -0.8829375023 4.5380818681
H -2.9596492827 -1.8437276305 4.5221216535
C -4.1249281175 0.4004756787 1.1655216406
C -3.6353302924 1.6229046114 0.6843711827
H -1.5667550440 1.6629973908 2.4414322262
C -4.5234891084 2.5509004307 0.1444384244
H -4.1442520184 3.5017916858 -0.2216525594
C -5.8845872809 2.2671234587 0.0644736389
H -6.5705578262 2.9985074190 -0.3548381451
C -6.3661310487 1.0371574340 0.5275291796
H -7.4256662542 0.8058548518 0.4619447035
C -5.4944582701 0.1113707308 1.0849708426
H -5.8630706203 -0.8369243514 1.4678940842
H -2.5707192368 1.8246188792 0.6894404950
$end

$rem
job_type = freq
basis = def2-svpd
max_scf_cycles = 100
gen_scfman = true
xc_grid = 3
thresh = 14
s2thresh = 16
scf_algorithm = diis
resp_charges = true
symmetry = false
sym_ignore = true
method = b97mv
solvent_method = pcm
mem_total = 170000
$end

$pcm
heavypoints 194
hpoints 194
radii uff
theory cpcm
vdwscale 1.1
$end

$solvent
dielectric 78.39
$end
Binary file not shown.
Loading

0 comments on commit 123d16d

Please sign in to comment.