diff --git a/mlair/run_modules/pre_processing.py b/mlair/run_modules/pre_processing.py index 813873b8181fcb78917c5ef4e697da63b2941845..422ae8eea023351e24492144571a3fdcc455a7f8 100644 --- a/mlair/run_modules/pre_processing.py +++ b/mlair/run_modules/pre_processing.py @@ -9,6 +9,7 @@ from typing import Tuple import multiprocessing import requests import psutil +import traceback import numpy as np import pandas as pd @@ -79,7 +80,10 @@ class PreProcessing(RunEnvironment): logging.debug(f"Number of training stations: {n_train}") logging.debug(f"Number of val stations: {n_val}") logging.debug(f"Number of test stations: {n_test}") - self.create_latex_report() + try: + self.create_latex_report() + except Exception as e: + logging.warning(f"Can't create latex report: {e} ") def create_latex_report(self): """ @@ -336,6 +340,14 @@ def f_proc(data_handler, station, name_affix, store, **kwargs): try: res = data_handler.build(station, name_affix=name_affix, store_processed_data=store, **kwargs) except (AttributeError, EmptyQueryResult, KeyError, requests.ConnectionError, ValueError) as e: - logging.info(f"remove station {station} because it raised an error: {e}") + formatted_lines = traceback.format_exc().splitlines() + logging.info(f"remove station {station} because it raised an error: {e} -> {' | '.join(f_inspect_error(formatted_lines))}") res = None return res, station + + +def f_inspect_error(formatted): + for i in range(len(formatted) - 1, -1, -1): + if "mlair/mlair" not in formatted[i]: + return formatted[i - 3:i] + return formatted[-3:0]