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 b6dacdd
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions tests/ert/ui_tests/cli/analysis/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import os

import pytest


@pytest.fixture(autouse=True)
def reduce_omp_num_threads_count():
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 b6dacdd

Please sign in to comment.