Skip to content

Commit

Permalink
feat: changes the default backend based on if mpi4py and psutil are i…
Browse files Browse the repository at this point in the history
…nstalled
  • Loading branch information
gtdang committed Aug 28, 2024
1 parent 0954871 commit b5a07da
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions hnn_core/gui/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
get_L5Pyr_params_default)
from hnn_core.hnn_io import dict_to_network, write_network_configuration
from hnn_core.cells_default import _exp_g_at_dist
from hnn_core.parallel_backends import _has_mpi4py, _has_psutil

hnn_core_root = Path(hnn_core.__file__).parent
default_network_configuration = (hnn_core_root / 'param' /
Expand Down Expand Up @@ -340,10 +341,11 @@ def __init__(self, theme_color="#802989",
placeholder='ID of your simulation',
description='Name:',
disabled=False)
self.widget_backend_selection = Dropdown(options=[('Joblib', 'Joblib'),
('MPI', 'MPI')],
value='Joblib',
description='Backend:')
self.widget_backend_selection = (
Dropdown(options=[('Joblib', 'Joblib'),
('MPI', 'MPI')],
value=self._check_backend(),
description='Backend:'))
self.widget_mpi_cmd = Text(value='mpiexec',
placeholder='Fill if applies',
description='MPI cmd:', disabled=False)
Expand Down Expand Up @@ -447,6 +449,14 @@ def _available_cores():
else:
return len(psutil.Process().cpu_affinity())

@staticmethod
def _check_backend():
"""Checks for MPI and returns the default backend name"""
default_backend = 'Joblib'
if _has_mpi4py() and _has_psutil():
default_backend = 'MPI'
return default_backend

def get_cell_parameters_dict(self):
"""Returns the number of elements in the
cell_parameters_dict dictionary.
Expand Down

0 comments on commit b5a07da

Please sign in to comment.