From 6143912b1f50b832b9c0c9dc4a6e03a93c0703f0 Mon Sep 17 00:00:00 2001 From: Jo Basevi Date: Tue, 15 Oct 2024 11:56:24 +1100 Subject: [PATCH] yatm model driver: Override model class method for prior restarts --- payu/models/yatm.py | 10 ++++++---- test/models/test_yatm.py | 21 +++++++++++++++++++++ 2 files changed, 27 insertions(+), 4 deletions(-) create mode 100644 test/models/test_yatm.py diff --git a/payu/models/yatm.py b/payu/models/yatm.py index 577a8181..ed27eee0 100644 --- a/payu/models/yatm.py +++ b/payu/models/yatm.py @@ -37,11 +37,13 @@ def set_model_pathnames(self): self.work_input_path = os.path.join(self.work_path, 'INPUT') def archive(self): - - # Create an empty restart directory - mkdir_p(self.restart_path) - shutil.rmtree(self.work_input_path) def collate(self): pass + + def get_prior_restart_files(self): + """Override model class method to avoid displaying an error + when there is no prior restart files. yatm reads from data files + so it should not require prior restarts""" + return [] diff --git a/test/models/test_yatm.py b/test/models/test_yatm.py new file mode 100644 index 00000000..b4dfebab --- /dev/null +++ b/test/models/test_yatm.py @@ -0,0 +1,21 @@ + +from unittest.mock import Mock + +import payu.experiment +import payu.models + +def test_get_prior_restart_files(capsys, tmpdir): + with capsys.disabled(): + expt = Mock(spec=payu.experiment.Experiment) + model_config = {'model': 'yatm'} + model = payu.models.Yatm(expt, 'atmosphere', model_config) + model.prior_restart_path = str(tmpdir / 'unexistent_dir') + + restart_files = model.get_prior_restart_files() + + # Check nothing written to standard output + captured = capsys.readouterr() + assert captured.out == '' + assert captured.err == '' + + assert restart_files == []