diff --git a/src/eko/runner/__init__.py b/src/eko/runner/__init__.py index c985fb1fd..0d05183f5 100644 --- a/src/eko/runner/__init__.py +++ b/src/eko/runner/__init__.py @@ -1,12 +1,18 @@ """Manage steps to DGLAP solution, and operator creation.""" import os +from pathlib import Path from typing import Union +from ..io import runcards from ..io.runcards import OperatorCard, TheoryCard from ..io.types import RawCard -from . import legacy +from . import managed +# TODO: drop this altogether, replacing just with managed.solve +# it is currently kept not to break the interface, but the runcards upgrade and +# path conversion should be done by the caller, here we just clearly declare +# which types we expect def solve( theory_card: Union[RawCard, TheoryCard], operators_card: Union[RawCard, OperatorCard], @@ -26,18 +32,13 @@ def solve( to the solution of the |DGLAP| equation itself, and determine the resulting operator features. - Parameters - ---------- - theory_card : - theory parameters and related settings - operator_card : - solution configurations, and further EKO options - path : - path where to store the computed operator - Note ---- For further information about EKO inputs and output see :doc:`/code/IO` """ - legacy.Runner(theory_card, operators_card, path).compute() + # TODO: drop this + # legacy.Runner(theory_card, operators_card, path).compute() + + new_theory, new_operator = runcards.update(theory_card, operators_card) + managed.solve(new_theory, new_operator, Path(path)) diff --git a/src/eko/runner/managed.py b/src/eko/runner/managed.py new file mode 100644 index 000000000..3aaef21ef --- /dev/null +++ b/src/eko/runner/managed.py @@ -0,0 +1,29 @@ +"""Fully managed runner. + +This is an automated runner, mainly suggested for small EKOs computations. + +The primitives used here to compute the various pieces are part of the public +interface, and should be directly used to manage a more complex run for a +considebaly large operator. + +Thus, parallelization and multi-node execution is possible using EKO primitives, +but not automatically performed. + +""" + +from pathlib import Path + +from ..io.runcards import OperatorCard, TheoryCard +from ..io.struct import EKO +from . import recipes + + +def solve(theory: TheoryCard, operator: OperatorCard, path: Path): + """Solve DGLAP equations in terms of evolution kernel operators (EKO).""" + with EKO.create(path) as builder: + eko = builder.load_cards(theory, operator).build() + + recipes.create(eko) + + # for recipe in eko.recipes: + # pass diff --git a/src/eko/runner/recipes.py b/src/eko/runner/recipes.py index 0e6163b66..659667080 100644 --- a/src/eko/runner/recipes.py +++ b/src/eko/runner/recipes.py @@ -4,10 +4,9 @@ from .. import EKO from .. import scale_variations as sv -from ..io import runcards from ..io.dictlike import DictLike from ..io.types import SquaredScale -from ..thresholds import ThresholdsAtlas +from . import commons @dataclass @@ -35,19 +34,7 @@ class MatchingRecipe(Recipe): def create(eko: EKO): """Create all associated recipes.""" - _ = eko.theory_card.matching - - masses = runcards.masses( - eko.theory_card, eko.operator_card.configs.evolution_method - ) - - tc = ThresholdsAtlas( - masses=masses, - q2_ref=eko.operator_card.mu20, - nf_ref=eko.theory_card.num_flavs_init, - thresholds_ratios=None, - max_nf=eko.theory_card.num_flavs_max_pdf, - ) + tc = commons.threshold_atlas(eko.theory_card, eko.operator_card) for mu2 in eko.mu2grid: expanded = eko.operator_card.configs.scvar_method is sv.Modes.expanded diff --git a/tests/eko/runner/test_init.py b/tests/eko/runner/test_init.py index 63037c2a7..ff5985834 100644 --- a/tests/eko/runner/test_init.py +++ b/tests/eko/runner/test_init.py @@ -11,10 +11,14 @@ def compute(self): self.path.write_text("output", encoding="utf-8") +def mock_solve(th, op, path): + return MockRunner(th, op, path).compute() + + def test_run(monkeypatch, tmp_path: pathlib.Path): # just test, that it is a shortcut to 'compute' path = tmp_path / "eko.tar" - monkeypatch.setattr(eko.runner.legacy, "Runner", MockRunner) + monkeypatch.setattr(eko, "solve", mock_solve) eko.solve({}, {}, path=path) out = path.read_text(encoding="utf-8") assert out == "output"