Repository: ESMCI/cime

Issue:
CIME does not always download all the necessary input files for test cases that modify case2
We are seeing that some test cases will sometimes need different input files for their case2 (ERP, PEM). These files don't appear to be automatically downloaded by CIME which can lead to failures.


Discussion:
@jonbob , does this summarize the issue correctly?
I wonder if the issue is due to case2 being submitted from a (compute) node that doesn't have internet access?   One way to solve this might be to explicitly call check_inputdata --download from the ERP and PEM tests in the case2 directory.
That might do it -- it's only the mpas graph (decomposition) files that are different and get missed. And thanks @jgfouca, I think that covers it. The graph files should be listed in the mpas input_data_list's, so hopefully it's as simple as calling check_download from case2
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.
This issue is still important to E3SM
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

Resolving patch:
diff --git a/CIME/case/case_submit.py b/CIME/case/case_submit.py
--- a/CIME/case/case_submit.py
+++ b/CIME/case/case_submit.py
@@ -287,7 +287,8 @@ def check_case(self, skip_pnl=False, chksum=False):
     if not skip_pnl:
         self.create_namelists()  # Must be called before check_all_input_data
     logger.info("Checking that inputdata is available as part of case submission")
-    self.check_all_input_data(chksum=chksum)
+    if not self.get_value("TEST"):
+        self.check_all_input_data(chksum=chksum)
 
     if self.get_value("COMP_WAV") == "ww":
         # the ww3 buildnml has dependencies on inputdata so we must run it again


Test patch:
diff --git a/CIME/SystemTests/system_tests_common.py b/CIME/SystemTests/system_tests_common.py
--- a/CIME/SystemTests/system_tests_common.py
+++ b/CIME/SystemTests/system_tests_common.py
@@ -441,6 +441,15 @@ def run_indv(
         stop_option = self._case.get_value("STOP_OPTION")
         run_type = self._case.get_value("RUN_TYPE")
         rundir = self._case.get_value("RUNDIR")
+        try:
+            self._case.check_all_input_data()
+        except CIMEError:
+            caseroot = self._case.get_value("CASEROOT")
+            raise CIMEError(
+                "Could not find all inputdata on any server, try "
+                "manually running `./check_input_data --download "
+                f"--versbose` from {caseroot!r}."
+            ) from None
         if submit_resubmits is None:
             do_resub = self._case.get_value("BATCH_SYSTEM") != "none"
         else:
diff --git a/CIME/tests/test_unit_case.py b/CIME/tests/test_unit_case.py
--- a/CIME/tests/test_unit_case.py
+++ b/CIME/tests/test_unit_case.py
@@ -22,10 +22,20 @@ def make_valid_case(path):
 class TestCaseSubmit(unittest.TestCase):
     def test_check_case(self):
         case = mock.MagicMock()
+        # get_value arguments TEST, COMP_WAV, COMP_INTERFACE, BUILD_COMPLETE
+        case.get_value.side_effect = [False, "", "", True]
         case_submit.check_case(case, chksum=True)
 
         case.check_all_input_data.assert_called_with(chksum=True)
 
+    def test_check_case_test(self):
+        case = mock.MagicMock()
+        # get_value arguments TEST, COMP_WAV, COMP_INTERFACE, BUILD_COMPLETE
+        case.get_value.side_effect = [True, "", "", True]
+        case_submit.check_case(case, chksum=True)
+
+        case.check_all_input_data.assert_not_called()
+
     @mock.patch("CIME.case.case_submit.lock_file")
     @mock.patch("CIME.case.case_submit.unlock_file")
     @mock.patch("os.path.basename")