Skip to content

Commit

Permalink
Debugging test hanging forever.
Browse files Browse the repository at this point in the history
  • Loading branch information
vitenti committed Apr 20, 2024
1 parent e6d7d18 commit 4b4a90e
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 7 deletions.
4 changes: 0 additions & 4 deletions numcosmo_py/experiments/planck18.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,7 @@ def generate_planck18_tt(
massive_nu: bool = False,
) -> tuple[Ncm.ObjDictStr, Ncm.ObjArray]:
"""Generate Planck 2018 TT baseline experiment dictionary."""

# Likelihood

cbe_boltzmann = Nc.HIPertBoltzmannCBE.new()

b18_lowl_EE = Nc.DataPlanckLKL.full_new_id(
Expand Down Expand Up @@ -219,9 +217,7 @@ def generate_planck18_ttteee(
massive_nu: bool = False,
) -> tuple[Ncm.ObjDictStr, Ncm.ObjArray]:
"""Generate Planck 2018 TT baseline experiment dictionary."""

# Likelihood

cbe_boltzmann = Nc.HIPertBoltzmannCBE.new()

b18_lowl_EE = Nc.DataPlanckLKL.full_new_id(
Expand Down
2 changes: 1 addition & 1 deletion tests/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ if python_typer.found()
{
'name': 'py_numcosmo_app',
'source': 'test_py_numcosmo_app.py',
'timeout': 0,
'timeout': 60 * 15,
},
]
endif
Expand Down
43 changes: 41 additions & 2 deletions tests/test_py_numcosmo_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@

from typing import Tuple
from pathlib import Path
import functools
import sys

import pytest
from typer.testing import CliRunner

Expand All @@ -42,6 +45,37 @@

runner = CliRunner()


@pytest.fixture(name="cli")
def fixture_cli():
"""Yield a click.testing.CliRunner to invoke the CLI."""
class_ = CliRunner

def invoke_wrapper(f):
"""Augment CliRunner.invoke to emit its output to stdout.
This enables pytest to show the output in its logs on test
failures.
"""

@functools.wraps(f)
def wrapper(*args, **kwargs):
echo = kwargs.pop("echo", False)
result = f(*args, **kwargs)

if echo is True:
sys.stdout.write(result.output)
return result

return wrapper

class_.invoke = invoke_wrapper(class_.invoke)
cli_runner = class_()

yield cli_runner


Ncm.cfg_init()


Expand Down Expand Up @@ -527,12 +561,12 @@ def test_run_mcmc_apes_init_catalog(simple_experiment):


def test_run_mcmc_apes_method_kernel(
simple_experiment, interpolation_method, interpolation_kernel
simple_experiment, interpolation_method, interpolation_kernel, cli
):
"""Run a MCMC analysis using APES."""
filename, _ = simple_experiment
output = filename.with_suffix(".out.yaml")
result = runner.invoke(
result = cli.invoke(
app,
[
"run",
Expand All @@ -545,9 +579,14 @@ def test_run_mcmc_apes_method_kernel(
interpolation_method,
"--interpolation-kernel",
interpolation_kernel,
"--run-messages",
"full",
],
echo=True,
catch_exceptions=False,
)
if result.exit_code != 0:
print(result.output)
raise result.exception


Expand Down

0 comments on commit 4b4a90e

Please sign in to comment.