Skip to content

Commit

Permalink
Print warning when report generation failed.
Browse files Browse the repository at this point in the history
So far, a failure during report generation was logged but not printed to
the terminal, so it could easily be missed by the user.

To change this, also print an explicit, red warning to the terminal in
that case.
  • Loading branch information
luator committed Oct 28, 2024
1 parent 301302c commit e6118bb
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/cluster_utils/server/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from . import data_analysis, distributions
from .latex_utils import LatexFile
from .optimizers import Optimizer
from .utils import log_and_print, shorten_string
from .utils import log_and_print, make_red, shorten_string


def init_plotting():
Expand Down Expand Up @@ -313,7 +313,12 @@ def filename_gen(base_path):
latex.produce_pdf(output_file)
log_and_print(logger, f"Report saved at {output_file}")
except Exception:
logging.warning("Could not generate PDF report", exc_info=True)
logging.warning("Failed to generate PDF report", exc_info=True)
print(
make_red(
"Warning: Failed to generate PDF report. See log for details."
)
)


def distribution_plots(
Expand Down Expand Up @@ -494,4 +499,9 @@ def filename_gen(base_path: str | os.PathLike) -> Iterator[str]:
latex.produce_pdf(output_file)
logger.info("Saved report to %s", output_file)
except Exception:
logger.warning("Could not generate PDF report", exc_info=True)
logger.warning("Failed to generate PDF report", exc_info=True)
print(
make_red(
"Warning: Failed to generate PDF report. See log for details."
)
)

0 comments on commit e6118bb

Please sign in to comment.