Skip to content

Commit

Permalink
add avaialble_diags output
Browse files Browse the repository at this point in the history
  • Loading branch information
anton-seaice committed Feb 20, 2025
1 parent 7964883 commit 305dbd7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
20 changes: 13 additions & 7 deletions payu/models/mom6.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
from payu.models.mom_mixin import MomMixin
from payu.git_utils import GitRepository

MOM6_DOCS = "MOM_parameter_doc.*"
MOM6_DOCS = ["MOM_parameter_doc.*","available_diags.*"]

def mom6_add_parameter_files(model):
"""Add parameter files defined in input.nml to model configuration files.
Expand Down Expand Up @@ -53,19 +53,25 @@ def mom6_save_docs_files(model):
mkdir_p(docs_folder)

# copy everything that matches MOM_parameter_doc.* to the control dir
for f in glob(os.path.join(model.work_path, MOM6_DOCS)):
try:
shutil.copy(f, docs_folder)
except Exception as e:
warn(e)
for pattern in MOM6_DOCS:
for f in glob(os.path.join(model.work_path, pattern)):
try:
shutil.copy(f, docs_folder)
except Exception as e:
warn(e)

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)

paths_to_commit = []
for pattern in MOM6_DOCS:
for i in glob(os.path.join(docs_folder, pattern)):
paths_to_commit.append(i)

repo.commit(
commit_message = "payu archive: documentation of MOM6 run-time configuration" ,
paths_to_commit = glob(os.path.join(docs_folder, MOM6_DOCS))
paths_to_commit = paths_to_commit
)

class Mom6(MomMixin, Fms):
Expand Down
4 changes: 2 additions & 2 deletions test/models/test_mom6.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def mom_parameter_doc(request):

@pytest.mark.parametrize(
"mom_parameter_doc",
[["MOM_parameter_doc.all","MOM_parameter_doc.debug","MOM_parameter_docs.debug"]],
[["MOM_parameter_doc.all","MOM_parameter_doc.debug","MOM_parameter_docs.debug", "available_diags.000000"]],
indirect=True
)
@pytest.mark.filterwarnings("error")
Expand All @@ -167,7 +167,7 @@ def test_mom6_save_doc_files(mom_parameter_doc):
payu.models.mom6.mom6_save_docs_files(mom_parameter_doc)

# Check MOM_parameter_doc.* are added to control_path
for file in ["MOM_parameter_doc.all","MOM_parameter_doc.debug"]:
for file in ["MOM_parameter_doc.all","MOM_parameter_doc.debug", "available_diags.000000"]:
filename = os.path.join(mom_parameter_doc.control_path, "docs", file)
assert os.path.isfile(filename)==True , "Payu did not move MOM_parameter_doc.* files into docs folder"
os.remove(filename)
Expand Down

0 comments on commit 305dbd7

Please sign in to comment.