diff --git a/.github/workflows/build_workflow.yml b/.github/workflows/build_workflow.yml index e17f246..70f8b52 100644 --- a/.github/workflows/build_workflow.yml +++ b/.github/workflows/build_workflow.yml @@ -47,6 +47,7 @@ jobs: # since the action is run on a branch in detached head state. # This is the equivalent of running "pre-commit run --all-files" locally. # If you commit with the `--no-verify` flag, this check may fail. + # TODO: this doesn't seem to run when I run `git commit` locally. I always have to run `pre-commit run --all-files` manually. - name: Install and Run Pre-commit uses: pre-commit/action@v3.0.0 diff --git a/zppy_interfaces/global_time_series/coupled_global.py b/zppy_interfaces/global_time_series/coupled_global.py index 41eeaf4..35464fb 100644 --- a/zppy_interfaces/global_time_series/coupled_global.py +++ b/zppy_interfaces/global_time_series/coupled_global.py @@ -8,7 +8,11 @@ import xcdat from zppy_interfaces.global_time_series.coupled_global_plotting import make_plot_pdfs -from zppy_interfaces.global_time_series.coupled_global_utils import Metric, Variable +from zppy_interfaces.global_time_series.coupled_global_utils import ( + INCLUSIONS_DIR, + Metric, + Variable, +) from zppy_interfaces.global_time_series.coupled_global_viewer import ( create_viewer, create_viewer_index, @@ -66,13 +70,9 @@ def land_csv_row_to_var(csv_row: List[str]) -> Variable: def construct_land_variables(requested_vars: List[str]) -> List[Variable]: var_list: List[Variable] = [] header = True - # If this file is being run stand-alone, then - # it will search the directory above the git directory # TODO: how do we make sure the csv is actually accessible???? # The current directory is where we ran the code from, which is not necessarily where the csv is. - csv_path = ( - "/home/ac.forsyth2/ez/zppy-interfaces/zppy_interfaces/global_time_series/" - ) + csv_path = INCLUSIONS_DIR with open(f"{csv_path}/zppy_land_fields.csv", newline="") as csv_file: logger.debug("Reading zppy_land_fields.csv") var_reader = csv.reader(csv_file) @@ -221,13 +221,13 @@ def globalAnnualHelper( var, "year" ) data_array = annual_average_dataset_for_var.data_vars[var] - import pprint - - pprint.pprint( - f"annual_average_dataset_for_var attributes={annual_average_dataset_for_var.attrs}" - ) - pprint.pprint(f"data_array attributes={data_array.attrs}") + # import pprint + # pprint.pprint( + # f"annual_average_dataset_for_var attributes={annual_average_dataset_for_var.attrs}" + # ) + # pprint.pprint(f"data_array attributes={data_array.attrs}") # data_array *= area*landfrac + # TODO: Determine how to get area and landfrac else: # This shouldn't be possible raise ValueError(f"Invalid Enum option for metric={metric}") diff --git a/zppy_interfaces/global_time_series/coupled_global_utils.py b/zppy_interfaces/global_time_series/coupled_global_utils.py index e32d496..b54f956 100644 --- a/zppy_interfaces/global_time_series/coupled_global_utils.py +++ b/zppy_interfaces/global_time_series/coupled_global_utils.py @@ -1,5 +1,10 @@ from enum import Enum +# TODO: how to determine this automatically? +INCLUSIONS_DIR = ( + "/home/ac.forsyth2/ez/zppy-interfaces/zppy_interfaces/global_time_series/" +) + class Metric(Enum): AVERAGE = 1 diff --git a/zppy_interfaces/global_time_series/coupled_global_viewer.py b/zppy_interfaces/global_time_series/coupled_global_viewer.py index ddc1544..271c9a9 100644 --- a/zppy_interfaces/global_time_series/coupled_global_viewer.py +++ b/zppy_interfaces/global_time_series/coupled_global_viewer.py @@ -3,7 +3,10 @@ from bs4 import BeautifulSoup -from zppy_interfaces.global_time_series.coupled_global_utils import Variable +from zppy_interfaces.global_time_series.coupled_global_utils import ( + INCLUSIONS_DIR, + Variable, +) from zppy_interfaces.global_time_series.utils import Parameters from zppy_interfaces.multi_utils.logger import _setup_custom_logger from zppy_interfaces.multi_utils.viewer import OutputViewer @@ -69,7 +72,6 @@ def create_viewer(parameters: Parameters, vars: List[Variable], component: str) return url -# TODO: looks like we need to modify this (and have a index_template.html to use) to include all component viewers on the index # Copied from E3SM Diags and modified def create_viewer_index( root_dir: str, title_and_url_list: List[Tuple[str, str]] @@ -93,13 +95,10 @@ def insert_data_in_row(row_obj, name: str, url: str): td.append(a) row_obj.append(td) + # import sys + # logger.debug(f"sys.prefix: {sys.prefix}, ls sys.prefix: {os.listdir(sys.prefix)}") # TODO: figure out install_path - import sys - - logger.debug(f"sys.prefix: {sys.prefix}, ls sys.prefix: {os.listdir(sys.prefix)}") - install_path: str = ( - "/home/ac.forsyth2/ez/zppy-interfaces/zppy_interfaces/global_time_series/" - ) + install_path: str = INCLUSIONS_DIR path: str = os.path.join(install_path, "index_template.html") output: str = os.path.join(root_dir, "index.html") diff --git a/zppy_interfaces/multi_utils/logger.py b/zppy_interfaces/multi_utils/logger.py index 128d3ca..7f9eee2 100644 --- a/zppy_interfaces/multi_utils/logger.py +++ b/zppy_interfaces/multi_utils/logger.py @@ -17,6 +17,8 @@ logging.getLogger().addHandler(console_handler) +# TODO: Why are logging messages printing 3x? +# Following the example of https://github.com/xCDAT/xcdat/blob/27396e510185fddfe04921427ce2d67618a93709/xcdat/_logger.py#L20 def _setup_custom_logger(name, propagate=True) -> logging.Logger: """Sets up a custom logger. @@ -27,7 +29,7 @@ def _setup_custom_logger(name, propagate=True) -> logging.Logger: name : str Name of the file where this function is called. propagate : bool, optional - Whether to propagate logger messages or not, by default False + Whether to propagate logger messages or not, by default True Returns ------- @@ -63,6 +65,5 @@ def _setup_custom_logger(name, propagate=True) -> logging.Logger: """ logger = logging.getLogger(name) logger.propagate = propagate - logger.setLevel(logging.DEBUG) return logger