diff --git a/hnn_core/gui/gui.py b/hnn_core/gui/gui.py index 8e89cf8df..020962a6a 100644 --- a/hnn_core/gui/gui.py +++ b/hnn_core/gui/gui.py @@ -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' / @@ -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) @@ -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.