aragilar / pytest-mpi

Pytest plugin for working with MPI
https://pytest-mpi.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
19 stars 7 forks source link

every pytest process is writing to stdout #35

Open stenczelt opened 3 years ago

stenczelt commented 3 years ago

How to avoid pytest from writing on all MPI processes? If I run

$mpirun -n 2 python -m pytest --with-mpi    

============================= test session starts ==============================
platform darwin -- Python 3.8.5, pytest-6.1.2, py-1.10.0, pluggy-0.13.1
============================= test session starts ==============================
platform darwin -- Python 3.8.5, pytest-6.1.2, py-1.10.0, pluggy-0.13.1
rootdir: /Users/tks32/work/wfl_repo, configfile: pytest.ini, testpaths: tests/
plugins: cov-2.10.1, mpi-0.5
rootdir: /Users/tks32/work/wfl_repo, configfile: pytest.ini, testpaths: tests/
plugins: cov-2.10.1, mpi-0.5
collected 42 items / 41 deselected / 1 selected                                
collected 42 items / 41 deselected / 1 selected 

[...]

So I am getting the output from all the processes. Is there a different option, or would it be possible to make pytest only print on rank 0?

aragilar commented 3 years ago

No, there's no configuration to control pytest's output. I suspect the smarter thing to do would be look at what options your MPI system has to control stdout/stderr, as trying to sensibly have pytest take arbitrarily different paths is likely harder than handling at the MPI coordinator level.

If you do figure out how to control the output, then a PR adding documentation around it would be welcome.

PhilipVinc commented 3 months ago

@aragilar could you kindly tag a new release including this commit?