Skip to content

Commit

Permalink
Generate index.html at top-level of results directory
Browse files Browse the repository at this point in the history
  • Loading branch information
tomvothecoder committed Jan 29, 2025
1 parent 47ef624 commit 83f1291
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[#]
sets = ["polar"]
case_id = "GPCP_v3.2"
variables = ["PRECT"]
ref_name = "GPCP_v3.2"
reference_name = "GPCP v2.2"
seasons = ["ANN", "DJF", "MAM", "JJA", "SON"]
regions = ["polar_S"]
test_colormap = "WhiteBlueGreenYellowRed.rgb"
reference_colormap = "WhiteBlueGreenYellowRed.rgb"
diff_colormap = "BrBG"
contour_levels = [0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5]
diff_levels = [-2, -1.5, -1, -0.75, -0.5, -0.25, 0.25, 0.5, 0.75, 1, 1.5, 2]
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# python -m auxiliary_tools.cdat_regression_testing.792-lat-lon-run-script.792_lat_lon_run_script
from auxiliary_tools.cdat_regression_testing.base_run_script import run_set

SET_NAME = "polar"
SET_DIR = "562-index-html"
# CFG_PATH: str | None = None
CFG_PATH: str | None = "auxiliary_tools/cdat_regression_testing/562-index-html/562_index_html.cfg"
MULTIPROCESSING = False

# %%
run_set(SET_NAME, SET_DIR, CFG_PATH, MULTIPROCESSING)
8 changes: 1 addition & 7 deletions e3sm_diags/e3sm_diags_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -388,13 +388,7 @@ def main(parameters=[]) -> List[CoreParameter]: # noqa B006
if parameters_results[0].no_viewer:
logger.info("Viewer not created because the no_viewer parameter is True.")
else:
path = os.path.join(parameters_results[0].results_dir, "viewer")
if not os.path.exists(path):
os.makedirs(path)

# TODO: This is where the path is passed for the viewer, which
# is where the index.html is stored.
index_path = create_viewer(path, parameters_results)
index_path = create_viewer(parameters_results)
logger.info("Viewer HTML generated at {}".format(index_path))

# Validate actual and expected parameters are aligned
Expand Down
2 changes: 1 addition & 1 deletion e3sm_diags/viewer/core_viewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def generate_page(self):
)
return url

raise RuntimeError("Error geneating the page.")
raise RuntimeError("Error generating the page.")

def generate_viewer(self, prompt_user=True):
"""Generate the webpage and ask the user if they want to see it."""
Expand Down
10 changes: 9 additions & 1 deletion e3sm_diags/viewer/main.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import collections
import os
from typing import List

from bs4 import BeautifulSoup

import e3sm_diags
from e3sm_diags.logger import custom_logger
from e3sm_diags.parameter.core_parameter import CoreParameter

from . import (
aerosol_budget_viewer,
Expand Down Expand Up @@ -115,11 +117,16 @@ def insert_data_in_row(row_obj, name, url):
return output


def create_viewer(root_dir, parameters):
def create_viewer(parameters: List[CoreParameter]) -> str:
"""
Based of the parameters, find the files with the
certain extension and create the viewer in root_dir.
"""
root_dir = parameters[0].results_dir

if not os.path.exists(root_dir):
os.makedirs(root_dir)

# Group each parameter object based on the `sets` parameter.
set_to_parameters = collections.defaultdict(list)
for param in parameters:
Expand All @@ -129,6 +136,7 @@ def create_viewer(root_dir, parameters):
# A list of (title, url) tuples that each viewer generates.
# This is used to create the main index.
title_and_url_list = []

# Now call the viewers with the list of parameters as the arguments.
for set_name, parameters in set_to_parameters.items():
logger.info(f"{set_name} {root_dir}")
Expand Down

0 comments on commit 83f1291

Please sign in to comment.