Skip to content

eegprep-lean: let the host choose the browser transport #413

Closed

Description

@neuromechanist

Problem

PyfetchTransport.get imports pyodide.http when it makes a request.
The OSA browser runtime (OpenScience-Collective/osa#431), which is where NEMAR's python_browser recipe runs, seals the interpreter before any model-written code executes.
The seal blocks the pyodide, js and micropip roots.
Its one sanctioned network route is the host's own client, which enforces the community's fetch allowlist.

So await open_array(url), exactly as nemar_read_window hands it out, fails there with an ImportError about pyodide.http.
Nothing about eegprep-lean is wrong in a plain Pyodide; the gap is that a host cannot say how requests should be made.

Proposal

  • FetchTransport(fetch): a Transport over any async fetch(url, *, headers) -> (status, body).
    It reuses _range_header (including the suffix form the sharding codec needs) and _check_ranged, and raises TransportError for a failed request or a status of 400 and above.
  • set_default_transport(transport): lets the host that owns the interpreter choose what default_transport() returns, once, at startup; None restores platform selection.
    An explicit transport= argument still wins everywhere.

With both, the OSA runtime registers FetchTransport(osa.fetch) after its seal, and the recipe runs verbatim.

Tests

Against the real loopback server the existing transport and read-window tests use, with a fetch that makes real HTTP requests:
ranges (suffix included), a range answered in full refused, HTTP errors carrying their status, and a sharded store read end to end through set_default_transport.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions