Repository navigation
Description
Phase 1 of #324.
Base: epic/324-pyodide-browser.
Blocks: every other phase.
Parallel with: nothing.
Why
micropip.install("eegprep") fails under Pyodide today because the base dependency set pulls C-extension packages that have no WebAssembly build.
This phase removes them from the base install.
The imports are already lazy, so no call site logic changes.
Grounding, verified against the current tree
oct2py is the dominant problem, and not for the reason the epic assumed.
It has exactly one lazy import, src/eegprep/functions/adminfunc/eeglabcompat.py:298, but its dependency tree is oct2py -> octave-kernel -> ipykernel, which drags in pyzmq (needs cffi), debugpy, psutil, and tornado.
Moving oct2py alone removes four C-extension packages from the base install.
It is also inert in a browser regardless of wheels, because there is no Octave binary to drive.
psutil is a direct dependency with no WebAssembly build.
Call sites: src/eegprep/plugins/clean_rawdata/asr_process.py:64 and :115, and src/eegprep/functions/miscfunc/misc.py:207.
pyedflib has zero imports anywhere in src/.
It is only present in pyproject.toml and uv.lock.
EDF reading already goes through mne and neo.rawio.edfrawio (src/eegprep/plugins/EEG_BIDS/raw.py:79).
See the open question below.
greenlet, reached through pybids -> sqlalchemy, is not a blocker.
uv.lock shows it guarded by a platform_machine marker listing AMD64, WIN32, aarch64, amd64, ppc64le, win32, and x86_64.
Pyodide reports wasm32, so greenlet self-excludes.
Do not restructure pybids in this phase.
Everything else in the base set is either in the Pyodide distribution (numpy, scipy, matplotlib, h5py, sympy, pandas, sqlalchemy, pyyaml, scikit-learn, threadpoolctl) or is a pure-Python wheel micropip can pull from PyPI (mne, nibabel, pybids, neo, quantities, pooch, eeglabio, python-picard).
Scope
Add extras and move dependencies out of [project].dependencies:
[eeglab]=oct2py. Gates the Octave path ineeglabcompat.py.[sys]=psutil.pyedflib: see open question.
Fix the two places where a missing extra would now break behavior rather than fail clearly:
asr_process.pyresolvesmax_mem=Noneby callingpsutil.virtual_memory().free.
Withpsutilabsent this raises at an unhelpful point.
Resolve to a documented fixed default instead, once, at the top of the function, per the AGENTS.md rule on environment-dependent defaults.
State the chosen number and its rationale in the PR.misc.py:207andeeglabcompat.py:298must raiseImportErrornaming the exact extra, for examplepip install eegprep[sys].
misc.pyalready raises a message but it names a bareuv pip install psutil; update it to name the extra.
Keep the all extra a true superset so full installs do not regress.
Non-goals
No Pyodide harness or CI in this phase; that is phase 2.
No change to pybids, mne, or neo.
No numerical change anywhere.
Acceptance criteria
-
oct2pyandpsutilare removed from[project].dependenciesand available as[eeglab]and[sys]. -
allincludes every new extra. - A resolution check script asserts that every package in the resolved base requirement set is either present in the Pyodide lockfile or publishes a
py3-none-anywheel.
This is the phase gate; it is deterministic and needs no browser.
Livemicropip.installconfirmation lands in phase 2. - Calling ASR with
max_mem=Nonein an environment withoutpsutilsucceeds and uses the documented default. -
misc.pyandeeglabcompat.pyraiseImportErrornaming the extra. - Octave-marked and
psutil-dependent tests skip cleanly when the extra is absent, with no weakened assertions. -
uv.lockregenerated;uv sync --group devstill yields a working dev environment. -
docs/source/install page documents every extra and says which are needed for which workflow. -
./pre-commit.py --changed-from origin/developclean,uv run --no-sync ruff check .,ruff format --check .,ty checkclean. -
EEGPREP_SKIP_MATLAB=1 uv run pytest tests -m "not slow"green.
Open question for the phase agent to raise, not decide
The epic proposed a [formats] extra for pyedflib.
Nothing imports it, so the options are to delete it outright, or to keep it as an empty-purpose extra for downstream users who import pyedflib themselves.
Recommendation is deletion, since an extra that installs a package eegprep never calls is misleading.
Raise this on the issue and get a maintainer answer before finalizing; do not silently pick one.
/goal prompt
/goal Remove every WebAssembly-incompatible package from eegprep's base install by moving it behind an extra, without changing any numerical behavior or breaking full installs.
Source of truth: pyproject.toml, uv.lock, and the three verified call sites src/eegprep/functions/adminfunc/eeglabcompat.py:298, src/eegprep/plugins/clean_rawdata/asr_process.py:64 and :115, and src/eegprep/functions/miscfunc/misc.py:207. Read AGENTS.md first, especially the rules on resolving environment-dependent defaults once, failing fast on unknown inputs, and not adding compatibility shims.
Constraints: the package must keep working standalone; do not touch pybids, mne, or neo; do not add defensive try/except around impossible states; every changed line must trace to this task.
Finish line: [eeglab] and [sys] extras exist and all is a superset; the resolution check script passes for the base requirement set; ASR with max_mem=None works without psutil; missing extras raise ImportError naming the extra; install docs updated; pre-commit, ruff, ruff format, ty, and EEGPREP_SKIP_MATLAB=1 uv run pytest tests -m "not slow" all clean.
Before finalizing, post the pyedflib question on the issue and wait for a maintainer answer. Report any review finding you chose not to fix, with the reason.
Activity
neuromechanist commentedon Sep 17, 2026
🤖 pyedflib open question: implemented the recommended option (removed it outright from
[project].dependencies; no[formats]extra added).Twist not covered in the original grounding:
tests/test_bids_load_frombids_helpers.pyimportspyedflibdirectly to synthesize an EDF fixture for testing the BIDS/EDF loader (src/never imports it). Deleting it outright would have broken that test's collection. Moved it to thedevdependency group instead (test-fixture-only, same treatment aspytestitself), so it never reaches published installs,[all], ormicropip.install, butuv sync --group devstill has it for running the test suite.Flagging as before: this is easy to reverse if you'd rather add it back as an unused
[formats]extra for downstream users who importpyedflibthemselves. See the PR for details: will link once opened.neuromechanist commentedon Sep 17, 2026
🤖 Reviewed #380 against this issue's non-goals. Two points, one resolved and one that needed a maintainer decision.
ASR
max_memdefault: keeping the fixed 64 MB. Decided, but recording the evidence because the PR description understates the change.This issue's non-goals say "no numerical change anywhere," and the swap from a
psutil-derived budget to a fixed 64 MB does changeasr_processoutput. Measured on 64 channels of 60 s at 250 Hz,max_mem=4096versusmax_mem=64gives a max absolute difference of 8.09 on unit-variance data and a relative Frobenius difference of 3.25e-01. The mechanism is thatupdate_atis built per block, so the reconstruction matrix is refreshed on a grid that restarts at every block boundary; changing the memory budget changes the number of blocks and therefore the update positions.It is still the right call, for reasons the PR did not spell out:
clean_asr.py:34already defaults tomaxmem=64andclean_asr.py:194is the only in-package caller ofasr_process, so the standard cleaning pipeline was already running at 64 and is unaffected.asr_process(..., max_mem=None)calls change, and those were previously machine-dependent, which the old code's own warning text admitted was "not fully reproducible."Callers who want the old behavior pass
max_memexplicitly.Changelog was missing. The extras split changes what a plain install provides and the ASR default changes numerical output, so both are user-facing under the AGENTS.md rule that user-facing changes need matching docs in the same branch. Added in
docs/source/changelog.rston the branch.pyedflib: agreed with moving it to thedevgroup rather than deleting it outright. The grounding in this issue said "zero imports insrc/," which was accurate but incomplete;tests/test_bids_load_frombids_helpers.py:7imports it to write a synthetic EDF fixture. Keeping it indevkeeps it out of every published install while leaving the suite runnable, which satisfies the intent.neuromechanist commentedon Sep 17, 2026
🤖 Done. PR #380 merged into
epic/324-pyodide-browser. Closing manually becauseCloses #374only fires on merges into the default branch, not into an epic branch; the work reachesdevelopwhen epic #324 merges.