Skip to content

Commit

Permalink
Merge pull request #2113 from ESMCI/jgfouca/custom_success_msg_case_s…
Browse files Browse the repository at this point in the history
…tatus

Add ability to customize CaseStatus success message for a phase.
Add ability to customize CaseStatus success message for a phase.

Test suite: code_checker, by-hand
Test baseline:
Test namelist changes:
Test status: bit for bit

Fixes #2108

User interface changes?: jobid now added to CaseStatus case_submit entry

Update gh-pages html (Y/N)?: N

Code review: @jedwards4b
  • Loading branch information
jedwards4b authored Dec 6, 2017
2 parents cb0f58a + 07a8fec commit 530c337
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
7 changes: 5 additions & 2 deletions scripts/lib/CIME/case_submit.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"""
import socket
from CIME.XML.standard_module_setup import *
from CIME.utils import expect, run_and_log_case_status
from CIME.utils import expect, run_and_log_case_status, verbatim_success_msg
from CIME.preview_namelists import create_namelists
from CIME.check_lockedfiles import check_lockedfiles
from CIME.check_input_data import check_all_input_data
Expand Down Expand Up @@ -82,6 +82,8 @@ def _submit(case, job=None, no_batch=False, prereq=None, resubmit=False,
if xml_jobid_text:
case.set_value("JOB_IDS", xml_jobid_text)

return xml_jobid_text

def submit(case, job=None, no_batch=False, prereq=None, resubmit=False,
skip_pnl=False, mail_user=None, mail_type=None, batch_args=None):
if case.get_value("TEST"):
Expand All @@ -102,7 +104,8 @@ def submit(case, job=None, no_batch=False, prereq=None, resubmit=False,
resubmit=resubmit, skip_pnl=skip_pnl,
mail_user=mail_user, mail_type=mail_type,
batch_args=batch_args)
run_and_log_case_status(functor, "case.submit", caseroot=case.get_value("CASEROOT"))
run_and_log_case_status(functor, "case.submit", caseroot=case.get_value("CASEROOT"),
custom_success_msg_functor=verbatim_success_msg)
except:
# If something failed in the batch system, make sure to mark
# the test as failed if we are running a test.
Expand Down
8 changes: 6 additions & 2 deletions scripts/lib/CIME/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1420,7 +1420,10 @@ def stringify_bool(val):
expect(type(val) is bool, "Wrong type for val '{}'".format(repr(val)))
return "TRUE" if val else "FALSE"

def run_and_log_case_status(func, phase, caseroot='.'):
def verbatim_success_msg(return_val):
return return_val

def run_and_log_case_status(func, phase, caseroot='.', custom_success_msg_functor=None):
append_case_status(phase, "starting", caseroot=caseroot)
rv = None
try:
Expand All @@ -1430,7 +1433,8 @@ def run_and_log_case_status(func, phase, caseroot='.'):
append_case_status(phase, "error", msg=("\n{}".format(e)), caseroot=caseroot)
raise
else:
append_case_status(phase, "success", caseroot=caseroot)
custom_success_msg = custom_success_msg_functor(rv) if custom_success_msg_functor else None
append_case_status(phase, "success", msg=custom_success_msg, caseroot=caseroot)

return rv

Expand Down

0 comments on commit 530c337

Please sign in to comment.