Skip to content

Commit

Permalink
dump theory and operator cards to log file
Browse files Browse the repository at this point in the history
  • Loading branch information
scarlehoff committed Apr 24, 2024
1 parent 546bb90 commit 47aafa7
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions n3fit/src/evolven3fit/evolve.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from collections import defaultdict
import json
import logging
import pathlib
import sys
Expand All @@ -19,7 +20,7 @@

LOGGING_SETTINGS = {
"formatter": logging.Formatter("%(asctime)s %(name)s/%(levelname)s: %(message)s"),
"level": logging.INFO,
"level": logging.DEBUG,
}


Expand Down Expand Up @@ -61,8 +62,14 @@ def evolve_fit(
log_file = logging.FileHandler(log_file)
stdout_log = logging.StreamHandler(sys.stdout)
for log in [log_file, stdout_log]:
log.setLevel(LOGGING_SETTINGS["level"])
log.setFormatter(LOGGING_SETTINGS["formatter"])

# The log file will get everything
log_file.setLevel(LOGGING_SETTINGS["level"])
# While the terminal only up to info
stdout_log.setLevel(logging.INFO)


for logger in (_logger, *[logging.getLogger("eko")]):
logger.handlers = []
logger.setLevel(LOGGING_SETTINGS["level"])
Expand All @@ -82,7 +89,7 @@ def evolve_fit(
_logger.info(f"Loading eko from theory {theoryID}")
eko_path = (Loader().check_theoryID(theoryID).path) / "eko.tar"
except FileNotFoundError:
_logger.info(f"eko not found in theory {theoryID}, we will construct it")
_logger.warning(f"eko not found in theory {theoryID}, we will construct it")
theory, op = eko_utils.construct_eko_cards(
theoryID, q_fin, q_points, x_grid, op_card_dict, theory_card_dict
)
Expand All @@ -97,6 +104,9 @@ def evolve_fit(
# Read the cards directly from the eko to make sure they are consistent
theory = eko_op.theory_card
op = eko_op.operator_card
# And dump them to the log
_logger.debug(f"Theory card: {json.dumps(theory.raw)}")
_logger.debug(f"Opeartor card: {json.dumps(op.raw)}")

# Modify the info file with the fit-specific info
info = info_file.build(theory, op, 1, info_update={})
Expand Down

0 comments on commit 47aafa7

Please sign in to comment.