Skip to content

Commit

Permalink
improve logging
Browse files Browse the repository at this point in the history
  • Loading branch information
giacomomagni committed Feb 15, 2024
1 parent 29312c9 commit 4f3c94d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
9 changes: 4 additions & 5 deletions src/pineko/cli/fonll.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
"""CLI entry point to FONLL."""

import logging
import pathlib

import click
import rich

from .. import configs, fonll, theory, theory_card
from ..fonll import TheoryCardError
from ._base import command

logger = logging.getLogger(__name__)


config_setting = click.option(
Expand Down Expand Up @@ -125,20 +124,20 @@ def fonll_ekos(theoryid, datasets, overwrite, cfg):

# now inherit ekos
# nf=3
logger.info("Inherit nf=3 from theory %i00", theoryid)
rich.print(f"[green] Inherit nf=3 ekos from theory {theoryid}00")
theory.TheoryBuilder(f"{theoryid}00", datasets, overwrite=overwrite).inherit_ekos(
f"{theoryid}01"
)
# nf=4
logger.info("Inherit nf=4 from theory %i04", theoryid)
rich.print(f"[green] Inherit nf=4 ekos from theory {theoryid}04")
theory.TheoryBuilder(f"{theoryid}04", datasets, overwrite=overwrite).inherit_ekos(
f"{theoryid}02"
)
theory.TheoryBuilder(f"{theoryid}04", datasets, overwrite=overwrite).inherit_ekos(
f"{theoryid}03"
)
# nf=5
logger.info("Inherit nf=5 from theory %i05", theoryid)
rich.print(f"[green] Inherit nf=5 ekos from theory {theoryid}05")
theory.TheoryBuilder(f"{theoryid}05", datasets, overwrite=overwrite).inherit_ekos(
f"{theoryid}06"
)
Expand Down
11 changes: 6 additions & 5 deletions src/pineko/fonll.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from pathlib import Path

import pineappl
import rich
import yaml

from . import configs, parser, theory_card
Expand Down Expand Up @@ -228,8 +229,8 @@ def assembly_combined_fk(
new_fk_path = configs.configs["paths"]["fktables"] / str(theoryid) / grid
if new_fk_path.exists():
if not overwrite:
logger.info(
"[green]Success:[/] skipping existing FK Table %s", str(new_fk_path)
rich.print(
f"[green]Success:[/] skipping existing FK Table {new_fk_path}"
)
return
produce_combined_fk(
Expand All @@ -250,9 +251,9 @@ def assembly_combined_fk(
cfg=cfg,
)
if new_fk_path.exists():
logger.info("[green]Success:[/] Wrote FK table to %s", str(new_fk_path))
rich.print(f"[green]Success:[/] Wrote FK table to {new_fk_path}")
else:
logger.info("[red]Failure:[/]")
rich.print("[red]Failure:[/]")


def produce_combined_fk(
Expand Down Expand Up @@ -362,5 +363,5 @@ def dump_tcards(tcard, tcard_parent_path, theoryid):
with open(theorycard_path, "w", encoding="UTF-8") as f:
yaml.safe_dump(theorycard, f)
paths_list.append(theorycard_path)
logger.info("[green]Wrote theory card to %s", str(theorycard_path))
rich.print(f"[green]Wrote theory card to {theorycard_path}")
return paths_list

0 comments on commit 4f3c94d

Please sign in to comment.