Fix CedRawIO with sonpy >= 1.9.12 and re-enable the CED tests - #1891
Open
AxelNoun wants to merge 3 commits into
Open
Fix CedRawIO with sonpy >= 1.9.12 and re-enable the CED tests#1891AxelNoun wants to merge 3 commits into
AxelNoun wants to merge 3 commits into
Conversation
sonpy 1.9.12 dropped the 'lib' namespace that cedrawio.py used, so every sonpy.lib.* access raised AttributeError. Resolve the namespace once, probing sonpy.lib, sonpy and sonpy.sonpy in turn: the last is needed on Linux, where the 1.9.12 wheel ships an empty __init__.py. Refs NeuralEnsemble#1890 Co-authored-by: Cursor <cursoragent@cursor.com>
test_cedio.py replicated the old per-platform sonpy dispatch and skipped with 1.9.12; test_cedrawio.py guarded on a bare 'import sonpy', which succeeds with 1.9.12 so the test would run and fail. Both now delegate to _get_sonpy_namespace(). Refs NeuralEnsemble#1890 Co-authored-by: Cursor <cursoragent@cursor.com>
The test extra declared sonpy;python_version<'3.10' while the project requires >=3.10, so sonpy was never installed and the CED tests never ran. Target the platform/version combinations sonpy actually publishes wheels for; the sdist ships a Windows .pyd and is not usable elsewhere. Refs NeuralEnsemble#1890 Co-authored-by: Cursor <cursoragent@cursor.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1890.
sonpy 1.9.12 reorganised its package layout and dropped the
libnamespace thatcedrawio.pyrelies on, so everysonpy.lib.*access raisesAttributeError: module 'sonpy' has no attribute 'lib'.While preparing the fix I found that the CED tests could not have caught this, for two
independent reasons — so this PR fixes the reader and restores the test coverage that would
have flagged it.
1.
neo/rawio/cedrawio.py— resolve the namespaceA cached
_get_sonpy_namespace()helper probes three candidates in order:sonpy.lib<= 1.9.5, the old per-platform dispatchsonpy>= 1.9.12on Windows and macOS (from .sonpy import *)sonpy.sonpy>= 1.9.12on Linux, whose wheel ships an empty__init__.pyThe third is not redundant: the
cp314-manylinux_2_39_x86_64wheel has a 0-byte__init__.py, so neithersonpy.libnorsonpy.SonFileresolves there. If none of thethree exposes
SonFile, anImportErrornaming all three is raised, rather than letting anAttributeErrorsurface from the middle of_parse_header.2. Both CED test guards
There are two, and each fails differently with 1.9.12:
neo/test/iotest/test_cedio.pyreplicated the old per-platform dispatch(
import sonpy.linux.sonpy, …), which no longer exists →HAVE_SONPY = False→ skipped.neo/test/rawiotest/test_cedrawio.pyused a bareimport sonpy, which succeeds with1.9.12 →
HAVE_SONPY = True→ the test would run and fail with theAttributeError.Both now delegate to
_get_sonpy_namespace(), so "sonpy is usable" has one definition.3.
pyproject.toml— thetestextra never installed sonpy"sonpy;python_version<'3.10'",with
requires-python = ">=3.10". The marker cannot be satisfied, so sonpy is absent fromevery CI run and both guards were moot regardless of how they were written. This is why the
breakage went unnoticed.
Changed to match where sonpy actually publishes usable wheels:
1.9.12 ships
win_amd64wheels for cp39–cp314, butmanylinuxandmacosxonly for cp314.The marker is deliberately not just
"sonpy": on Linux 3.10–3.13 pip would fall back to thesource distribution, which ships a Windows
.pyd(verified:PE32+ executable (DLL) […] for MS Windows) and produces an unusable install.The practical effect is that the automatic
ubuntu-latest/ Python 3.14 CI job will nowinstall sonpy and actually exercise
CedRawIO.Verification
The existing test suite goes from failing to passing. Windows, Python 3.12, sonpy 1.9.12,
against
master(35cbce7):pytest neo/test/rawiotest/test_cedrawio.py -vFAILED—AttributeError: module 'sonpy' has no attribute 'lib'atcedrawio.py:72PASSED(1.07 s) —test_read_allacross all three spike2 entitiesThat covers both
.smrxand the two.smrentities, so the reader is exercised end to endand not just at import time.
Additionally:
sonpy.libabsent on all five; the compiledlibrary reads
spike2/m365_1sec.smrxcorrectly through the new namespace(
GetOpenError() == 0,MaxChannels() == 101), confirming an import-path problem ratherthan a functional regression in sonpy.
sonpy.sonpy;SonFile,DataType.Adc,DataType.AdcMarkandMarkerFilterare all reachable, andCedRawIO.parse_header()runs to completion instead of raising.HAVE_SONPYisTruewith sonpy 1.9.12 presentand
Falsewhen sonpy cannot be imported.Trueexactly where a usable wheel exists, across the sixplatform/version combinations in Neo's support range.
black --line-length 120 --checkclean on all changed files.pytest neo/test/rawiotest/test_cedrawio.py neo/test/iotest/test_cedio.py -v→ 8 passed.Not covered
macOS is untested. It is the one platform where the 1.9.12 wheel exists only for cp314, so
3.10–3.13 are excluded by the marker there. Happy to run it if someone has a machine.
Open questions
platform_system=='Windows' or python_version>='3.14'acceptable, or would you ratherkeep the
testextra minimal and add sonpy only to the CI workflow?cedextra (line 101, currently a bare"sonpy") get the same marker forconsistency? I left it alone to keep the diff focused.