Skip to content

Commit

Permalink
--timeout option (default: 2 hours)
Browse files Browse the repository at this point in the history
  • Loading branch information
BerengerBerthoul committed Sep 5, 2024
1 parent 8f92473 commit 67a77de
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions pytest_parallel/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
import pytest
from pathlib import Path
import argparse
#from mpi4py import MPI
#from logger import consoleLogger
import resource

# --------------------------------------------------------------------------
def pytest_addoption(parser):
Expand All @@ -22,6 +21,8 @@ def pytest_addoption(parser):

parser.addoption('--n-workers', dest='n_workers', type=int, help='Max number of processes to run in parallel')

parser.addoption('--timeout', dest='timeout', type=int, default=7200, help='Timeout')

parser.addoption('--slurm-options', dest='slurm_options', type=str, help='list of SLURM options e.g. "--time=00:30:00 --qos=my_queue --n_tasks=4"')
parser.addoption('--slurm-additional-cmds', dest='slurm_additional_cmds', type=str, help='list of commands to pass to SLURM job e.g. "source my_env.sh"')
parser.addoption('--slurm-file', dest='slurm_file', type=str, help='Path to file containing header of SLURM job') # TODO DEL
Expand Down Expand Up @@ -69,6 +70,10 @@ def _invoke_params(args):
# --------------------------------------------------------------------------
@pytest.hookimpl(trylast=True)
def pytest_configure(config):
# Set timeout
timeout = config.getoption('timeout')
resource.setrlimit(resource.RLIMIT_CPU, (timeout, timeout))

# Get options and check dependent/incompatible options
scheduler = config.getoption('scheduler')
n_workers = config.getoption('n_workers')
Expand Down

0 comments on commit 67a77de

Please sign in to comment.