Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PR: Generalize Run plugin to support generic inputs and executors #17467

Merged
merged 102 commits into from
Feb 15, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
102 commits
Select commit Hold shift + click to select a range
d89e4b4
Start Run plugin generalization
andfoy Mar 10, 2022
c103a55
Finish typing stubs and Run API interfaces
andfoy Mar 10, 2022
cb61372
Add register and deregister methods for InputProviders, Executors and…
andfoy Mar 16, 2022
a1b920c
Merge remote-tracking branch 'upstream/master' into split_run_editor
andfoy Mar 17, 2022
dbb2bf6
Fix docstrings and some interface naming
andfoy Mar 27, 2022
738e0fa
Move context and extension to run configuration metadata
andfoy Mar 29, 2022
e26c41f
Start working on the new Run dialog
andfoy Mar 30, 2022
5a00314
Define abstract models for both model configurations as well as execu…
andfoy Apr 20, 2022
6e57446
Merge branch 'master' into split_run_editor
andfoy Apr 20, 2022
e4a986e
Register files from the editor
andfoy Apr 21, 2022
56dda5f
Fix issues with the run configuration combobox
andfoy May 9, 2022
2cd4f3f
Merge branch 'master' into split_run_editor
andfoy May 9, 2022
958fbf6
Deregister run configurations from the Editor
andfoy May 9, 2022
17800e9
Merge branch 'split_run_editor' of https://github.com/andfoy/spyder i…
andfoy May 9, 2022
8e89657
Make sure combobox follows the focused run configuration
andfoy May 10, 2022
ceffc24
Ensure executors combo box is updated correctly
andfoy May 16, 2022
ddd57c7
Load stored parameters from configuration
andfoy May 18, 2022
53a909f
Add combobox and checkbox to create new run configurations
andfoy May 23, 2022
1f3b28f
Decouple run parameters from files
andfoy May 24, 2022
7165efa
Per-executor configuration parameters are now being saved and loaded
andfoy May 26, 2022
6b4a065
Run is now working with files
andfoy May 27, 2022
0c1e651
Move external console options to a separate executor
andfoy May 30, 2022
7274b74
Add support for bash files
andfoy May 31, 2022
42996dc
Save last used parameters per file
andfoy Jun 1, 2022
4f1a388
Fix parameter initialization in dialog
andfoy Jun 1, 2022
48ac435
Add selection action
andfoy Jun 3, 2022
4e4077d
Add support for cells and script selection
andfoy Jun 4, 2022
a1ed3c7
Add support for cells and advance
andfoy Jun 7, 2022
53b8ca2
Merge branch 'master' into split_run_editor
andfoy Jun 7, 2022
cad2038
Try to override shortcuts
andfoy Jun 7, 2022
79a485b
Add run to/from line actions
andfoy Jun 7, 2022
978a59e
Add open configuration dialog action
andfoy Jun 8, 2022
35ab62f
Add re-run last file action
andfoy Jun 8, 2022
1c0d828
Add re-run cell option
andfoy Jun 9, 2022
23c7520
Migrate Profiler to use the new Run API
andfoy Jun 10, 2022
bfec106
Get around Python scope limitations
andfoy Jun 10, 2022
28a6e92
Move Pylint to use the new Run infraestructure
andfoy Jun 13, 2022
bb91bb0
Add teardown routines for Run methods and dependencies
andfoy Jun 13, 2022
b9f395b
Start re-working the Run configuration page
andfoy Jun 14, 2022
bba8245
Add configuration page edition dialog
andfoy Jun 15, 2022
22e2932
Configuration page is now working as expected
andfoy Jun 17, 2022
9069f26
Remove unwanted import
andfoy Jun 20, 2022
4761fca
Ensure powershell and cmd work as expected
andfoy Jun 20, 2022
c8401f3
Start fixing fast tests
andfoy Jun 20, 2022
748342d
Merge remote-tracking branch 'upstream/master' into split_run_editor
andfoy Jun 20, 2022
99da57b
Rename action to make it visible in macOS
steff456 Jun 20, 2022
3b5716b
Merge branch 'master' into split_run_editor
andfoy Jun 21, 2022
717d9c2
Fix mainwindow tests
andfoy Jun 21, 2022
8550e23
Merge with master
andfoy Jun 21, 2022
cbf6d4f
Add temporary run api to debug files
andfoy Jun 21, 2022
f3f413a
Fix cell copy options
andfoy Jun 21, 2022
edc8532
Fix a few more tests
andfoy Jun 21, 2022
01ac4df
Fix remaining tests
andfoy Jun 22, 2022
836626a
Merge branch 'master' into split_run_editor
andfoy Jun 23, 2022
b1e958f
Merge remote-tracking branch 'upstream/master' into split_run_editor
andfoy Jun 23, 2022
4a1339d
Fix test_connection_to_external_kernel
andfoy Jun 24, 2022
9b5dd10
Add external console test
andfoy Jun 27, 2022
17612ce
Fix shell test in Windows
andfoy Jun 27, 2022
4f5c406
Apply review comments
steff456 Jun 28, 2022
8a05705
Inherit RunExecutor from QObject in order to ensure MRO resolution
andfoy Jun 28, 2022
8fd758e
Add API versioning how-to
andfoy Jun 28, 2022
90951bc
Fix pep8 issues
steff456 Jun 29, 2022
f6a13f7
Merge branch 'master' into split_run_editor
andfoy Jun 29, 2022
54bdaff
Add comments to fix test on windows CI
steff456 Jun 30, 2022
41a08d9
Merge branch 'split_run_editor' of github.com:andfoy/spyder into spli…
steff456 Jun 30, 2022
a65c8a8
Fix failing test in frames
steff456 Jun 30, 2022
25ab1f3
Refactor run dialog to use async Qt API
andfoy Jul 1, 2022
0986382
Extend test to run an input in transient mode
andfoy Jul 2, 2022
a72dde9
Extend test to consider subordinate contexts
andfoy Jul 5, 2022
77b5422
Use Run button instead of shortcut on test_varexp_rename
andfoy Jul 5, 2022
5c68b36
Merge branch 'master' into split_run_editor
andfoy Jul 5, 2022
85eb1a4
Test teardown deregistration for Run
andfoy Jul 5, 2022
e059967
Try to prevent duplicate shortcuts
andfoy Jul 7, 2022
d223b4c
Group some run tests
andfoy Jul 11, 2022
cd7d70c
Skip test_runcell_edge_cases
andfoy Jul 11, 2022
4df2264
Skip test_runcell_pdb on Windows
andfoy Jul 11, 2022
c5b14e9
Fix typo
steff456 Jul 12, 2022
89e2d4d
Skip test_runcell_cache on Windows
andfoy Jul 12, 2022
fee8db9
Merge branch 'split_run_editor' of https://github.com/andfoy/spyder i…
andfoy Jul 12, 2022
10542d3
Skip test_runcell_after_restart on Windows
andfoy Jul 12, 2022
ffbf1e3
Move test_varexp_remove to call the Run button directly
andfoy Jul 12, 2022
d84f28a
Increase timeout on test_print_multiprocessing
andfoy Jul 13, 2022
48965d3
Fix issues with whitespaces when running shell files
andfoy Jul 13, 2022
45d5053
Retrieve run configurations for super contexts via get_run_configurat…
andfoy Jul 13, 2022
b64f181
Force editor to set focus appropiately in test_print_multiprocessing
andfoy Jul 13, 2022
3204b63
Add wait for test_print_faulthandler
andfoy Jul 13, 2022
7020323
Fix Run configuration page table issues
andfoy Jul 13, 2022
500887c
Display only the executors that have a configuration dialog
andfoy Jul 13, 2022
ebf2b63
Add wait time to refresh run file in test_debug_unsaved_function
andfoy Jul 14, 2022
646f321
Merge after releasing 5.3.3
ccordoba12 Feb 3, 2023
0e80241
Merge after releasing 5.4.0
ccordoba12 Feb 4, 2023
8ede54f
Merge after releasing 5.4.1
ccordoba12 Feb 5, 2023
1c156b7
Fix line endings of batch scripts
ccordoba12 Feb 5, 2023
0e07d4a
Merge branch 'master' into split_run_editor
ccordoba12 Feb 5, 2023
58525e3
Testing: Refactor code used to generate run parameters
ccordoba12 Feb 5, 2023
4d42430
Main Window: Remove attributes related to the Run menu and toolbar
ccordoba12 Feb 5, 2023
fd12df1
Testing: Fix most failing tests and skip others
ccordoba12 Feb 5, 2023
8215c66
Debugger: Fix debugging selections
ccordoba12 Feb 7, 2023
5304a54
Ignore revision that updated the new run architecture with master
ccordoba12 Feb 9, 2023
b4782dc
Merge branch 'master' into split_run_editor
ccordoba12 Feb 11, 2023
4068d25
Add some missing docstrings, fix style issues and other minor things
ccordoba12 Feb 11, 2023
5cf60eb
Testing: Skip test_shell_execution on Mac because it's failing
ccordoba12 Feb 14, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Configuration page is now working as expected
Co-authored-by: Stephannie Jimenez Gacha <steff456@hotmail.com>
  • Loading branch information
andfoy and steff456 committed Jun 17, 2022
commit 22e2932d539eaf0d27dfc255e5fb390e131cc907
137 changes: 119 additions & 18 deletions spyder/plugins/run/confpage.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,17 @@
"""Run configuration page."""

# Standard library imports
from typing import Dict, List, Set
from copy import deepcopy
from typing import Dict, List, Set, Tuple
from uuid import uuid4

# Third party imports
from qtpy.QtCore import Qt
from qtpy.QtWidgets import (QButtonGroup, QGroupBox, QHBoxLayout, QLabel,
steff456 marked this conversation as resolved.
Show resolved Hide resolved
QVBoxLayout, QComboBox, QTableView,
QAbstractItemView, QPushButton, QGridLayout,
QHeaderView)
from spyder.plugins.run.api import SupportedExecutionRunConfiguration
from spyder.plugins.run.api import ExtendedRunExecutionParameters, SupportedExecutionRunConfiguration

# Local imports
from spyder.plugins.run.container import RunContainer
Expand Down Expand Up @@ -58,7 +60,7 @@ def __init__(self, parent, model):
def focusOutEvent(self, e):
"""Qt Override."""
# self.source_model.update_active_row()
self._parent.delete_configuration_btn.setEnabled(False)
# self._parent.delete_configuration_btn.setEnabled(False)
super().focusOutEvent(e)
steff456 marked this conversation as resolved.
Show resolved Hide resolved

def focusInEvent(self, e):
Expand All @@ -71,6 +73,7 @@ def selection(self, index):
self.update()
self.isActiveWindow()
self._parent.delete_configuration_btn.setEnabled(True)
self._parent.clone_configuration_btn.setEnabled(True)

def adjust_cells(self):
"""Adjust column size based on contents."""
Expand All @@ -89,7 +92,7 @@ def reset_plain(self):
# self.sortByColumn(self.source_model.TRIGGER, Qt.AscendingOrder)
steff456 marked this conversation as resolved.
Show resolved Hide resolved
self.selectionModel().selectionChanged.connect(self.selection)

def show_editor(self, new=False):
def show_editor(self, new=False, clone=False):
extension, context, params = None, None, None
extensions, contexts, executor_params = (
self._parent.get_executor_configurations())
Expand All @@ -104,14 +107,32 @@ def show_editor(self, new=False):
extension, context)

dialog.setup()
dialog.exec_()

if not clone:
dialog.exec_()
else:
dialog.ok_btn_clicked()
dialog.accept()

status = dialog.status
if status == RunDialogStatus.Close:
return

extension, context, new_executor_params = dialog.get_configuration()

if not new and clone:
new_executor_params["uuid"] = str(uuid4())
new_executor_params["name"] = _('%s (copy)') % params['name']

changes = []
if params and not clone:
changes.append(('deleted', params))

changes.append(('new', new_executor_params))
self.model().apply_changes(changes, extension, context)

def clone_configuration(self):
self.show_editor(clone=True)

def keyPressEvent(self, event):
"""Qt Override."""
Expand All @@ -136,6 +157,16 @@ def setup_page(self):
self.executor_model = RunExecutorNamesListModel(
self, self.plugin_container.executor_model)
self.table_model = ExecutorRunParametersTableModel(self)
self.table_model.sig_data_changed.connect(
lambda: self.set_modified(True))

self.all_executor_model: Dict[
str, Dict[Tuple[str, str, str],
ExtendedRunExecutionParameters]] = {}
self.previous_executor_index: int = 0
self.default_executor_conf_params: Dict[
str, Dict[Tuple[str, str, str],
ExtendedRunExecutionParameters]] = {}

about_label = QLabel(_("The following are the per-executor "
"configuration settings used for "
Expand Down Expand Up @@ -163,16 +194,28 @@ def setup_page(self):

self.new_configuration_btn = QPushButton(
_("Create new parameters"))
self.clone_configuration_btn = QPushButton(
_("Clone currently selected parameters"))
self.delete_configuration_btn = QPushButton(
_("Delete currently selected parameters"))
self.reset_configuration_btn = QPushButton(
_("Reset parameters"))
self.delete_configuration_btn.setEnabled(False)
self.clone_configuration_btn.setEnabled(False)

self.new_configuration_btn.clicked.connect(
self.create_new_configuration)
self.clone_configuration_btn.clicked.connect(
self.clone_configuration)
self.delete_configuration_btn.clicked.connect(
self.delete_configuration)
self.reset_configuration_btn.clicked.connect(self.reset_to_default)

# Buttons layout
btns = [self.new_configuration_btn,
self.delete_configuration_btn]
self.clone_configuration_btn,
self.delete_configuration_btn,
self.reset_configuration_btn]
sn_buttons_layout = QGridLayout()
for i, btn in enumerate(btns):
sn_buttons_layout.addWidget(btn, i, 1)
Expand All @@ -189,21 +232,32 @@ def setup_page(self):
vlayout.addStretch(1)

def executor_index_changed(self, index: int):
# Save previous executor configuration
prev_executor_info = self.table_model.get_current_view()
previous_executor_name, _ = self.executor_model.selected_executor(
self.previous_executor_index)
self.all_executor_model[previous_executor_name] = prev_executor_info
# Handle current executor configuration
executor, available_inputs = self.executor_model.selected_executor(
index)

executor_conf_params = {}
for (ext, context) in available_inputs:
params = (
self.plugin_container.get_executor_configuration_parameters(
executor, ext, context))
params = params["params"]
for exec_params_id in params:
exec_params = params[exec_params_id]
executor_conf_params[
(ext, context, exec_params_id)] = exec_params
container = self.plugin_container
executor_conf_params = self.all_executor_model.get(executor, {})
if executor_conf_params == {}:
for (ext, context) in available_inputs:
params = (
container.get_executor_configuration_parameters(
executor, ext, context))
params = params["params"]
for exec_params_id in params:
exec_params = params[exec_params_id]
executor_conf_params[
(ext, context, exec_params_id)] = exec_params
self.default_executor_conf_params[executor] = deepcopy(
executor_conf_params)
self.all_executor_model[executor] = deepcopy(executor_conf_params)

self.table_model.set_parameters(executor_conf_params)
self.previous_executor_index = index

def get_executor_configurations(self) -> Dict[
str, SupportedExecutionRunConfiguration]:
Expand Down Expand Up @@ -236,5 +290,52 @@ def get_executor_configurations(self) -> Dict[
def create_new_configuration(self):
self.params_table.show_editor(new=True)

def clone_configuration(self):
self.params_table.clone_configuration()

def delete_configuration(self):
executor_name, _ = self.executor_model.selected_executor(
self.previous_executor_index)
index = self.params_table.currentIndex().row()
conf_index = self.table_model.get_tuple_index(index)
executor_params = self.all_executor_model[executor_name]
executor_params.pop(conf_index)
self.table_model.set_parameters(executor_params)
self.table_model.reset_model()

def reset_to_default(self):
self.all_executor_model = deepcopy(self.default_executor_conf_params)
executor_name, _ = self.executor_model.selected_executor(
self.previous_executor_index)
executor_params = self.all_executor_model[executor_name]
self.table_model.set_parameters(executor_params)
self.table_model.reset_model()
self.set_modified(False)

def apply_settings(self):
pass
prev_executor_info = self.table_model.get_current_view()
previous_executor_name, _ = self.executor_model.selected_executor(
self.previous_executor_index)
self.all_executor_model[previous_executor_name] = prev_executor_info

for executor in self.all_executor_model:
executor_params = self.all_executor_model[executor]
stored_execution_params: Dict[
Tuple[str, str],
Dict[str, ExtendedRunExecutionParameters]] = {}

for key in executor_params:
(extension, context, params_id) = key
params = executor_params[key]
ext_ctx_list = stored_execution_params.get(
(extension, context), {})
ext_ctx_list[params_id] = params
stored_execution_params[(extension, context)] = ext_ctx_list

for extension, context in stored_execution_params:
ext_ctx_list = stored_execution_params[(extension, context)]
self.plugin_container.set_executor_configuration_parameters(
executor, extension, context, {'params': ext_ctx_list}
)

return {'parameters'}
26 changes: 25 additions & 1 deletion spyder/plugins/run/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
# Standard library imports
from collections import OrderedDict
import enum
steff456 marked this conversation as resolved.
Show resolved Hide resolved
from typing import Dict, Tuple, Optional, Set, Union
from typing import Dict, Tuple, Optional, Set, Union, List

# Third-party imports
from qtpy.QtCore import (Qt, Signal, QAbstractListModel, QModelIndex,
Expand Down Expand Up @@ -349,6 +349,8 @@ class ExecutorRunParametersTableModel(QAbstractTableModel):
CONTEXT = 1
NAME = 2

sig_data_changed = Signal()

def __init__(self, parent):
super().__init__(parent)
self.executor_conf_params: Dict[
Expand Down Expand Up @@ -410,6 +412,12 @@ def set_parameters(self, params: Dict[
self.inverse_index = {v: k for k, v in self.params_index.items()}
self.endResetModel()

def get_current_view(self) -> ExtendedRunExecutionParameters:
return self.executor_conf_params

def get_tuple_index(self, index: int) -> Tuple[str, str, str]:
return self.params_index[index]

def reset_model(self):
self.beginResetModel()
self.endResetModel()
Expand Down Expand Up @@ -437,6 +445,22 @@ def sort(self, column: int, order: Qt.SortOrder = ...) -> None:
self.inverse_index = {v: k for k, v in self.params_index.items()}
self.endResetModel()

def apply_changes(
self, changes: List[Tuple[str, ExtendedRunExecutionParameters]],
extension: str, context: str):
self.beginResetModel()
for (operation, params) in changes:
key = (extension, context, params['uuid'])
if operation == 'deleted':
self.executor_conf_params.pop(key)
else:
self.executor_conf_params[key] = params

self.params_index = dict(enumerate(self.executor_conf_params))
self.inverse_index = {v: k for k, v in self.params_index.items()}
self.endResetModel()
self.sig_data_changed.emit()

def __len__(self):
return len(self.inverse_index)

Expand Down
9 changes: 4 additions & 5 deletions spyder/plugins/run/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -383,13 +383,12 @@ def accept(self) -> None:

if self.default_params:
uuid = self.default_params['uuid']
name = self.default_params['name']
else:
uuid = str(uuid4())
name = self.store_params_text.text()
if name == '':
date_str = datetime.now().strftime("%Y-%m-%dT%H:%M:%S")
name = f'Configuration-{date_str}'
name = self.store_params_text.text()
if name == '':
date_str = datetime.now().strftime("%Y-%m-%dT%H:%M:%S")
name = f'Configuration-{date_str}'

ext_exec_params = ExtendedRunExecutionParameters(
uuid=uuid, name=name, params=exec_params
Expand Down