@@ -815,13 +815,6 @@ As was the case for test cases, the base class :py:class:`compass.Step` has a
815815large number of attributes that are useful at different stages (init, setup and
816816run) of the step.
817817
818- logger : logging.Logger
819- A logger for output from the step
820-
821- log_filename : str
822- At run time, the name of a log file where output/errors from the step
823- are being logged, or ``None `` if output is to stdout/stderr
824-
825818Some attributes are available after calling the base class' constructor
826819``super().__init__() ``. These include:
827820
@@ -857,6 +850,10 @@ Some attributes are available after calling the base class' constructor
857850``self.threads ``
858851 the number of threads the step will use
859852
853+ ``self.cached ``
854+ Whether to get all of the outputs for the step from the database of
855+ cached outputs for the MPAS core that this step belongs to
856+
860857Another set of attributes is not useful until ``setup() `` is called by the
861858``compass `` framework:
862859
@@ -897,6 +894,10 @@ framework:
897894 methods and functions that use the logger to write their output to the log
898895 file.
899896
897+ ``self.log_filename ``
898+ The name of a log file where output/errors from the step are being logged,
899+ or ``None `` if output is to stdout/stderr
900+
900901The inputs and outputs should not be altered but they may be used to get file
901902names to read or write.
902903
@@ -1544,6 +1545,93 @@ in the test case's :ref:`dev_test_case_init`.
15441545The relative path in ``filename `` is with respect to the step's work directory,
15451546and is converted to an absolute path internally before the step is run.
15461547
1548+ .. _dev_step_cached_output :
1549+
1550+ Cached output files
1551+ ~~~~~~~~~~~~~~~~~~~
1552+
1553+ Many ``compass `` test cases and steps are expensive enough that it can become
1554+ time consuming to run full workflows to produce meshes and initial conditions
1555+ in order to test simulations. Therefore, ``compass `` provides a mechanism for
1556+ caching the outputs of each step in a database so that they can be downloaded
1557+ and symlinked rather than being computed each time.
1558+
1559+ Cached output files are be stored in the ``compass_cache `` database within each
1560+ MPAS core's space on that LCRC server (see :ref: `dev_step_input_download `).
1561+ If the "cached" version of a step is selected, as we will describe below, each
1562+ of the test case's outputs will have a corresponding "input" file added with
1563+ the ``target `` being a cache file on the LCRC server and the ``filename `` being
1564+ the output file. ``compass `` uses the ``cached_files.json `` database to know
1565+ which cache files correspond to which step outputs.
1566+
1567+ A developer can indicate that ``compass `` test suite includes steps with cached
1568+ outputs in two ways. First, if all steps in a test case should have cached
1569+ output, the following notation should be used:
1570+
1571+ .. code-block :: none
1572+
1573+ ocean/global_ocean/QU240/mesh
1574+ cached
1575+ ocean/global_ocean/QU240/PHC/init
1576+ cached
1577+
1578+ That is, the word ``cached `` should appear after the test case on its own line.
1579+ The indentation is for visual clarity and is not required.
1580+
1581+
1582+ Second, ff only some steps in a test case should have cached output, they need
1583+ to be listed explicitly, as follows:
1584+
1585+ .. code-block :: none
1586+
1587+ ocean/global_ocean/QUwISC240/mesh
1588+ cached: mesh
1589+ ocean/global_ocean/QUwISC240/PHC/init
1590+ cached: initial_state ssh_adjustment
1591+
1592+ The line can be indented for visual clarity, but must begin with ``cached: ``,
1593+ followed by a list of steps separated by a single space.
1594+
1595+ Similarly, a user setting up test cases has two mechanisms for specifying which
1596+ test cases and steps should have cached outputs. If all steps in a test case
1597+ should have cached outputs, the suffix ``c `` can be added to the test number:
1598+
1599+ .. code-block :: none
1600+
1601+ compass setup -n 90c 91c 92 ...
1602+
1603+ In this example, test cases 90 and 91 (``mesh `` and ``init `` test cases from
1604+ the ``SOwISC12to60 `` global ocean mesh, in this case) are set up with cached
1605+ outputs in all steps and 92 (``performance_test ``) is not. This approach is
1606+ efficient but does not provide any control of which steps use cached outputs
1607+ and which do not.
1608+
1609+ A much more verbose approach is required if some steps use cached outputs and
1610+ others do not within a given test case. Each test case must be set up on its
1611+ own with the ``-t `` and ``--cached `` flags as follows:
1612+
1613+
1614+ .. code-block :: none
1615+
1616+ compass setup -t ocean/global_ocean/QU240/mesh --cached mesh ...
1617+ compass setup -t ocean/global_ocean/QU240/PHC/init --cached initial_state ...
1618+ ...
1619+
1620+ Cache files should be generated by first running the test case as normal, then
1621+ running the :ref: `dev_compass_cache ` command-line tool at the base of the work
1622+ directory, providing the names of the steps whose outputs should be added to
1623+ the cache. The resulting ``<mpas_core>_cached_files.json `` should be copied
1624+ to ``compass/<mpas_core>/cached_files.json `` in a ``compass `` branch.
1625+
1626+ Calls to ``compass cache `` must be made on Chrysalis or Anvil. If outputs were
1627+ produced on another machine, they must be transferred to one of these two
1628+ machines before calling ``compass cache ``. File can be added manually to the
1629+ LCRC server and the ``cached_files.json `` databases but this is not
1630+ recommended.
1631+
1632+ More details on cached outputs are available in the design document
1633+ :ref: `design_doc_cached_outputs `.
1634+
15471635.. _dev_step_namelists_and_streams :
15481636
15491637Adding namelist and streams files
0 commit comments