Skip to content

[GUI] Keep pop_importevent dialog open on import errors - #801

Merged
arnodelorme merged 1 commit into
developfrom
agent/20261128-fix-790
Nov 28, 2026
Merged

arnodelorme merged 1 commit into
developfrom
agent/20261128-fix-790

Conversation

@claude

@claude claude Bot commented Nov 28, 2026

Copy link
Copy Markdown
Contributor

Validate the event import before the pop_importevent dialog closes, so an invalid field name such as Latency Type Position shows a warning and keeps the file and settings for correction instead of losing them. The error text now says latency and type must be lowercase and fields follow file column order. Adds an offscreen GUI regression test.

Part of #790

🤖 Generated with Claude Code

Validate the import before closing the dialog so an invalid field name such
as "Latency Type Position" shows a warning and keeps the file and settings
available for correction.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@claude claude Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Code review skipped — your organization has no extra usage available to pay for this review.

If your organization's extra usage balance is empty, an organization admin can add extra usage credits at claude.ai/admin-settings/usage. If its monthly spend limit was reached, an admin can raise it on the same page. If neither applies, contact Anthropic support.

Once extra usage is available, someone with write access to this repository can comment @claude review on this pull request to trigger a review.

@claude

claude Bot commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor Author

Claude finished @claude[bot]'s task in 1m 2s —— View job


Code review

  • Overall assessment: Looks good, with two small suggestions. I checked the validator wiring in qt.py _accept_if_valid: only ValueError is caught there, and the OSError→ValueError wrap covers unreadable or missing files. I also checked that the GUI path still produces the same options (_gui_options is a straight extraction), that the dataset and history change only once, after a successful import, and that the docs and help text were updated.
  • Highest-risk area: the dialog's OK handler now runs the whole import, including alignment.
  • Merge recommendation: Safe to merge. The nits below are optional.

Blocking

None.

Important

None.

Nits

  1. The validator runs the slow alignment search too, so it runs twice (_validate_dialog_values, pop_importevent.py#L80-L88). When the dataset already has events, the dialog defaults to align=0 and auto-adjust on. So both the OK-click validation and the real import call _optimal_alignment. That function calls fmin twice, and each evaluation compares every new event with every existing one. With a few thousand events, the UI freezes for twice as long before the dialog closes. The alignment search can't raise a validation error, so the validation copy can skip it: set options['optimalign'] = 'off' before calling _import_event_records. The _validate_alignment checks still run. There's an inline suggestion on that line.
  2. The rewritten reserved-field error no longer tells console users what to pass (pop_importevent.py#L103-L108). This message is raised from the console as well as from the dialog. The old text named the exact fix (fields=[...], skipline=1). The new "skip the header line" doesn't say which option to set. Suggested text: "... for example fields='latency type position' (or fields=['latency', 'type', 'position']) with skipline=1 for a header line."

Test gaps

None. The new offscreen test covers the regression end to end: it checks that the file and skipline survive the error, that ALLCOM is unchanged mid-dialog, and that the import and history entry happen exactly once. I wasn't allowed to run pytest in this job, so I haven't run the test myself; CI should confirm it.

EEGLAB parity notes

None. EEGLAB's pop_importevent.m closes the dialog and then errors. Keeping the form open adds a UX improvement and leaves the options and the history command unchanged.

Checked for correctness bugs, EEGLAB parity, data structure compatibility, changed-behavior tests, and CLAUDE.md/AGENTS.md compliance.

Comment on lines +80 to +86
def _validate_dialog_values(EEG: dict[str, Any], values: dict[str, Any]) -> None:
options = _gui_options(values)
event_source = options.get("event")
if event_source is None:
raise ValueError("pop_importevent: select an event file")
try:
_import_event_records(event_source, EEG.get("event"), float(EEG.get("srate", 1) or 1), options)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit (performance): This validator runs the whole import, including _optimal_alignment. When the dataset already has events, the dialog defaults to align=0 with auto-adjust on, so clicking OK runs fmin twice. Each evaluation compares every new event with every existing one, and then pop_importevent repeats the whole search after the dialog closes. With a few thousand events, the UI freezes for twice as long.

The alignment search can't raise a validation error, so the validation copy can skip it. The _validate_alignment range checks still run:

Suggested change
def _validate_dialog_values(EEG: dict[str, Any], values: dict[str, Any]) -> None:
options = _gui_options(values)
event_source = options.get("event")
if event_source is None:
raise ValueError("pop_importevent: select an event file")
try:
_import_event_records(event_source, EEG.get("event"), float(EEG.get("srate", 1) or 1), options)
def _validate_dialog_values(EEG: dict[str, Any], values: dict[str, Any]) -> None:
options = _gui_options(values)
options['optimalign'] = 'off'
event_source = options.get("event")
if event_source is None:
raise ValueError("pop_importevent: select an event file")
try:
_import_event_records(event_source, EEG.get("event"), float(EEG.get("srate", 1) or 1), options)

@arnodelorme
arnodelorme merged commit 8146295 into develop Nov 28, 2026
18 of 22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant