Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Refactor]: Refactor integration tests and add use_cfg flag to run_diags() #747

Merged
merged 31 commits into from
Dec 13, 2023
Merged
Changes from 1 commit
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
0c7307a
Remove default diags running with only Python API
tomvothecoder Nov 29, 2023
00865fe
Clean up `test_all_sets.py` and `test_diags.py`
tomvothecoder Nov 29, 2023
083ae3c
Fix paths for enso_diags in `all_sets_modified.cfg`
tomvothecoder Nov 29, 2023
daf1940
Fix referenced paths in `test_all_sets_image_diffs.py`
tomvothecoder Nov 29, 2023
9b55499
Remove unused NERSC function
tomvothecoder Nov 29, 2023
cb9f64e
Add debug mode
tomvothecoder Nov 30, 2023
715c025
Fix missing default value to debug in get_final_parameters
tomvothecoder Nov 30, 2023
0cdca64
Update pyproject.toml
tomvothecoder Nov 30, 2023
2f96ca4
Update e3sm_diags/run.py
tomvothecoder Nov 30, 2023
590fc37
Update e3sm_diags/run.py
tomvothecoder Nov 30, 2023
e7b049d
Fix sets to run
tomvothecoder Nov 30, 2023
9cb6777
Fix default sets
tomvothecoder Nov 30, 2023
0b99fff
Fix `test_all_sets_and_all_season`
tomvothecoder Nov 30, 2023
d19d4da
Refactor how cfg parameters are set
tomvothecoder Nov 30, 2023
7c9c607
Fix removal of CoreParameter default sets breaking integration test
tomvothecoder Nov 30, 2023
4c0a057
Fix class property and default sets
tomvothecoder Nov 30, 2023
63e29bf
Fix property
tomvothecoder Nov 30, 2023
4e24fb2
Update docstring
tomvothecoder Nov 30, 2023
4d562ce
Update e3sm_diags/run.py
tomvothecoder Nov 30, 2023
c2b5cf9
Fix comments
tomvothecoder Nov 30, 2023
2942f25
Fix cfg_params being modified in memory
tomvothecoder Nov 30, 2023
8618ba9
Update Makefile commands
tomvothecoder Nov 30, 2023
4e7bf9c
Revert core_parser changes
tomvothecoder Nov 30, 2023
3122650
Revert formatting changes
tomvothecoder Dec 1, 2023
720dc10
Revert formatting
tomvothecoder Dec 1, 2023
3ae6d54
Rename `debug` to `use_cfg`
tomvothecoder Dec 12, 2023
d3e0c9a
Update use_cfg param in test
tomvothecoder Dec 12, 2023
5eaf7b3
Remove `test_all_sets_modified_image_counts.py`
tomvothecoder Dec 12, 2023
9f1862a
Remove `test_dataset.py` and move `test_run.py` to unit tests dir
tomvothecoder Dec 12, 2023
13547ad
Update attr comment in Run class
tomvothecoder Dec 12, 2023
3ff0aa7
Rename `debug_params` to `params`
tomvothecoder Dec 13, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix comments
  • Loading branch information
tomvothecoder committed Dec 13, 2023
commit c2b5cf9b75e1363e3ca3706216483a2ae533cee0
1 change: 0 additions & 1 deletion e3sm_diags/parser/core_parser.py
Original file line number Diff line number Diff line change
@@ -725,7 +725,6 @@ def get_parameters(
# Sometimes, one of these can be None, so get the one that's None.
parameter = parameter if parameter else cmdline_parameter

# FIXME: This returns an empty list because
final_parameters = self.select(parameter, final_parameters)
self._add_aliases(final_parameters)

43 changes: 27 additions & 16 deletions e3sm_diags/run.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import copy
from itertools import chain
from typing import List, Union
from typing import List

import e3sm_diags # noqa: F401
from e3sm_diags.e3sm_diags_driver import get_default_diags_path, main
@@ -53,9 +53,10 @@ def run_diags(
* If True, only the parameters passed via ``parameters`` will be
run. The sets to run are based on the sets defined by the
parameters. This makes it easy to debug a few sets.
* If False, run all sets using the list of parameters passed in this
function and parameters defined in a .cfg file (if defined).
This is the default option.
* If False, run all sets using the list of parameters passed in
this function and parameters defined in a .cfg file (if
defined), or use the .cfg file(s) for default diagnostics. This
is the default option.

Returns
-------
@@ -67,7 +68,6 @@ def run_diags(
RuntimeError
If a diagnostic run using a parameter fails for any reason.
"""

params = self.get_run_parameters(parameters, debug)

if params is None or len(params) == 0:
@@ -142,21 +142,16 @@ def _get_cfg_parameters(
"""
run_params = []

# Get parameters from user-defined .cfg file or default diags .cfg
# file.

if self.has_cfg_file_arg:
cfg_params = self._get_diags_from_cfg_file()
cfg_params = self._get_custom_params_from_cfg_file()
else:
run_type = parameters[0].run_type
cfg_params = self._get_default_diags_from_cfg_file(run_type)
cfg_params = self._get_default_params_from_cfg_file(run_type)

# Loop over the sets to run and get the related parameters.
if len(self.sets_to_run) == 0:
self.sets_to_run = DEFAULT_SETS

for set_name in self.sets_to_run:
# For each of the set_names, get the corresponding parameter.
param = self._get_instance_of_param_class(
SET_TO_PARAMETERS[set_name], parameters
)
@@ -187,17 +182,33 @@ def _get_cfg_parameters(

return run_params

def _get_diags_from_cfg_file(self) -> Union[List, List[CoreParameter]]:
"""
Get parameters defined by the cfg file passed to -d/--diags (if set).
def _get_custom_params_from_cfg_file(self) -> List[CoreParameter]:
"""Get parameters using the cfg file set by `-d`/`--diags`.

Returns
-------
List[CoreParameter]
A list of parameter objects.
"""
params = self.parser.get_cfg_parameters(argparse_vals_only=False)

params_final = self._convert_params_to_subclass(params)

return params_final

def _get_default_diags_from_cfg_file(self, run_type):
def _get_default_params_from_cfg_file(self, run_type: str) -> List[CoreParameter]:
"""Get parameters using the default diagnostic .cfg file(s).

Parameters
----------
run_type : str
The run type used to check for which .cfg file(s) to reference.

Returns
-------
List[CoreParameter]
A list of parameter objects.
"""
# Get the paths to the default diags .cfg file(s).
paths = []
for set_name in self.sets_to_run: