From 1d011a109af4db83d1f535c294a9e3bd184f1c8f Mon Sep 17 00:00:00 2001 From: juacrumar Date: Tue, 28 Oct 2025 11:49:13 +0100 Subject: [PATCH 1/2] fail if there is no pinecard at all ; override the path with what the user provides ; fail if tool not discovered --- poetry.lock | 10 +++++----- pyproject.toml | 2 +- src/pinefarm/cli/run.py | 21 ++++++++++++++++++++- src/pinefarm/external/__init__.py | 10 ++++++---- 4 files changed, 32 insertions(+), 11 deletions(-) diff --git a/poetry.lock b/poetry.lock index cb53f29..9dceba4 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,4 +1,4 @@ -# This file is automatically @generated by Poetry 2.1.3 and should not be changed by hand. +# This file is automatically @generated by Poetry 2.2.1 and should not be changed by hand. [[package]] name = "adani" @@ -793,14 +793,14 @@ files = [ [[package]] name = "nnpdf-data" -version = "0.0.3" +version = "4.1.1" description = "The NNPDF data repository" optional = false python-versions = "<4.0,>=3.9" groups = ["main"] files = [ - {file = "nnpdf_data-0.0.3-py3-none-any.whl", hash = "sha256:bf1d5243973ec8ab0542b8e69d80955dd989d566549ad13a410cee78e81ab948"}, - {file = "nnpdf_data-0.0.3.tar.gz", hash = "sha256:23398ad186f701a597c86ce325a9328660860ae96cc40f0f5de1cebd382ceed1"}, + {file = "nnpdf_data-4.1.1-py3-none-any.whl", hash = "sha256:8f85f86b6d1e44b42694ccd8f2b0903ebb31c9a4434aef6667ebe2bb9e49ab3a"}, + {file = "nnpdf_data-4.1.1.tar.gz", hash = "sha256:405fc376945f4784e83b5fc03dda6fe3300c0386cdf18457b68988fb205fa4a6"}, ] [package.dependencies] @@ -1949,4 +1949,4 @@ vrap = ["eko"] [metadata] lock-version = "2.1" python-versions = "^3.9" -content-hash = "795e8096880d0bfca45a08b3c6a858f8b332767621a72742e984e28aa0f79a38" +content-hash = "693c8610b63a53d8efcab43cc8d2c715334f2e5a2e353bfc27d1ab62c026682b" diff --git a/pyproject.toml b/pyproject.toml index 575ad43..268d5b7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -36,7 +36,7 @@ pineappl = "^1.0" more-itertools = "^8.10.0" appdirs = "^1.4.4" tomli = "^2.0.1" -nnpdf-data = { version = "0.0.3" } +nnpdf-data = { version = "^4.1.1" } yadism = { extras = ["box"], version = "^0.13.7", optional=true, markers = "python_version < '3.13'" } eko = { extras = ["box"], version = "^0.14.2", optional=true, markers = "python_version < '3.13'" } diff --git a/src/pinefarm/cli/run.py b/src/pinefarm/cli/run.py index a313870..f47163a 100644 --- a/src/pinefarm/cli/run.py +++ b/src/pinefarm/cli/run.py @@ -58,7 +58,26 @@ def subcommand(pinecard, theory_path, pdf, dry, finalize=None): finalize: str path to the runfolder in which to run the post processing step """ - pinecard = pathlib.Path(pinecard) + + # Check whether pinecard is a path. If it is, override the configuration. + if (pinpath := pathlib.Path(pinecard)).exists(): + # If this pinecard is not in the runcards folder, warn the user but let it continue + if pinpath.parent.absolute() != ( + rcards := configs.configs["paths"]["runcards"] + ): + logger.warning( + f"The pinecard ({pinecard}) is not in the runcards ({rcards}) folder, overriding config." + ) + configs.configs["paths"]["runcards"] = pinpath.parent + pinecard = pinpath + # Otherwise, use the configuration to fill the path + else: + pinecard = configs.configs["paths"]["runcards"] / pinecard + + # Check for existence + if not pinecard.exists(): + raise FileNotFoundError(f"The pinecard {pinecard} cannot be found") + if finalize is not None: finalize = pathlib.Path(finalize) diff --git a/src/pinefarm/external/__init__.py b/src/pinefarm/external/__init__.py index 9844e93..3423915 100644 --- a/src/pinefarm/external/__init__.py +++ b/src/pinefarm/external/__init__.py @@ -27,7 +27,6 @@ def decide_external_tool(dsname: str): """ # The decisions are usually based on the existence of a `.yaml` file with a specific name # or a prefix in the pinecard - if dsname.startswith("NNLOJET"): from .nnlojet import NNLOJET @@ -54,7 +53,10 @@ def decide_external_tool(dsname: str): return integrability.Integrability, "brown" - # Defaults to Madgraph - from . import mg5 # pylint: disable=import-outside-toplevel + # Try with Madgraph... + if (configs["paths"]["runcards"] / dsname / "launch.txt").exists(): + from . import mg5 # pylint: disable=import-outside-toplevel + + return mg5.Mg5, "blue" - return mg5.Mg5, "blue" + raise ValueError(f"pinefarm could not discover the tool to use for {dsname}") From ce2898abaa4ba00ff232642cc817eef9c698e042 Mon Sep 17 00:00:00 2001 From: juacrumar Date: Tue, 28 Oct 2025 12:05:16 +0100 Subject: [PATCH 2/2] blank line --- src/pinefarm/cli/run.py | 1 - 1 file changed, 1 deletion(-) diff --git a/src/pinefarm/cli/run.py b/src/pinefarm/cli/run.py index f47163a..ddbcfd3 100644 --- a/src/pinefarm/cli/run.py +++ b/src/pinefarm/cli/run.py @@ -58,7 +58,6 @@ def subcommand(pinecard, theory_path, pdf, dry, finalize=None): finalize: str path to the runfolder in which to run the post processing step """ - # Check whether pinecard is a path. If it is, override the configuration. if (pinpath := pathlib.Path(pinecard)).exists(): # If this pinecard is not in the runcards folder, warn the user but let it continue