Skip to content

Commit

Permalink
use expt.runlog.enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
anton-seaice committed Feb 16, 2025
1 parent f4dd337 commit 64c4e86
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 9 deletions.
2 changes: 1 addition & 1 deletion payu/models/mom6.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def mom6_save_docs_files(model):
except Exception as e:
warn(e)

if model.expt.config.get('runlog', True): #if runlog true, default to true
if model.expt.runlog.enabled: #if runlog true, default to true
# commit new files to the control dir
repo = GitRepository(repo_path = model.control_path)

Expand Down
34 changes: 33 additions & 1 deletion test/models/access-om3/test_access_om3.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import copy
import os
import shutil
from pathlib import Path
import pytest

import payu
Expand Down Expand Up @@ -422,3 +421,36 @@ def test_get_restart_datetime_badcal(start_dt, calendar, cmeps_calendar, expecte
teardown_cmeps_config()
remove_expt_archive_dirs(type='restart')


# During archiving, we use model.expt.runlog.enabled to determine if the runlog is set
# Confirm all permutations set/don't set this.
@pytest.mark.parametrize(
"runlog, enabled",
[
(True, True),
(False, False),
({"enable":True}, True),
({"enable":False}, False)
]
)
@pytest.mark.filterwarnings("error")
def test_setup_runlog(runlog, enabled):
# set runlog differet to cmeps_config():
config = copy.deepcopy(config_orig)
config['model'] = MODEL
config['ncpus'] = 1
config['runlog'] = runlog

write_config(config)

with open(os.path.join(ctrldir, 'nuopc.runconfig'), "w") as f:
f.close()

with cd(ctrldir):
lab = payu.laboratory.Laboratory(lab_path=str(labdir))
expt = payu.experiment.Experiment(lab, reproduce=False)
model = expt.models[0]

assert model.expt.runlog.enabled == enabled

teardown_cmeps_config()
10 changes: 3 additions & 7 deletions test/models/test_mom6.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ def test_mom6_save_doc_files(mom_parameter_doc):
# and doesn't move files that don't match that name

# don't try and commit during tests
mom_parameter_doc.expt.config["runlog"] = False
mom_parameter_doc.expt.runlog.enabled = False

# Function to test
payu.models.mom6.mom6_save_docs_files(mom_parameter_doc)
Expand All @@ -184,7 +184,7 @@ def test_mom6_save_doc_files(mom_parameter_doc):
@pytest.mark.filterwarnings("error")
def test_mom6_commit_doc_files(mom_parameter_doc):
# Confirm that mom6_save_doc_files commits files named MOM_parameter_doc.* into the docs folder of a config
# default is to commit during runs
mom_parameter_doc.expt.runlog.enabled = True

#init a git repo
repo = create_new_repo(Path(mom_parameter_doc.control_path))
Expand Down Expand Up @@ -221,7 +221,6 @@ def test_mom6_commit_doc_files(mom_parameter_doc):
os.remove(filename)



@pytest.mark.parametrize(
"mom_parameter_doc",
[["MOM_parameter_doc.layout"]],
Expand All @@ -231,7 +230,7 @@ def test_mom6_commit_doc_files(mom_parameter_doc):
def test_mom6_not_commit_doc_files(mom_parameter_doc):
# Confirm that mom6_save_doc_files doesn't commits files if runlog is False

mom_parameter_doc.expt.config["runlog"] = False
mom_parameter_doc.expt.runlog.enabled = False

#init a git repo
repo = create_new_repo(Path(mom_parameter_doc.control_path))
Expand All @@ -249,9 +248,6 @@ def test_mom6_not_commit_doc_files(mom_parameter_doc):
assert repo.head.commit == initial_commit, "Payu did not commit MOM_parameter_doc.layout"





def test_setup():
input_nml = {
"MOM_input_nml": {
Expand Down

0 comments on commit 64c4e86

Please sign in to comment.