Skip to content

Commit

Permalink
Have cli analysis tests explicitly set multithreading env variables t…
Browse files Browse the repository at this point in the history
…o 1.

This commit adds an auto-used fixture for all analysis tests, that sets the environment variables for multithreading `OMP_NUM_THREADS`, `MKL_NUM_THREADS`, and `NUMEXPR_NUM_THREADS` all to 1. This can cause the issue of those tests hanging, as numpy uses all resources available if those env variables are not explicitly set.
  • Loading branch information
jonathan-eq committed Oct 30, 2024
1 parent 97478fa commit f3068f9
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions tests/ert/ui_tests/cli/analysis/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import os
import sys

import pytest


@pytest.fixture(autouse=True)
def reduce_omp_num_threads_count():
if sys.platform != "darwin":
yield
return
multithreading_env_variables = [
["OMP_NUM_THREADS", "1"], # OpenMP
["MKL_NUM_THREADS", "1"], # Intel Math Kernel Library
["NUMEXPR_NUM_THREADS", "1"], # NumExpr library in Python
]
for option in multithreading_env_variables:
env_var_name = option[0]
option[1], os.environ[env_var_name] = os.environ.get(env_var_name), option[1]

yield

for option in multithreading_env_variables:
env_var_name = option[0]
if option[1] is None:
del os.environ[env_var_name]
else:
os.environ[env_var_name] = option[1]

0 comments on commit f3068f9

Please sign in to comment.