src.output_manager module¶
Implementation of the OutputManager plugin, which templates html and organizes the PODs’ output files.
- class src.output_manager.AbstractOutputManager(case)[source]¶
Bases:
ABC
Abstract interface for any OutputManager.
- src.output_manager.html_templating_dict(pod)[source]¶
Returns the dict of recognized substitutions to perform in html templating for pod.
- class src.output_manager.HTMLSourceFileMixin[source]¶
Bases:
object
Convienience method to define location of html templates in one place.
- property CASE_TEMP_HTML¶
Path to temporary top-level html file for case that gets appended to as PODs finish.
- class src.output_manager.HTMLPodOutputManager(pod, output_mgr)[source]¶
Bases:
HTMLSourceFileMixin
Performs cleanup tasks specific to a single POD when that POD has finished running.
- __init__(pod, output_mgr)[source]¶
Copy configuration info from
Diagnostic
object pod.- Parameters:
pod (
Diagnostic
) – POD which generated the output files being processed.output_mgr – Parent OutputManager handling the overall processing of output files from all PODs.
- make_pod_html()[source]¶
Perform templating on POD’s html results page(s).
Wraps
append_html_template()
. Looks for all html files in$POD_CODE_DIR
, templates them, and copies them to$POD_WK_DIR
, respecting subdirectory structure (seerecursive_copy()
).
- convert_pod_figures(src_subdir: str, dest_subdir: str)[source]¶
Convert all vector graphics in
$POD_WK_DIR/
src_subdir to .png files using ghostscript (included in the _MDTF_base conda environment).All vector graphics files (identified by extension) in any subdirectory of
$POD_WK_DIR/
src_subdir are converted to .png files by running ghostscript in a subprocess. Afterwards, any bitmap files (identified by extension) in any subdirectory of$POD_WK_DIR/
src_subdir are moved to$POD_WK_DIR/
dest_subdir, preserving subdirectories (viarecursive_copy()
.)- Parameters:
src_subdir – Subdirectory tree of
$POD_WK_DIR
to search for vector graphics files.dest_subdir – Subdirectory tree of
$POD_WK_DIR
to move converted bitmap files to.
- cleanup_pod_files()[source]¶
Copy and remove remaining files to
$POD_WK_DIR
.In order, this 1) copies any bitmap figures in any subdirectory of
$POD_OBS_DATA
to$POD_WK_DIR/obs
(needed for legacy PODs without digested observational data), 2) removes vector graphics if requested, 3) removes netCDF scratch files in$POD_WK_DIR
if requested.Settings are set at runtime, when
ConfigManager
is initialized.
- make_output()[source]¶
Top-level method to make POD-specific output, post-init. Split off into its own method to make subclassing easier.
In order, this 1) creates the POD’s html output page from its included template, replacing
CASENAME
and other template variables with their current values, and adds a link to the POD’s page from the top-level html report; 2) converts the POD’s output plots (in PS or EPS vector format) to a bitmap format for webpage display; 3) copies all requested files to the output directory and deletes temporary files.
- property CASE_TEMP_HTML¶
Path to temporary top-level html file for case that gets appended to as PODs finish.
- POD_HTML(pod)¶
Path to pod’s html output file in the working directory.
- html_src_file(file_name)¶
Returns full path to a framework-supplied html template file_name or other part of the output page.
- static pod_html_template_file_name(pod)¶
Name of the html template file to use for pod.
- write_data_log_file()¶
Writes *.data.log file to output containing info on data files used.
- class src.output_manager.HTMLOutputManager(case)[source]¶
Bases:
AbstractOutputManager
,HTMLSourceFileMixin
OutputManager that collects the output of all PODs run as a part of case as html pages. Currently the only value for the OutputManager plugin, so it’s selected by default.
Instantiates
HTMLPodOutputManager
objects to handle processing the output of each POD.- append_result_link(pod)[source]¶
Update the top level index.html page with a link to pod’s results.
This simply appends one of two html fragments to index.html:
src/html/pod_result_snippet.html
if pod completed successfully, orsrc/html/pod_error_snippet.html
if an exception was raised during pod’s setup or execution.
- verify_pod_links(pod)[source]¶
Check for missing files linked to from POD’s html page.
See documentation for
LinkVerifier
. This method callsLinkVerifier
to check existence of all files linked to from the POD’s own top-level html page (after templating). If any files are missing, an error message listing them is written to the run’sindex.html
page (located insrc/html/pod_missing_snippet.html
).
- make_html(cleanup=True)[source]¶
Add header and footer to the temporary output file at CASE_TEMP_HTML.
- backup_config_files()[source]¶
Record user input configuration in a file named
config_save.json
for rerunning.
- make_output()[source]¶
Top-level method for doing all output activity post-init. Spun into a separate method to make subclassing easier.
- property CASE_TEMP_HTML¶
Path to temporary top-level html file for case that gets appended to as PODs finish.
- POD_HTML(pod)¶
Path to pod’s html output file in the working directory.
- html_src_file(file_name)¶
Returns full path to a framework-supplied html template file_name or other part of the output page.
- static pod_html_template_file_name(pod)¶
Name of the html template file to use for pod.
- write_data_log_file()¶
Writes *.data.log file to output containing info on data files used.
- class src.output_manager.MultirunHTMLOutputManager(pod)[source]¶
Bases:
HTMLOutputManager
,AbstractOutputManager
,HTMLSourceFileMixin
OutputManager that collects the output of all PODs run in multirun mode as html pages.
Instantiates
HTMLPodOutputManager
objects to handle processing the output of each POD.- append_result_link(pod)[source]¶
Update the top level index.html page with a link to pod’s results.
This simply appends one of two html fragments to index.html:
src/html/pod_result_snippet.html
if pod completed successfully, orsrc/html/pod_error_snippet.html
if an exception was raised during pod’s setup or execution.
- make_output(pod)[source]¶
Top-level method for doing all output activity post-init. Spun into a separate method to make subclassing easier.
- make_html(cleanup=True)[source]¶
Add header and footer to the temporary output file at CASE_TEMP_HTML.
- property CASE_TEMP_HTML¶
Path to temporary top-level html file for case that gets appended to as PODs finish.
- POD_HTML(pod)¶
Path to pod’s html output file in the working directory.
- backup_config_files()¶
Record user input configuration in a file named
config_save.json
for rerunning.
- copy_to_output()¶
Copy all files to the user-specified output directory (
$OUTPUT_DIR
).
- html_src_file(file_name)¶
Returns full path to a framework-supplied html template file_name or other part of the output page.
- make_tar_file()¶
Make tar file of web/bitmap output.
- static pod_html_template_file_name(pod)¶
Name of the html template file to use for pod.
- verify_pod_links(pod)¶
Check for missing files linked to from POD’s html page.
See documentation for
LinkVerifier
. This method callsLinkVerifier
to check existence of all files linked to from the POD’s own top-level html page (after templating). If any files are missing, an error message listing them is written to the run’sindex.html
page (located insrc/html/pod_missing_snippet.html
).
- write_data_log_file()¶
Writes *.data.log file to output containing info on data files used.