From 4ed67794d0347c8a12882088db7817b266a33018 Mon Sep 17 00:00:00 2001 From: Pekka T Savolainen Date: Mon, 2 Dec 2024 16:41:38 +0200 Subject: [PATCH 1/2] Edit utility function Re spine-tools/Spine-Toolbox#3018 --- spine_engine/utils/helpers.py | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/spine_engine/utils/helpers.py b/spine_engine/utils/helpers.py index 1d840de..5db0b8f 100644 --- a/spine_engine/utils/helpers.py +++ b/spine_engine/utils/helpers.py @@ -247,18 +247,19 @@ def inverted(input_): return output -def get_julia_env(settings): +def get_julia_env(use_jupyter_console, julia_kernel, julia_path, julia_project_path): """ Args: - settings (QSettings, AppSettings) + use_jupyter_console (bool): True if Jupyter console is in use + julia_kernel (str): Julia kernel name + julia_path (str): Path to Julia executable + julia_project_path (str): Path to Julia project/environment folder Returns: Union[tuple, None]: (julia_exe, julia_project), or None if none found """ - use_jupyter_console = settings.value("appSettings/useJuliaKernel", defaultValue="0") == "2" if use_jupyter_console: - kernel_name = settings.value("appSettings/juliaKernel", defaultValue="") - resource_dir = custom_find_kernel_specs().get(kernel_name) + resource_dir = custom_find_kernel_specs().get(julia_kernel) if resource_dir is None: return None filepath = os.path.join(resource_dir, "kernel.json") @@ -271,13 +272,11 @@ def get_julia_env(settings): project_arg = next((arg for arg in kernel_spec["argv"] if arg.startswith("--project=")), None) project = "" if project_arg is None else project_arg.split("--project=")[1] return julia, project - julia = settings.value("appSettings/juliaPath", defaultValue="") - if julia == "": + if julia_path == "": julia = resolve_executable_from_path(JULIA_EXECUTABLE) if julia == "": return None - project = settings.value("appSettings/juliaProjectPath", defaultValue="") - return julia, project + return julia_path, julia_project_path def required_items_for_execution(items, connections, executable_item_classes, execution_permits): From 4a58fcd8609948c496a7a2f1dc81815440617156 Mon Sep 17 00:00:00 2001 From: Pekka T Savolainen Date: Mon, 2 Dec 2024 17:06:29 +0200 Subject: [PATCH 2/2] Fix bug --- spine_engine/utils/helpers.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spine_engine/utils/helpers.py b/spine_engine/utils/helpers.py index 5db0b8f..2bee964 100644 --- a/spine_engine/utils/helpers.py +++ b/spine_engine/utils/helpers.py @@ -273,8 +273,8 @@ def get_julia_env(use_jupyter_console, julia_kernel, julia_path, julia_project_p project = "" if project_arg is None else project_arg.split("--project=")[1] return julia, project if julia_path == "": - julia = resolve_executable_from_path(JULIA_EXECUTABLE) - if julia == "": + julia_path = resolve_executable_from_path(JULIA_EXECUTABLE) + if julia_path == "": return None return julia_path, julia_project_path