Skip to content

feature/SOF-7961-v1 Feat: minimal Python REPL - #294

Open
VsevolodX wants to merge 4 commits into
devfrom
feature/SOF-7961-v1
Open

VsevolodX wants to merge 4 commits into
devfrom
feature/SOF-7961-v1

Conversation

@VsevolodX

Copy link
Copy Markdown
Member

What

The smallest working Python REPL: a View → Python REPL drawer running mat3ra.made.tools in-browser via Pyodide. Materials bind in as materials_in / material before each run; any Material variable syncs back after, merged by one reducer rule (materialsSyncScope): round-tripped ids upsert in place, REPL-created materials replace the previous python-repl batch, hand-made materials are never touched.

One repo, 14 files, ~700 lines, no new npm dependencies. The editor and drawer come from published cove; the environment recipe is one constants file mirroring AX's made profile; the host bridge is ~20 lines of inline Python, marked temporary pending a released notebooks-utils.

Deliberately omitted (each a later, separate PR): autocomplete, editable requirements, preloading, structured tracebacks, any cove/AX change. Architecture memo with the full build ladder: plan/repl-minimal-architecture.md.

How it's tested

tests/cypress/e2e/repl/python-repl.feature — the same pattern as the JupyterLite session: drive the panel against a real interpreter, assert the materials that come back, including the two merge invariants (derived material never inherits its source _id; selection survives a scope replacement). Passing locally in 52 s.

Notes for review

  • Wheels that don't build under Pyodide (pymatgen, spglib, pydantic) are downloaded to public/repl-wheels (gitignored) on prestart/prebuild and served same-origin — browsers block cross-origin wheel fetches without CORS. Host apps embedding MD serve the same path or pass replWheelBaseUrl.
  • Pyodide loads with an explicit indexURL: the bundled node polyfills make its own asset detection resolve to a filesystem path (the e2e caught this against cove's PyodideLoader).
  • Supersedes feature/SOF-7961 Feat: Material REPL [AI-written] #279, which review found too large; this is step v1 of the ladder in the memo.

🤖 Generated with Claude Code

A drawer running mat3ra.made.tools in-browser via Pyodide. Materials bind in
as materials_in/material before each run; Material variables sync back after,
merged by materialsSyncScope: round-tripped ids upsert in place, REPL-created
materials replace the previous python-repl batch, everything else untouched.

One repo, no new npm dependencies: the editor and drawer come from published
cove, the environment recipe is one constants file mirroring AX's made
profile, and the host bridge is ~20 lines of inline Python pending a released
notebooks-utils. Wheels that do not build under Pyodide are provisioned to
public/repl-wheels on prestart/prebuild and served same-origin.

Pyodide loads with an explicit indexURL: the bundled node polyfills make its
own asset detection resolve to a filesystem path (caught by the e2e).

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@netlify

netlify Bot commented Aug 24, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for mat3ra-materials-designer ready!

Name Link
🔨 Latest commit d203a5f
🔍 Latest deploy log https://app.netlify.com/projects/mat3ra-materials-designer/deploys/6a9e23b6b730170008f19344
😎 Deploy Preview https://deploy-preview-294--mat3ra-materials-designer.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

VsevolodX and others added 2 commits August 24, 2026 13:33
Each interim solution now carries a TODO(repl-vN) naming where it moves and
what deletes it, anchored to the ladder in agents/plan/, so nothing temporary
can outlive its step unnoticed. grep -rn "TODO(repl-" src scripts lists them.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The REPL panel becomes an iframe of github.com/mat3ra/pyodide-repl, driven
over the same data bridge as the JupyterLite session: get-data answers with
{materials, selectedIndex}, set-data payloads route into materialsSyncScope,
which is unchanged. All Pyodide and Python concerns leave this repo — the
environment, the wheels and their provisioning script, and the dead
PythonTransformation dialog (the last consumer of cove's PyodideLoader).

The e2e keeps the same assertions, driving the embedded page cross-origin
like the JupyterLite specs; tagged @ignore in CI until a shared deploy
exists to embed. Verified locally against a vite preview of the built page:
46 s to a passing run.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@VsevolodX
VsevolodX force-pushed the feature/SOF-7961-v1 branch from c35e0be to d86f4d5 Compare August 28, 2026 03:51
The REPL page knows no domain: everything material-specific now travels to
it as configuration over the bridge — the package lists, the Python that
binds materials_in/material from this app's data, and the scan that produces
the {syncScope, entities} payload the reducer merges. It lives in
madeReplConfig and reaches the panel as a prop, so a host can swap it.

Wheels come straight from the JupyterLite deploy that already hosts them
(it sends access-control-allow-origin: *), so nothing in this stack
provisions or serves wheels any more.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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