Skip to content

Commit

Permalink
add config to nfonll cli
Browse files Browse the repository at this point in the history
  • Loading branch information
giacomomagni committed Sep 18, 2023
1 parent 24bfe64 commit c29463b
Showing 1 changed file with 26 additions and 3 deletions.
29 changes: 26 additions & 3 deletions src/pineko/cli/fonll.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,16 @@
from .. import configs, fonll, parser, theory_card
from ._base import command

import pathlib

config_setting = click.option(
"-c",
"--configs",
"cfg",
default=None,
type=click.Path(resolve_path=True, path_type=pathlib.Path),
help="Explicitly specify config file (it has to be a valid TOML file).",
)

class TheoryCardError(Exception):
"""Raised when asked for FONLL theory cards with an original tcard as input that is not asking for FONLL."""
Expand Down Expand Up @@ -40,6 +50,7 @@ def get_list_grids_name(yaml_file):
@click.option("--FFNS5til", type=int, help="theoryID containing the ffns5til fktable")
@click.option("--FFNS5bar", type=int, help="theoryID containing the ffns5bar fktable")
@click.option("--overwrite", is_flag=True, help="Allow files to be overwritten")
@config_setting
def subcommand(
theoryid,
dataset,
Expand All @@ -51,8 +62,16 @@ def subcommand(
ffns5til,
ffns5bar,
overwrite,
cfg
):
"""Combine the different FKs needed to produce the FONLL prescription."""

path = configs.detect(cfg)
base_configs = configs.load(path)
configs.configs = configs.defaults(base_configs)
if cfg is not None:
print(f"Configurations loaded from '{path}'")

# Checks
if (ffn04 is None and ffns5til is not None) or (
ffn04 is not None and ffns5til is None
Expand All @@ -69,7 +88,6 @@ def subcommand(
)
raise InconsistentInputsError
# Get theory info
configs.configs = configs.defaults(configs.load())
tcard = theory_card.load(theoryid)
if not "DAMPPOWER" in tcard:
if tcard["DAMP"] != 0:
Expand Down Expand Up @@ -121,9 +139,14 @@ def subcommand(

@command.command("fonll_tcards")
@click.argument("theoryID", type=int)
def fonll_tcards(theoryid):
@config_setting
def fonll_tcards(theoryid, cfg):
"""Produce the FONLL tcards starting from the original tcard given by the theoryID."""
configs.configs = configs.defaults(configs.load())
path = configs.detect(cfg)
base_configs = configs.load(path)
configs.configs = configs.defaults(base_configs)
if cfg is not None:
print(f"Configurations loaded from '{path}'")
tcard = theory_card.load(theoryid)
tcard_parent_path = theory_card.path(theoryid).parent
if "FONLL" not in tcard["FNS"]:
Expand Down

0 comments on commit c29463b

Please sign in to comment.