diff --git a/src/metaDMG/fit/fits.py b/src/metaDMG/fit/fits.py index cf161b9..d539dae 100644 --- a/src/metaDMG/fit/fits.py +++ b/src/metaDMG/fit/fits.py @@ -10,7 +10,8 @@ import numpyro import pandas as pd from logger_tt import logger -from tqdm import tqdm +from tqdm.rich import tqdm +from tqdm.std import TqdmExperimentalWarning from metaDMG.errors import BadDataError, FittingError from metaDMG.fit import bayesian, fit_utils, frequentist @@ -18,12 +19,21 @@ from metaDMG.utils import Config +# from tqdm import tqdm + numpyro.enable_x64() #%% BAYESIAN_MAXIMUM_SIZE = 100 +#%% + +# XXX Works, but should be a better way +# with warnings.catch_warnings(): +warnings.filterwarnings("ignore", category=TqdmExperimentalWarning) + + #%% diff --git a/src/metaDMG/fit/serial.py b/src/metaDMG/fit/serial.py index 06f9f98..fc41b64 100644 --- a/src/metaDMG/fit/serial.py +++ b/src/metaDMG/fit/serial.py @@ -332,7 +332,7 @@ def run_LCA(config: Config, force: bool = False) -> None: def run_damage_no_lca(config: Config, force: bool = False) -> None: - logger.info(f"Getting damage.") + # logger.info(f"Getting damage.") targets = [ config["path_mismatches_txt"], @@ -349,7 +349,7 @@ def run_damage_no_lca(config: Config, force: bool = False) -> None: if not metaDMG_cpp_is_valid(config): raise metadamageError() - logger.info(f"Computing damage. NOTE: NO LCA.") + logger.info(f"Computing mismatch matrices (without LCA).") command_damage = get_damage_command(config) command_damage_ugly = get_damage_ugly_command(config) @@ -366,7 +366,7 @@ def run_damage_no_lca(config: Config, force: bool = False) -> None: delete_tmp_dir(config) else: - logger.info(f"Damage has already been computed before. NOTE: NO LCA.") + logger.info(f"Loading mismatch matrices (without LCA).") #%% @@ -384,18 +384,18 @@ def run_cpp(config: Config, force: bool = False) -> None: def get_df_mismatches(config: Config, force: bool = False) -> pd.DataFrame: - logger.info(f"Getting df_mismatches") + # logger.info(f"Getting df_mismatches") target = data_dir(config, name="mismatches") if do_run(target, force=force): - logger.info(f"Computing df_mismatches.") + logger.info(f"Computing mismatch matrix dataframes.") df_mismatches = mismatches.compute(config) target.parent.mkdir(parents=True, exist_ok=True) df_mismatches.to_parquet(target) else: - logger.info(f"Loading df_mismatches.") + logger.info(f"Loading mismatch matrix dataframes.") df_mismatches = pd.read_parquet(target) return df_mismatches @@ -414,21 +414,21 @@ def get_df_fit_results( force: bool = False, ) -> pd.DataFrame: - logger.info(f"Getting df_fit_results.") + # logger.info(f"Getting df_fit_results.") target = data_dir(config, name="fit_results") if do_load(target, force=force): - logger.info(f"Try to load df_fit_results.") + logger.info(f"Try to load fit results.") df_fit_results = pd.read_parquet(target) # if frequentist fits only, return immediately if not config["bayesian"]: - logger.info(f"Loading df_fit_results (frequentist).") + logger.info(f"Loading fit results (MAP).") return df_fit_results # if df_fit_results has already been run with Bayesian, return this if dataframe_columns_contains(df_fit_results, "damage"): - logger.info(f"Loading df_fit_results (Bayesian).") + logger.info(f"Loading fit results (Bayesian).") return df_fit_results # Compute the fits @@ -456,12 +456,12 @@ def get_df_results( force: bool = False, ) -> pd.DataFrame: - logger.info(f"Getting df_results.") + # logger.info(f"Getting df_results.") target = data_dir(config, name="results") if do_load(target, force=force): - logger.info(f"Loading df_results.") + logger.info(f"Loading results as dataframe.") df_results = pd.read_parquet(target) # if frequentist fits only, return immediately @@ -473,7 +473,7 @@ def get_df_results( return df_results # Compute the results: - logger.info(f"Computing df_results.") + logger.info(f"Computing final results.") df_results = results.merge(config, df_mismatches, df_fit_results) target.parent.mkdir(parents=True, exist_ok=True) df_results.to_parquet(target) diff --git a/src/metaDMG/loggers/log_config.yaml b/src/metaDMG/loggers/log_config.yaml index 67928fd..111d82a 100644 --- a/src/metaDMG/loggers/log_config.yaml +++ b/src/metaDMG/loggers/log_config.yaml @@ -8,34 +8,25 @@ formatters: format: "[%(asctime)s] | %(name)s:%(lineno)d | %(levelname)s | %(message)s" datefmt: "%Y-%m-%d %H:%M:%S" brief: - format: "[%(asctime)s] | %(levelname)s | %(message)s" + # format: "[%(asctime)s] | %(levelname)s | %(message)s" + format: "%(message)s" datefmt: "%Y-%m-%d %H:%M:%S" handlers: console: - class: logging.StreamHandler + class: rich.logging.RichHandler level: INFO formatter: brief - stream: ext://sys.stdout - - error_file_handler: - class: logging.handlers.TimedRotatingFileHandler - level: DEBUG - formatter: simple - filename: logs/log.txt - backupCount: 15 - encoding: utf8 - when: midnight - -loggers: - urllib3: - level: WARNING - handlers: [console, error_file_handler] - propagate: no + # stream: ext://sys.stdout + show_time: true + show_level: true + show_path: false + rich_tracebacks: true + log_time_format: "%Y-%m-%d %H:%M:%S" root: level: DEBUG - handlers: [console, error_file_handler] + handlers: [console] logger_tt: suppress: ["exchangelib", "numba", "matplotlib", "absl"]