Skip to content

Commit 8c43623

Browse files
committed
(tests) Improved tearDown of customModel to improve model-related memory handling in the testing pipeline
1 parent c738b3d commit 8c43623

3 files changed

Lines changed: 7 additions & 2 deletions

File tree

‎pysipfenn/tests/test_ModelAdjusters.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ def tearDown(self):
5050
delattr(self, attr)
5151
# Core objects created in setUp — order matters: adjuster holds a ref into the Calculator
5252
del self.ma
53+
self.c.destroy()
5354
del self.c
5455
gc.collect()
5556

‎pysipfenn/tests/test_ModelExporters.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ def tearDown(self):
3434
if hasattr(self, attr):
3535
delattr(self, attr)
3636
# Core Calculator created in setUp
37+
self.c.destroy()
3738
del self.c
3839
gc.collect()
3940

‎pysipfenn/tests/test_customModel.py‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import unittest
2+
import gc
23
from pymatgen.core import Structure
34
from importlib.resources import files as resources_files, as_file
45
import shutil
@@ -47,8 +48,10 @@ def testCalculation(self):
4748

4849
@pytest.mark.skipif(IN_GITHUB_ACTIONS, reason="Test depends on the ONNX network files")
4950
def tearDown(self) -> None:
50-
'''Deletes the copied model.'''
51-
self.c = None
51+
'''Deletes the copied model and frees the Calculator.'''
52+
self.c.destroy()
53+
del self.c
54+
gc.collect()
5255
print('\nTearing down')
5356
os.remove('MyFunNet.onnx')
5457
print('Removed MyFunNet')

0 commit comments

Comments
 (0)