Skip to content

Fix saved model path collisions across paradigms - #1206

Merged
bruAristimunha merged 6 commits into
NeuroTechX:developfrom
lindicaphxag-tech:fix/model-save-path-collisions
Oct 4, 2026
Merged

bruAristimunha merged 6 commits into
NeuroTechX:developfrom
lindicaphxag-tech:fix/model-save-path-collisions

Conversation

@lindicaphxag-tech

@lindicaphxag-tech lindicaphxag-tech commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fixes #1182 by namespacing saved evaluation artifacts with the paradigm and optional run suffix. Two benchmark runs that share an evaluation type, dataset, subject, session, and pipeline no longer overwrite one another when their paradigm or suffix differs.

The layout is now:

<Models|GridSearch>_<evaluation>/<Paradigm>/<suffix-if-set>/<dataset>/<subject>/<session>/<pipeline>/

The model path change is documented as an API compatibility change. Calls to the private path helper that omit paradigm retain their previous layout.

Validation

  • git diff --check
  • python -m py_compile moabb/evaluations/base.py moabb/evaluations/utils.py moabb/tests/test_evaluations.py
  • uv run --active --no-sync python -m pytest moabb/tests/test_evaluations.py -q -k 'create_save_path or test_within_session_evaluation_save_model' — 11 passed.
  • Added path tests covering paradigm and suffix isolation, plus an integration test that runs a fake EEG evaluation and checks the paradigm-scoped output directory.

lindicaphxag-tech commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor Author

@bruAristimunha this is ready for maintainer review when convenient. It fixes #1182 by namespacing saved evaluation artifacts by paradigm and optional suffix and targets develop. Exact-head validation on 6e9a24f0cb3d8c5f748ce11f1e4146af82fe9a99 is green: touched-file pre-commit passes and all 11 focused path/integration regressions pass, including the fake EEG evaluation save path. Evidence: https://github.com/lindicaphxag-tech/lindicaphxag-tech/actions/runs/37136756045. I’ll hold the current head rather than make further scope changes.

@bruAristimunha bruAristimunha left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks @lindicaphxag-tech — the collision in #1182 is real and namespacing by paradigm/suffix is the natural fix. The code reads fine and the private helper keeps its old layout when paradigm is omitted. Because this changes the on-disk layout of saved models for everyone, I want to think about the migration story (existing Models_* trees become orphaned) before approving; I've approved the Actions run so CI can speak in the meantime. Merge-order note for the series: this one goes first, #1211 last.

Copy link
Copy Markdown
Contributor Author

Migration follow-up on current head 38d4be23: I don't think an automatic move of existing Models_* / GridSearch_* trees can be made safe, because the legacy path is exactly missing the two provenance fields needed to choose a destination (paradigm and suffix). Any automatic migration would have to guess which namespace an existing pickle belongs to.

I tightened the migration story instead:

  • legacy trees are left untouched at their historical paths; this PR only changes the destination for new saves;
  • the API-change note now says explicitly that legacy artifacts are not auto-migrated and remain manually readable in place;
  • the official noplot_load_model.py example now points to the canonical output produced by plot_benchmark.py: Models_WithinSession/LeftRightImagery/benchmark/Zhou2016/..., and notes that older trees remain at their original path.

This keeps the collision fix non-destructive and avoids assigning false provenance to old artifacts. If you prefer a warning when a legacy tree is detected during a new save, I can add that, but I would avoid moving/copying it automatically.

@lindicaphxag-tech
lindicaphxag-tech force-pushed the fix/model-save-path-collisions branch from 38d4be2 to 8459398 Compare October 4, 2026 15:21
@lindicaphxag-tech

Copy link
Copy Markdown
Contributor Author

Rebased onto current develop (ae47249, including #1210). I resolved the changelog overlap by retaining both API notes. The migration note now explicitly states that existing Models_* and GridSearch_* trees remain at their historical paths, are not auto-migrated because their paradigm/suffix provenance is unavailable, and remain manually readable there.

The current head is 845939818aea97df21843c7d96bb6e90fa8232a6. Pre-commit CI, Python syntax compilation, and git diff --check pass. The full GitHub test matrix is running; this Windows environment cannot execute pytest because the test dependencies (starting with nemar) are not installed.

@lindicaphxag-tech

Copy link
Copy Markdown
Contributor Author

Added two regression checks on current head c471dd8: the fake WithinSession evaluation now verifies that a model artifact is actually written beneath the paradigm/suffix namespace, and the path test covers the GridSearch namespace as well. pre-commit.ci, link-check, Python syntax compilation, and git diff --check pass; this environment still lacks pytest, and the fresh upstream matrix is running.

@lindicaphxag-tech
lindicaphxag-tech force-pushed the fix/model-save-path-collisions branch from c471dd8 to 8a49db4 Compare October 4, 2026 16:29

@bruAristimunha bruAristimunha left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks @lindicaphxag-tech — the migration story on this head is the right call: legacy Models_*/GridSearch_* trees stay where they are (no false-provenance auto-move), the API-change note spells it out, and noplot_load_model.py points at the new canonical path. The two new regressions (paradigm-scoped save on the fake WithinSession eval, GridSearch namespace isolation) make the contract load-bearing. CI green on c471dd8. Approving and merging.

@bruAristimunha
bruAristimunha merged commit ac7c01e into NeuroTechX:develop Oct 4, 2026
14 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.

Saved models overwrite each other across paradigms and suffixes

2 participants