Skip to content

Commit 8a08384

Browse files
Release upper version limit on PySCF
To enable check-pointing of the state of a converged calculation, Sebastiaan rolled some custom serialization with Dill. This worked until some data structures were changed in PySCF around v2.4, breaking this functionality. This forced an upper version limit on PySCF. Recently, in PySCF v2.7, serialization via Pickle is natively supported. This commit removes the upper version constraints on PySCF by making the needed changes to the templates and parser, and regenerating the reference file for the tests. Other versions were also bumped, where appropriate.
1 parent 6a99d37 commit 8a08384

21 files changed

+73
-112
lines changed

pyproject.toml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ requires = ['flit_core>=3.4,<4']
55
[project]
66
authors = [
77
{name = 'Sebastiaan P. Huber', email = '[email protected]'},
8-
{name = 'Adam Grofe', email = '[email protected]'}
8+
{name = 'Adam Grofe', email = '[email protected]'},
9+
{name = 'Conrad Johnston', email = '[email protected]'}
910
]
1011
classifiers = [
1112
'Development Status :: 3 - Alpha',
@@ -20,19 +21,18 @@ classifiers = [
2021
'Topic :: Scientific/Engineering'
2122
]
2223
dependencies = [
23-
'aiida-core[atomic_tools]~=2.5',
24+
'aiida-core[atomic_tools]~=2.6',
2425
'aiida-shell>=0.5.3',
25-
'dill',
2626
'numpy',
2727
'pint',
28-
'pyscf[geomopt]~=2.2,<2.4'
28+
'pyscf[geomopt] ~= 2.7'
2929
]
3030
dynamic = ['description', 'version']
3131
keywords = ['aiida', 'workflows', 'pyscf']
3232
license = {file = 'LICENSE.txt'}
3333
name = 'aiida-pyscf'
3434
readme = 'README.md'
35-
requires-python = '>=3.9'
35+
requires-python = '>=3.9,<3.12'
3636

3737
[project.entry-points.'aiida.calculations']
3838
'pyscf.base' = 'aiida_pyscf.calculations.base:PyscfCalculation'
@@ -45,13 +45,13 @@ requires-python = '>=3.9'
4545

4646
[project.optional-dependencies]
4747
pre-commit = [
48-
'mypy==1.8.0',
48+
'mypy==1.13.0',
4949
'pre-commit~=2.17'
5050
]
5151
tests = [
5252
'packaging',
5353
'pgtest~=1.3,>=1.3.1',
54-
'pytest~=7.2',
54+
'pytest~=8.3',
5555
'pytest-regressions'
5656
]
5757

@@ -90,10 +90,10 @@ module = 'aiida_pyscf.*'
9090
ignore_missing_imports = true
9191
module = [
9292
'ase.*',
93-
'dill.*',
9493
'pint.*',
9594
'plumpy.*',
96-
'ruamel.*'
95+
'ruamel.*',
96+
'aiida_shell.*'
9797
]
9898

9999
[tool.pytest.ini_options]
Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Section: Results
22
def write_results_and_exit(results):
3-
import dill
43
import json
4+
import pickle
55
import sys
66

77
results['timings']['total'] = time.perf_counter() - time_start
@@ -11,11 +11,8 @@ def write_results_and_exit(results):
1111

1212
{% if results.pickle_model %}
1313
with open('{{ results.filename_model }}', 'wb') as handle:
14-
# Need to unset the ``_chkfile`` attribute as it contains an open file handle which cannot be unpickled.
15-
mean_field_run._chkfile = None
16-
# Need to unset the ``opt`` attribute as it contains ctypes objects containing pointers which cannot be pickled.
17-
mean_field_run.opt = None
18-
dill.dump(mean_field_run, handle)
14+
pickle.dump(mean_field_run, handle)
15+
1916
{% endif %}
2017

2118
sys.exit(0)

src/aiida_pyscf/parsers/base.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
import json
66
import pathlib
7+
import pickle
78

8-
import dill
99
import numpy
1010
from aiida.engine import ExitCode
1111
from aiida.orm import ArrayData, Dict, FolderData, SinglefileData, TrajectoryData
@@ -54,11 +54,11 @@ def parse(self, retrieved_temporary_folder: str | None = None, **kwargs): # noq
5454

5555
try:
5656
with retrieved.open(PyscfCalculation.FILENAME_MODEL, 'rb') as handle:
57-
model = dill.load(handle)
57+
model = pickle.load(handle)
5858
except FileNotFoundError:
5959
if parameters.get('results', {}).get('pickle_model', True):
6060
self.logger.warning(f'The pickled model file `{PyscfCalculation.FILENAME_MODEL}` could not be read.')
61-
except dill.UnpicklingError:
61+
except pickle.UnpicklingError:
6262
self.logger.warning(f'The pickled model file `{PyscfCalculation.FILENAME_MODEL}` could not be unpickled.')
6363
else:
6464
self.out('model', PickledData(model))
@@ -156,7 +156,7 @@ def batch(iterable, batch_size):
156156
symbols=[site.kind_name for site in self.node.inputs.structure.sites],
157157
positions=numpy.array(positions),
158158
)
159-
energies = (numpy.array(energies) * ureg.hartree).to(ureg.electron_volt).magnitude # type: ignore[attr-defined]
159+
energies = (numpy.array(energies) * ureg.hartree).to(ureg.electron_volt).magnitude
160160
trajectory.set_array('energies', numpy.array(energies))
161161

162162
return trajectory

tests/calculations/test_base/test_checkpoint.pyr

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ def main():
1414

1515
# Section: Results
1616
def write_results_and_exit(results):
17-
import dill
1817
import json
18+
import pickle
1919
import sys
2020

2121
results['timings']['total'] = time.perf_counter() - time_start
@@ -24,11 +24,8 @@ def main():
2424
json.dump(results, handle)
2525

2626
with open('model.pickle', 'wb') as handle:
27-
# Need to unset the ``_chkfile`` attribute as it contains an open file handle which cannot be unpickled.
28-
mean_field_run._chkfile = None
29-
# Need to unset the ``opt`` attribute as it contains ctypes objects containing pointers which cannot be pickled.
30-
mean_field_run.opt = None
31-
dill.dump(mean_field_run, handle)
27+
pickle.dump(mean_field_run, handle)
28+
3229

3330
sys.exit(0)
3431

tests/calculations/test_base/test_default.pyr

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ def main():
1414

1515
# Section: Results
1616
def write_results_and_exit(results):
17-
import dill
1817
import json
18+
import pickle
1919
import sys
2020

2121
results['timings']['total'] = time.perf_counter() - time_start
@@ -24,11 +24,8 @@ def main():
2424
json.dump(results, handle)
2525

2626
with open('model.pickle', 'wb') as handle:
27-
# Need to unset the ``_chkfile`` attribute as it contains an open file handle which cannot be unpickled.
28-
mean_field_run._chkfile = None
29-
# Need to unset the ``opt`` attribute as it contains ctypes objects containing pointers which cannot be pickled.
30-
mean_field_run.opt = None
31-
dill.dump(mean_field_run, handle)
27+
pickle.dump(mean_field_run, handle)
28+
3229

3330
sys.exit(0)
3431

tests/calculations/test_base/test_parameters_cubegen_parameters0_.pyr

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ def main():
1414

1515
# Section: Results
1616
def write_results_and_exit(results):
17-
import dill
1817
import json
18+
import pickle
1919
import sys
2020

2121
results['timings']['total'] = time.perf_counter() - time_start
@@ -24,11 +24,8 @@ def main():
2424
json.dump(results, handle)
2525

2626
with open('model.pickle', 'wb') as handle:
27-
# Need to unset the ``_chkfile`` attribute as it contains an open file handle which cannot be unpickled.
28-
mean_field_run._chkfile = None
29-
# Need to unset the ``opt`` attribute as it contains ctypes objects containing pointers which cannot be pickled.
30-
mean_field_run.opt = None
31-
dill.dump(mean_field_run, handle)
27+
pickle.dump(mean_field_run, handle)
28+
3229

3330
sys.exit(0)
3431

tests/calculations/test_base/test_parameters_cubegen_parameters1_.pyr

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ def main():
1414

1515
# Section: Results
1616
def write_results_and_exit(results):
17-
import dill
1817
import json
18+
import pickle
1919
import sys
2020

2121
results['timings']['total'] = time.perf_counter() - time_start
@@ -24,11 +24,8 @@ def main():
2424
json.dump(results, handle)
2525

2626
with open('model.pickle', 'wb') as handle:
27-
# Need to unset the ``_chkfile`` attribute as it contains an open file handle which cannot be unpickled.
28-
mean_field_run._chkfile = None
29-
# Need to unset the ``opt`` attribute as it contains ctypes objects containing pointers which cannot be pickled.
30-
mean_field_run.opt = None
31-
dill.dump(mean_field_run, handle)
27+
pickle.dump(mean_field_run, handle)
28+
3229

3330
sys.exit(0)
3431

tests/calculations/test_base/test_parameters_cubegen_parameters2_.pyr

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ def main():
1414

1515
# Section: Results
1616
def write_results_and_exit(results):
17-
import dill
1817
import json
18+
import pickle
1919
import sys
2020

2121
results['timings']['total'] = time.perf_counter() - time_start
@@ -24,11 +24,8 @@ def main():
2424
json.dump(results, handle)
2525

2626
with open('model.pickle', 'wb') as handle:
27-
# Need to unset the ``_chkfile`` attribute as it contains an open file handle which cannot be unpickled.
28-
mean_field_run._chkfile = None
29-
# Need to unset the ``opt`` attribute as it contains ctypes objects containing pointers which cannot be pickled.
30-
mean_field_run.opt = None
31-
dill.dump(mean_field_run, handle)
27+
pickle.dump(mean_field_run, handle)
28+
3229

3330
sys.exit(0)
3431

tests/calculations/test_base/test_parameters_cubegen_parameters3_.pyr

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ def main():
1414

1515
# Section: Results
1616
def write_results_and_exit(results):
17-
import dill
1817
import json
18+
import pickle
1919
import sys
2020

2121
results['timings']['total'] = time.perf_counter() - time_start
@@ -24,11 +24,8 @@ def main():
2424
json.dump(results, handle)
2525

2626
with open('model.pickle', 'wb') as handle:
27-
# Need to unset the ``_chkfile`` attribute as it contains an open file handle which cannot be unpickled.
28-
mean_field_run._chkfile = None
29-
# Need to unset the ``opt`` attribute as it contains ctypes objects containing pointers which cannot be pickled.
30-
mean_field_run.opt = None
31-
dill.dump(mean_field_run, handle)
27+
pickle.dump(mean_field_run, handle)
28+
3229

3330
sys.exit(0)
3431

tests/calculations/test_base/test_parameters_fcidump.pyr

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ def main():
1414

1515
# Section: Results
1616
def write_results_and_exit(results):
17-
import dill
1817
import json
18+
import pickle
1919
import sys
2020

2121
results['timings']['total'] = time.perf_counter() - time_start
@@ -24,11 +24,8 @@ def main():
2424
json.dump(results, handle)
2525

2626
with open('model.pickle', 'wb') as handle:
27-
# Need to unset the ``_chkfile`` attribute as it contains an open file handle which cannot be unpickled.
28-
mean_field_run._chkfile = None
29-
# Need to unset the ``opt`` attribute as it contains ctypes objects containing pointers which cannot be pickled.
30-
mean_field_run.opt = None
31-
dill.dump(mean_field_run, handle)
27+
pickle.dump(mean_field_run, handle)
28+
3229

3330
sys.exit(0)
3431

tests/calculations/test_base/test_parameters_hessian.pyr

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ def main():
1414

1515
# Section: Results
1616
def write_results_and_exit(results):
17-
import dill
1817
import json
18+
import pickle
1919
import sys
2020

2121
results['timings']['total'] = time.perf_counter() - time_start
@@ -24,11 +24,8 @@ def main():
2424
json.dump(results, handle)
2525

2626
with open('model.pickle', 'wb') as handle:
27-
# Need to unset the ``_chkfile`` attribute as it contains an open file handle which cannot be unpickled.
28-
mean_field_run._chkfile = None
29-
# Need to unset the ``opt`` attribute as it contains ctypes objects containing pointers which cannot be pickled.
30-
mean_field_run.opt = None
31-
dill.dump(mean_field_run, handle)
27+
pickle.dump(mean_field_run, handle)
28+
3229

3330
sys.exit(0)
3431

tests/calculations/test_base/test_parameters_mean_field.pyr

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ def main():
1414

1515
# Section: Results
1616
def write_results_and_exit(results):
17-
import dill
1817
import json
18+
import pickle
1919
import sys
2020

2121
results['timings']['total'] = time.perf_counter() - time_start
@@ -24,11 +24,8 @@ def main():
2424
json.dump(results, handle)
2525

2626
with open('model.pickle', 'wb') as handle:
27-
# Need to unset the ``_chkfile`` attribute as it contains an open file handle which cannot be unpickled.
28-
mean_field_run._chkfile = None
29-
# Need to unset the ``opt`` attribute as it contains ctypes objects containing pointers which cannot be pickled.
30-
mean_field_run.opt = None
31-
dill.dump(mean_field_run, handle)
27+
pickle.dump(mean_field_run, handle)
28+
3229

3330
sys.exit(0)
3431

tests/calculations/test_base/test_parameters_mean_field_localize_orbitals.pyr

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ def main():
1414

1515
# Section: Results
1616
def write_results_and_exit(results):
17-
import dill
1817
import json
18+
import pickle
1919
import sys
2020

2121
results['timings']['total'] = time.perf_counter() - time_start
@@ -24,11 +24,8 @@ def main():
2424
json.dump(results, handle)
2525

2626
with open('model.pickle', 'wb') as handle:
27-
# Need to unset the ``_chkfile`` attribute as it contains an open file handle which cannot be unpickled.
28-
mean_field_run._chkfile = None
29-
# Need to unset the ``opt`` attribute as it contains ctypes objects containing pointers which cannot be pickled.
30-
mean_field_run.opt = None
31-
dill.dump(mean_field_run, handle)
27+
pickle.dump(mean_field_run, handle)
28+
3229

3330
sys.exit(0)
3431

tests/calculations/test_base/test_parameters_optimizer.pyr

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ def main():
1414

1515
# Section: Results
1616
def write_results_and_exit(results):
17-
import dill
1817
import json
18+
import pickle
1919
import sys
2020

2121
results['timings']['total'] = time.perf_counter() - time_start
@@ -24,11 +24,8 @@ def main():
2424
json.dump(results, handle)
2525

2626
with open('model.pickle', 'wb') as handle:
27-
# Need to unset the ``_chkfile`` attribute as it contains an open file handle which cannot be unpickled.
28-
mean_field_run._chkfile = None
29-
# Need to unset the ``opt`` attribute as it contains ctypes objects containing pointers which cannot be pickled.
30-
mean_field_run.opt = None
31-
dill.dump(mean_field_run, handle)
27+
pickle.dump(mean_field_run, handle)
28+
3229

3330
sys.exit(0)
3431

tests/calculations/test_base/test_parameters_pickle_model.pyr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ def main():
1414

1515
# Section: Results
1616
def write_results_and_exit(results):
17-
import dill
1817
import json
18+
import pickle
1919
import sys
2020

2121
results['timings']['total'] = time.perf_counter() - time_start

0 commit comments

Comments
 (0)