Skip to content

Commit

Permalink
Include native kernel (python3 for Python) to kernel lists
Browse files Browse the repository at this point in the history
Re Issue #2824
  • Loading branch information
ptsavol committed Jun 13, 2024
1 parent 5d4cd24 commit 7fe69e0
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 12 deletions.
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
-e git+https://github.com/spine-tools/Spine-Database-API.git#egg=spinedb_api
-e git+https://github.com/spine-tools/spine-engine.git#egg=spine_engine
-e git+https://github.com/spine-tools/spine-items.git#egg=spine_items
-e git+https://github.com/spine-tools/spine-engine.git@toolbox_issue_2824#egg=spine_engine
-e git+https://github.com/spine-tools/spine-items.git@toolbox_issue_2824#egg=spine_items
-e .
11 changes: 5 additions & 6 deletions spinetoolbox/kernel_fetcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@
import json
from PySide6.QtCore import Signal, Slot, QThread
from PySide6.QtGui import QIcon
from jupyter_client.kernelspec import find_kernel_specs
from spine_engine.utils.helpers import resolve_conda_executable
from spine_engine.utils.helpers import resolve_conda_executable, custom_find_kernel_specs
from spine_engine.execution_managers.conda_kernel_spec_manager import CondaKernelSpecManager


Expand Down Expand Up @@ -50,9 +49,9 @@ def stop_thread(self):

def get_all_regular_kernels(self):
"""Finds all kernel specs as quickly as possible."""
for kernel_name, resource_dir in find_kernel_specs().items(): # Find regular Kernels
if not os.path.exists(resource_dir):
continue
for kernel_name, resource_dir in custom_find_kernel_specs().items(): # Find regular Kernels
# if not os.path.exists(resource_dir):
# continue
icon = self.get_icon(resource_dir)
self.kernel_found.emit(kernel_name, resource_dir, False, icon, {})
if not self.keep_going:
Expand All @@ -79,7 +78,7 @@ def run(self):
self.get_all_conda_kernels()
return
# To find just a subset of kernels, we need to open kernel.json file and check the language
for kernel_name, resource_dir in find_kernel_specs().items():
for kernel_name, resource_dir in custom_find_kernel_specs().items():
d = self.get_kernel_deats(resource_dir)
icon = self.get_icon(resource_dir)
if d["language"].lower().strip() == "python": # Regular Python kernel found
Expand Down
7 changes: 3 additions & 4 deletions spinetoolbox/widgets/kernel_editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@
from PySide6.QtWidgets import QDialog, QMessageBox, QDialogButtonBox, QWidget
from PySide6.QtCore import Slot, Qt, QTimer
from PySide6.QtGui import QGuiApplication, QIcon
from jupyter_client.kernelspec import find_kernel_specs
from spine_engine.utils.helpers import resolve_current_python_interpreter, resolve_default_julia_executable
from spine_engine.utils.helpers import resolve_current_python_interpreter, resolve_default_julia_executable, custom_find_kernel_specs
from spinetoolbox.execution_managers import QProcessExecutionManager
from spinetoolbox.helpers import (
busy_effect,
Expand Down Expand Up @@ -56,7 +55,7 @@ def __init__(self, parent, python_or_julia):
self._rebuild_ijulia_process = None
self._install_julia_kernel_process = None
self._ready_to_install_kernel = False
self.kernel_names_before = find_kernel_specs().keys()
self.kernel_names_before = custom_find_kernel_specs().keys()
self._new_kernel_name = ""
self.setAttribute(Qt.WA_DeleteOnClose)
self._cursors = {w: w.cursor() for w in self.findChildren(QWidget)}
Expand Down Expand Up @@ -93,7 +92,7 @@ def new_kernel_name(self):

def _solve_new_kernel_name(self):
"""Finds out the new kernel name after a new kernel has been created."""
kernel_names_after = find_kernel_specs().keys()
kernel_names_after = custom_find_kernel_specs().keys()
try:
self._new_kernel_name = list(set(kernel_names_after) - set(self.kernel_names_before))[0]
except IndexError:
Expand Down

0 comments on commit 7fe69e0

Please sign in to comment.