From 0c6f4dfa83cd50d3b83e7f080641501c232be490 Mon Sep 17 00:00:00 2001 From: George Dang <53052793+gtdang@users.noreply.github.com> Date: Fri, 23 Aug 2024 17:05:56 -0400 Subject: [PATCH] feat: added number of available cores as an attribute and applied the attribute where relevant. --- hnn_core/gui/gui.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/hnn_core/gui/gui.py b/hnn_core/gui/gui.py index 8f86304a2..729624363 100644 --- a/hnn_core/gui/gui.py +++ b/hnn_core/gui/gui.py @@ -7,8 +7,9 @@ import io import logging import mimetypes -import multiprocessing import numpy as np +import platform +import psutil import sys import json import urllib.parse @@ -320,6 +321,9 @@ def __init__(self, theme_color="#802989", # load default parameters self.params = self.load_parameters(network_configuration) + # Number of available cores + self.n_cores = self._available_cores() + # In-memory storage of all simulation and visualization related data self.simulation_data = defaultdict(lambda: dict(net=None, dpls=list())) @@ -344,7 +348,7 @@ def __init__(self, theme_color="#802989", placeholder='Fill if applies', description='MPI cmd:', disabled=False) self.widget_n_jobs = BoundedIntText(value=1, min=1, - max=multiprocessing.cpu_count(), + max=self.n_cores, description='Cores:', disabled=False) self.load_data_button = FileUpload( @@ -585,8 +589,9 @@ def _run_button_clicked(b): self.widget_simulation_name, self._log_out, self.drive_widgets, self.data, self.widget_dt, self.widget_tstop, self.widget_ntrials, self.widget_backend_selection, - self.widget_mpi_cmd, self.widget_n_jobs, self.params, - self._simulation_status_bar, self._simulation_status_contents, + self.widget_mpi_cmd, self.n_cores, self.widget_n_jobs, + self.params, self._simulation_status_bar, + self._simulation_status_contents, self.connectivity_widgets, self.viz_manager, self.simulation_list_widget, self.cell_pameters_widgets)