Repository navigation
eegprep-lean: send only Range from PyfetchTransport - #420
Merged
Merged
Conversation
Safari and Firefox send a script-set User-Agent header, unlike Chrome, which drops it. That made PyfetchTransport's User-Agent header turn every read into a CORS preflight, and zarr.nemar.org allows only Range in Access-Control-Allow-Headers, so the preflight was refused there. PyfetchTransport now builds its request through FetchTransport, over an adapter around pyodide.http.pyfetch, so the header rule (Range only, nothing at all for an unranged read) has one implementation instead of two. This also picks up FetchTransport's existing coverage of the failure paths (connection failure, HTTP error status, a ranged request answered in full) for PyfetchTransport, which previously carried three "browser only" no-cover pragmas. Kept USER_AGENT for UrllibTransport, where it is still needed, and corrected its comment: browsers dropping a script-set User-Agent is true of Chrome only. Tests install a stand-in pyodide.http module at sys.modules (real requests over urllib against the same loopback server the other transport tests use), so PyfetchTransport.get is exercised directly instead of only documented as untestable outside Pyodide. Tested: uv run pytest across all four eegprep-lean CI tiers (base, zarr, plot, both extras), ruff check/format and ty check clean.
Contributor
There was a problem hiding this comment.
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, reopen this pull request to trigger a review.
Contributor
|
Claude encountered an error after 0s —— View job I'll analyze this and get back to you. |
1 similar comment
Contributor
|
Claude encountered an error after 0s —— View job I'll analyze this and get back to you. |
This was referenced Sep 25, 2026
This was referenced Sep 25, 2026
neuromechanist
added a commit
that referenced
this pull request
Sep 25, 2026
#420 changed PyfetchTransport's bytes without moving the version, and OSA vendors the wheel by file name, which it serves as immutable, so new bytes need a new name before they can be re-vendored. Tested: eegprep-lean tests, base tier (114 passed, 2 skipped); eegprep_lean.__version__ reads 0.1.0.dev3.
5 of 7 tasks
neuromechanist
added a commit
to OpenScience-Collective/osa
that referenced
this pull request
Sep 25, 2026
sccn/eegprep#420 makes PyfetchTransport send only Range; its User-Agent made every notebook read in Safari and Firefox a CORS preflight zarr.nemar.org refuses (#496). Built reproducibly from 50c50879 (#423); the runtime and the notebook site serve it. Tested: two builds give sha256 12a07ac4...; build_runtime_lock --check current; nemar runtime, notebook site and drift pytest (127); test-data-lane.js 93/93; chrome.js ok; drift watcher current.
6 tasks
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 #419
What
PyfetchTransport.getsent aUser-Agent: eegprep-leanheader on every request. Chromedrops a script-set
User-Agent, so requests there stayed simple; Safari and Firefox sendit, which turned every read into a CORS-preflighted request.
zarr.nemar.orgallows onlyRangeinAccess-Control-Allow-Headers, so the preflight was refused and every readfailed in those two browsers.
PyfetchTransportnow builds its request throughFetchTransport, over a small adapteraround
pyodide.http.pyfetch(_pyfetchintransport.py), instead of keeping a second,separate implementation of the header rule.
FetchTransportalready sentRangeonly,and nothing at all for an unranged read, for exactly this reason (its docstring). Sharing
the implementation also means
PyfetchTransportnow goes through the sameTransportError-on-failure, ranged-request-answered-in-full, and 4xx/5xx handling asFetchTransport, which previously carried three# pragma: no cover - browser onlymarkers because they could not be exercised outside a browser.
UrllibTransportkeeps sendingUSER_AGENT, since the NEMAR hosts refuse the defaultPython-urllibagent. The comment aboveUSER_AGENTclaimed browsers "set their own andignore this," which is true of Chrome only; corrected it to say so and to point at
FetchTransportfor why the browser transports send neither header value.Why
Filed as #419, from OpenScience-Collective/osa#496: measured in headless WebKit 26.6 and
Firefox 155 (Playwright 1.63) against
zarr.nemar.org, with Chrome 153 as the control.Without the
User-Agentheader, the same request answers 200 unranged and 206 ranged inall three browsers; with it, WebKit and Firefox refuse the preflight and the read fails
(a hang in WebKit specifically, worked around separately in
OpenScience-Collective/osa#502, then a
TransportError). AllowingUser-Agenton theNEMAR hosts instead would add a preflight to every chunk read in Safari and Firefox, so
the client-side change is the one the issue asks for.
Tests
Added coverage in
packages/eegprep-lean/tests/test_transport.pyandtests/conftest.py.PyfetchTransport.getitself is now exercised off Pyodide: a fakepyodide.httpmodule is installed atsys.modules(conftest.FakePyfetch), whosepyfetchmakes a real request overurllibagainst the same loopbackhttp.servertheother transport tests already use, and records the headers actually sent. This is a
stand-in for the browser's network boundary, not a mock of business logic, the same kind
of thing as an HTTP response fixture.
PyfetchTransportis now a third parametrization ("pyfetch") of the sharedtransportfixture, so it runs through the existingTestRangesandTestFailuresclasses: whole body, closed range, suffix range, open-ended range, a ranged request
answered in full refused, an unranged 200 not refused, an HTTP error status carrying
its status, and a connection failure carrying no status but naming the URL.
TestPyfetchTransport.test_only_range_is_sent_and_never_user_agent, asserting onthe headers the fake
pyodide.http.pyfetchactually received:Rangeonly for aclosed and a suffix range, and no headers at all for an unranged read.
PyfetchTransport"cannot be exercised here";it now can be, and is.
34/34 tests in
test_transport.pypass, 10 of them coveringPyfetchTransport(the eight[pyfetch]parametrizations ofTestRangesandTestFailures, the header test, and the platform-selection test).Mutation check (put back, ran, restored, ran again):
User-Agentheader in the adapter: 1 test failed(
test_only_range_is_sent_and_never_user_agent).Rangeheader in the adapter: 4 tests failed (the three rangedTestRangescases forpyfetch, plus the same header test).Both mutations restored; the full suite is green again.
Full suite, via
uv, matching.github/workflows/test.yml's four tiers:PYTHONPATH=src uv run --no-sync --project ../.. pytest tests -m "not network"):114 passed, 2 skipped.
zarrextra: 120 passed, 1 skipped.plotextra: 114 passed, 2 skipped.(
-m "not network"throughout; the network tier hits the livezarr.nemar.organd runsin
lean-live.ymlon a schedule.)Lint and types, matching the repo's
lintCI job:uv run --no-sync ruff check .: all checks passed.uv run --no-sync ruff format --check .: all files already formatted.uv run --no-sync ty check .: no diagnostics in anything touched by this change (3pre-existing
unresolved-import: torchdiagnostics elsewhere in the repo, unrelated tothis PR and untouched by it).
After merge
eegprep-lean has no PyPI release path of its own (see its README and ADR 0069); OSA picks
this fix up by re-vendoring the wheel by commit (
src/assistants/nemar/runtime/inOpenScience-Collective/osa, per that directory's README), not through a PyPI release.