Skip to content

Phase 1: Move oct2py, psutil, and pyedflib out of the base install - #380

Merged
neuromechanist merged 6 commits into
epic/324-pyodide-browserfrom
phase/374-extras-split
Sep 17, 2026
Merged

neuromechanist merged 6 commits into
epic/324-pyodide-browserfrom
phase/374-extras-split

Conversation

@neuromechanist

Copy link
Copy Markdown
Member

Closes #374

Phase 1 of epic #324: makes micropip.install("eegprep") viable in a browser/WebAssembly environment by removing packages with no WebAssembly build from [project].dependencies.

Changes

  • Moved oct2py to a new [eeglab] extra (gates the Octave runtime path in eeglabcompat.py).
  • Moved psutil to a new [sys] extra (gates memory-based job sizing in bids_preproc's ReservePerJob).
  • Removed pyedflib from [project].dependencies entirely (see "pyedflib decision" below).
  • [all] now includes eeglab and sys, so full installs are unaffected.
  • asr_process.py's max_mem=None no longer calls psutil.virtual_memory(). It resolves once, at the top of the function, to a fixed DEFAULT_MAX_MEM_MB = 64, matching the maxmem=64 default already used by asr_calibrate() and clean_asr() elsewhere in this plugin. The retry that re-queried psutil when the block-size check failed is removed; it now fails fast with RuntimeError('Not enough memory') instead, since retrying with the same fixed constant would just repeat the identical failed check.
  • misc.py's num_jobs_from_reservation and eeglabcompat.py's get_eeglab('OCT') now raise ImportError naming the exact extra (eegprep[sys] / eegprep[eeglab]) instead of a bare uv pip install psutil or an unguarded oct2py import.
  • Added tools/check_pyodide_base_resolution.py, the phase-gate script: walks eegprep's base dependency closure from uv.lock (evaluating dependency markers against a synthetic Pyodide/Emscripten environment, so greenlet correctly self-excludes), then checks each package against the official Pyodide package lock or, failing that, for a pure-Python wheel on PyPI. Currently: 0 failing, 1 known non-blocking gap (below).
  • uv.lock regenerated; docs/source/user_guide/installation.rst and README.md document the new extras.

pyedflib decision (reversible, flagging per issue instructions)

Removed outright per the issue's recommendation, since nothing in src/ imports it. One thing the issue's grounding missed: tests/test_bids_load_frombids_helpers.py imports pyedflib directly to write a synthetic EDF fixture. Deleting it outright would break that test's collection, so it now lives in the dev dependency group (test-fixture-only, same treatment as pytest), never reaching published installs, [all], or micropip.install. Posted the open question on #374; this is cheap to reverse if a [formats] extra is preferred instead.

New finding: docopt (not blocking, flagged for a maintainer call)

The resolution-check script found that docopt (pulled in via pybids -> num2words) has no wheel published on PyPI at all (sdist-only), which would independently block micropip.install("eegprep"). num2words declares it as an unconditional dependency even though it's only imported by num2words's own CLI entry point, never invoked by pybids or eegprep. Fixing this would mean changing pybids's or num2words's dependency tree, which conflicts with this phase's explicit non-goal ("no change to pybids, mne, or neo"), so it's tracked as a documented, non-blocking known gap in the check script rather than silently worked around. Flagging for a maintainer decision (likely an override-dependencies entry in a later phase, or an upstream fix).

Verification

./pre-commit.py --changed-from origin/develop, uv run --no-sync ruff check ., ruff format --check ., and ty check are all clean. EEGPREP_SKIP_MATLAB=1 uv run pytest tests -m "not slow" passes except one pre-existing, unrelated failure (test_pop_reref.py::PopRerefIcaRegressionTests::test_sample_data_average_reference_emits_no_runtime_warning, a BLAS divide-by-zero warning reproduced identically on the base commit before this branch's changes). tools/check_pyodide_base_resolution.py exits 0. Added a real (not mocked) regression test that blocks the psutil import via sys.modules and calls asr_process(..., max_mem=None) to prove that path no longer needs it.

oct2py drags in octave-kernel/ipykernel/pyzmq/debugpy/tornado, and psutil
has no WebAssembly build; both now live behind new [eeglab] and [sys]
extras instead of [project].dependencies, and both are included in [all].

pyedflib has zero imports under src/; nothing but a test fixture writer
in tests/test_bids_load_frombids_helpers.py needs it, so it moves to the
dev dependency group instead of becoming an unused extra. Not tested
beyond `uv lock`/`uv sync` succeeding; behavior verified by later commits.
max_mem=None previously called psutil.virtual_memory() twice (once for
the initial default, once as a retry when the block-size check failed),
which broke unhelpfully now that psutil is optional. Resolve it once, at
the top of asr_process, to a fixed DEFAULT_MAX_MEM_MB=64, matching the
maxmem=64 default already used by asr_calibrate() and clean_asr()
elsewhere in this plugin. The now-pointless retry (re-fetching the same
value again) is removed in favor of failing fast.

Updated test_utils_asr.py: dropped the psutil mocks in
test_memory_management/test_memory_error_handling since asr_process no
longer imports psutil, and added
test_default_max_mem_works_without_psutil, which blocks the real psutil
import via sys.modules to prove max_mem=None does not need it. Tested
with `uv run pytest tests/test_utils_asr.py`.
get_eeglab('OCT') now catches the bare oct2py ImportError and re-raises
naming 'eegprep[eeglab]'. num_jobs_from_reservation's psutil ImportError
previously named a bare 'uv pip install psutil'; it now names
'eegprep[sys]' too. Verified manually with the real import blocked (and,
for the oct2py path, a stub EEGLAB checkout so get_eeglab reaches the
oct2py import at all): both raise the updated message.
Phase gate for #374: walks eegprep's base dependency closure in
uv.lock (evaluating dependency markers against a synthetic Pyodide/
Emscripten environment, so e.g. greenlet correctly self-excludes),
then checks each package against the official Pyodide package lock
and, failing that, for a pure-Python (abi=none, platform=any) wheel
on PyPI that micropip could install directly.

One pre-existing gap is tracked as non-blocking: docopt (pulled in via
pybids -> num2words) has no PyPI wheel at all. Fixing it would mean
changing pybids's or num2words's own dependency tree, which is out of
scope for this phase (no numerical/behavioral change, and pybids/mne/neo
are explicitly not to be touched here); flagged in the script output and
in the PR description for a maintainer decision.

Tested by running the script directly: 0 failing, 1 known gap, exit 0.
Add install.rst sections for the MATLAB/Octave parity helpers
(eeglab extra) and system-aware parallel job sizing (sys extra), and
mention them in the all-extras examples in install.rst and README.
Docs-only change, not separately tested beyond reading the rendered
text.

@claude claude Bot left a comment

Copy link
Copy Markdown
Contributor

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's extra usage balance is too low to start another review, so this review was not started.

An organization admin can add extra usage credits at claude.ai/admin-settings/usage.

Once credits are available, reopen this pull request to trigger a review.

@claude

claude Bot commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

Claude encountered an error after 0s —— View job


I'll analyze this and get back to you.

The extras split changes what a plain install provides and the ASR default
changes numerical output for direct asr_process(max_mem=None) callers, so
both need a user-facing note.
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