From c81668507b79cb8e02d1721ebf5028a9f1921b34 Mon Sep 17 00:00:00 2001 From: Oskar Taubert Date: Mon, 23 Oct 2023 15:08:08 +0200 Subject: [PATCH] added pytest flag to print captured output --- .github/workflows/python-test.yml | 2 +- tests/test_propulator_sphere.py | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/.github/workflows/python-test.yml b/.github/workflows/python-test.yml index 9116c005..83a9ce13 100644 --- a/.github/workflows/python-test.yml +++ b/.github/workflows/python-test.yml @@ -31,4 +31,4 @@ jobs: ruff --output-format=github --target-version=py39 . - name: Test with pytest run: | - mpirun -n 1 pytest + pytest -s diff --git a/tests/test_propulator_sphere.py b/tests/test_propulator_sphere.py index 30294ac1..65d249dc 100644 --- a/tests/test_propulator_sphere.py +++ b/tests/test_propulator_sphere.py @@ -2,11 +2,12 @@ import tempfile from typing import Dict from operator import attrgetter +import logging import numpy as np from propulate import Propulator -from propulate.utils import get_default_propagator +from propulate.utils import get_default_propagator, set_logger_config def sphere(params: Dict[str, float]) -> float: @@ -38,6 +39,13 @@ def test_Propulator(): "b": (-5.12, 5.12), } with tempfile.TemporaryDirectory() as checkpoint_path: + set_logger_config( + level=logging.INFO, + log_file=checkpoint_path + "/propulate.log", + log_to_stdout=True, + log_rank=False, + colors=True, + ) # Set up evolutionary operator. propagator = get_default_propagator( # Get default evolutionary operator. pop_size=4, # Breeding pool size @@ -58,7 +66,7 @@ def test_Propulator(): ) # Run optimization and print summary of results. - propulator.propulate() + propulator.propulate(debug=2) propulator.summarize() best = min(propulator.population, key=attrgetter("loss"))