Skip to content

Commit

Permalink
Add RADCAD_BACKEND env variable to override during Windows tests
Browse files Browse the repository at this point in the history
  • Loading branch information
BenSchZA committed Aug 31, 2024
1 parent 24dd7ef commit 670c1d3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 5 additions & 0 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@
# thread = threading.Thread(func=main)
# thread.start()

# Configure radCAD for tests
if sys.platform.startswith('win'):
# Use the multiprocessing backend on Windows to avoid recursion depth errors
os.environ['RADCAD_BACKEND'] = 'multiprocessing'


def select_lockfile(session):
'''Select the PDM package manager lockfile based on the Python version'''
Expand Down
5 changes: 3 additions & 2 deletions radcad/engine.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import os
import copy
import multiprocessing
from typing import Iterator
Expand All @@ -18,7 +19,7 @@ def __init__(self, **kwargs):
Handles configuration and execution of experiments and simulations.
Args:
**backend (Backend): Which execution backend to use (e.g. Pathos, Multiprocessing, etc.). Defaults to `Backend.DEFAULT` / `Backend.PATHOS`.
**backend (Backend): Which execution backend to use (e.g. Pathos, Multiprocessing, etc.). Defaults to `Backend.DEFAULT` / `Backend.PATHOS`. Can be set via the `RADCAD_BACKEND` environment variable which takes precedence.
**processes (int, optional): Number of system CPU processes to spawn. Defaults to `multiprocessing.cpu_count() - 1 or 1`
**raise_exceptions (bool): Whether to raise exceptions, or catch them and return exceptions along with partial results. Default to `True`.
**deepcopy (bool): Whether to enable deepcopy of State Variables to avoid unintended state mutation. Defaults to `True`.
Expand All @@ -29,7 +30,7 @@ def __init__(self, **kwargs):
"""
self.executable = None
self.processes = kwargs.pop("processes", cpu_count)
self.backend = kwargs.pop("backend", Backend.DEFAULT)
self.backend = kwargs.pop("backend", os.getenv('RADCAD_BACKEND', Backend.DEFAULT))

_simulation_execution = kwargs.pop("simulation_execution", None)
if _simulation_execution:
Expand Down

0 comments on commit 670c1d3

Please sign in to comment.