diff --git a/spinetoolbox/ui_main.py b/spinetoolbox/ui_main.py index d7775fb9a..e8d56628f 100644 --- a/spinetoolbox/ui_main.py +++ b/spinetoolbox/ui_main.py @@ -50,7 +50,7 @@ ) from spine_engine.spine_engine import _set_resource_limits from spine_engine.load_project_items import load_item_specification_factories -from spine_engine.utils.helpers import resolve_python_interpreter, resolve_julia_executable +from spine_engine.utils.helpers import resolve_python_interpreter, resolve_julia_executable, resolve_julia_project from spinetoolbox.server.engine_client import ClientSecurityModel, EngineClient, RemoteEngineInitFailed from .config import DEFAULT_WORK_DIR, MAINWINDOW_SS, ONLINE_DOCUMENTATION_URL, SPINE_TOOLBOX_REPO_URL from .helpers import ( @@ -2347,20 +2347,22 @@ def start_detached_python_basic_console(self): def start_detached_julia_basic_console(self): """Starts basic console with the default Julia executable.""" julia = resolve_julia_executable(self.qsettings()) + project = resolve_julia_project(self.qsettings()) if not julia: self.msg_warning.emit("No Julia installation found. Add path to a Julia executable in Spine " "Toolbox Settings [File->Settings->Tools]") return _set_resource_limits(self.qsettings(), threading.Lock()) - self.start_detached_basic_console("julia", julia) + self.start_detached_basic_console("julia", julia, project) - def start_detached_basic_console(self, language, executable): + def start_detached_basic_console(self, language, executable, julia_project=None): """Launches a new detached basic console with the given executable or activates an existing Console if the kernel is already running. Args: language (str): Console kernel language executable (str): Abs. path to kernel file + julia_project (str): Path to Julia environment """ for pcw in self._persistent_consoles.values(): if pcw.detached_console_id is not None: @@ -2373,7 +2375,7 @@ def start_detached_basic_console(self, language, executable): icon = basic_console_icon(language) console_window = ConsoleWindow(icon, language) c = PersistentConsoleWidget(self, None, language, None, console_window) - key = c.request_start_kernel(executable) + key = c.request_start_kernel(executable, julia_project) if not key: self.msg_error.emit(f"Starting Basic Console for {executable} failed") return diff --git a/spinetoolbox/widgets/persistent_console_widget.py b/spinetoolbox/widgets/persistent_console_widget.py index 884f2196c..104cf33e7 100644 --- a/spinetoolbox/widgets/persistent_console_widget.py +++ b/spinetoolbox/widgets/persistent_console_widget.py @@ -788,24 +788,28 @@ def contextMenuEvent(self, ev): self._extend_menu(menu) menu.exec(ev.globalPos()) - def request_start_kernel(self, exec_path): + def request_start_kernel(self, exec_path, julia_project=None): """Requests Spine Engine to launch a persistent kernel manager for the given Python. Args: exec_path (str): Abs. path to kernel file (e.g. ../../julia.exe or ../../python.exe) + julia_project (str): Path to Julia environment Returns: str or None: Kernel manager key if kernel manager was launched successfully, None otherwise """ + args = [exec_path] if self._language == "python": manager_class = PythonPersistentExecutionManager elif self._language == "julia": manager_class = JuliaPersistentExecutionManager + if julia_project: + args += ["--project=" + julia_project] else: self._logger.msg_error.emit(f"Unsupported console language '{self._language}'") return None self._execution_manager = manager_class( - self._logger, [exec_path], [], f"Detached Basic {self._language.capitalize()} Console", False, None + self._logger, args, [], f"Detached Basic {self._language.capitalize()} Console", False, None ) try: msg_type, msg = self._q.get(timeout=20) # Blocks until msg (tuple(str, dict) is received, or timeout.