armi icon indicating copy to clipboard operation
armi copied to clipboard

Pytest and MPI import leading to large numbers of error messages

Open alexhjames opened this issue 1 year ago • 1 comments

ARMI has an import statement for mpi4py inside of a try statement in the context.py file. See code snippet below. If pytest is run with something that imports ARMI (directly or indirectly) and the user doesn't have ms-mpi installed then pytest outputs a huge wall of windows exception error text. See example below. The try statement functions correctly in that pytest test collection continues fine despite the dump of errors. An ipython call to the same import statement results in the ImportError that the try statement is handling and doesn't result in the same wall of error messages. Is it possible to suppress the pytest wall of errors by either adding something to the pytest call or by adding something to this line in ARMI? Or is the solution to just shut up and install ms-mpi?

Lines of code affected: https://github.com/terrapower/armi/blob/827d223cd6fc085c039390a2c3a0391f4e611fe5/armi/context.py#L111-L129

Example wall of text: image image

Example ipython import: image

alexhjames avatar Apr 03 '24 20:04 alexhjames

Okay, after talking to Alex, the situation is that this try/except has existed for over a decade:

https://github.com/terrapower/armi/blob/827d223cd6fc085c039390a2c3a0391f4e611fe5/armi/context.py#L111-L129

but at some point, recently, on Windows, it has started spraying the STDERR messages hundreds of times into STDOUT.

The code doesn't halt, so it's not technically a "bug". But that's certainly hideous and unwanted.

For now, Alex, I would say "install MPI" is a solution. But, long term, we will need to find a Python way to catch that STDERR message if it exists, and suppress it.

john-science avatar Apr 03 '24 21:04 john-science