Skip to content

Commit

Permalink
added pytest flag to print captured output
Browse files Browse the repository at this point in the history
  • Loading branch information
Oskar Taubert committed Oct 23, 2023
1 parent cf85d66 commit c816685
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/python-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ jobs:
ruff --output-format=github --target-version=py39 .
- name: Test with pytest
run: |
mpirun -n 1 pytest
pytest -s
12 changes: 10 additions & 2 deletions tests/test_propulator_sphere.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand All @@ -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"))

Expand Down

0 comments on commit c816685

Please sign in to comment.