Skip to content

A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.

fix: respect auto-instantiate while in wasm (#1378)

Myles Scolnick43e9ddb8acad
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index d2b07bc104..21a4287edd 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -182,10 +182,12 @@ _OR_
pnpm build:watch
```
-For the backend, you can start marimo in development mode with
+For the backend, we recommend running without auth (`--no-token`):
```bash
-marimo -d edit
+marimo edit --no-token
+# or in debug mode
+marimo -d edit --no-token
```
- **When to run with hot-reloading?**: When you are developing on the frontend
diff --git a/frontend/e2e-tests/kitchen-sink-wasm.spec.ts b/frontend/e2e-tests/kitchen-sink-wasm.spec.ts
index ddc1991f3f..ee0c929ac9 100644
--- a/frontend/e2e-tests/kitchen-sink-wasm.spec.ts
+++ b/frontend/e2e-tests/kitchen-sink-wasm.spec.ts
@@ -5,7 +5,7 @@ import { fileURLToPath } from "node:url";
const __filename = fileURLToPath(import.meta.url);
-test("can screenshot and download as html edit", async ({ page }) => {
+test.skip("can screenshot and download as html edit", async ({ page }) => {
await page.goto("http://localhost:3000");
// See text Initializing
@@ -17,7 +17,7 @@ test("can screenshot and download as html edit", async ({ page }) => {
await exportAsHTMLAndTakeScreenshot(page);
});
-test("can screenshot and download as html in run", async ({ page }) => {
+test.skip("can screenshot and download as html in run", async ({ page }) => {
await page.goto("http://localhost:3000?mode=read");
// See text Initializing
diff --git a/frontend/playwright.config.ts b/frontend/playwright.config.ts
index 88a600a422..b1dcc87265 100644
--- a/frontend/playwright.config.ts
+++ b/frontend/playwright.config.ts
@@ -192,7 +192,7 @@ const config: PlaywrightTestConfig = {
url: getUrl(EDIT_PORT),
reuseExistingServer: false,
},
- WASM_SERVER,
+ // WASM_SERVER,
],
};
diff --git a/frontend/src/core/edit-app.tsx b/frontend/src/core/edit-app.tsx
index 61477c3b08..3f49499424 100644
--- a/frontend/src/core/edit-app.tsx
+++ b/frontend/src/core/edit-app.tsx
@@ -90,8 +90,7 @@ export const EditApp: React.FC<AppProps> = ({ userConfig, appConfig }) => {
}, []);
const { connection } = useMarimoWebSocket({
- autoInstantiate:
- userConfig.runtime.auto_instantiate || viewState.mode === "read",
+ autoInstantiate: userConfig.runtime.auto_instantiate,
setCells: (cells, layout) => {
setCells(cells);
const names = cells.map((cell) => cell.name);
diff --git a/frontend/src/core/pyodide/worker/bootstrap.ts b/frontend/src/core/pyodide/worker/bootstrap.ts
index 7c723fb3a8..8779ef9f83 100644
--- a/frontend/src/core/pyodide/worker/bootstrap.ts
+++ b/frontend/src/core/pyodide/worker/bootstrap.ts
@@ -151,8 +151,9 @@ export class DefaultWasmController implements WasmController {
user_config=js.user_config.to_py(),
)
- def init():
- instantiate(session)
+ def init(auto_instantiate=True):
+ if auto_instantiate:
+ instantiate(session)
asyncio.create_task(session.start())
bridge, init`,
@@ -170,7 +171,7 @@ export class DefaultWasmController implements WasmController {
})
.then(() => {
loadSpan.end();
- init();
+ init(userConfig.runtime.auto_instantiate);
});
return bridge;
diff --git a/frontend/vite.config.mts b/frontend/vite.config.mts
index 7a767b1530..615e7af720 100644
--- a/frontend/vite.config.mts
+++ b/frontend/vite.config.mts
@@ -26,7 +26,15 @@ const htmlDevPlugin = (): Plugin => {
: "edit";
html = html.replace("{{ base_url }}", "");
html = html.replace("{{ title }}", "marimo");
- html = html.replace("{{ user_config }}", JSON.stringify({}));
+ html = html.replace(
+ "{{ user_config }}",
+ JSON.stringify({
+ // Add/remove user config here while developing
+ // runtime: {
+ // auto_instantiate: false,
+ // },
+ }),
+ );
html = html.replace("{{ app_config }}", JSON.stringify({}));
html = html.replace("{{ server_token }}", "");
if (process.env.VITE_MARIMO_VERSION) {
@@ -49,6 +57,17 @@ const htmlDevPlugin = (): Plugin => {
const serverDoc = new JSDOM(serverHtml).window.document;
const devDoc = new JSDOM(html).window.document;
+ // Login page
+ if (!serverHtml.includes("marimo-mode") && serverHtml.includes("login")) {
+ return `
+ <html>
+ <body>
+ In development mode, please run the server without authentication: <code style="color: red;">marimo run --no-auth</code>
+ </body>
+ </html>
+ `;
+ }
+
// copies these elements from server to dev
const copyElements = [
"base",
@@ -96,6 +115,10 @@ export default defineConfig({
target: TARGET,
changeOrigin: true,
},
+ "/auth": {
+ target: TARGET,
+ changeOrigin: true,
+ },
"/@file": {
target: TARGET,
changeOrigin: true,
diff --git a/marimo/_server/api/endpoints/login.py b/marimo/_server/api/endpoints/login.py
index 60ae38025f..53516e1506 100644
--- a/marimo/_server/api/endpoints/login.py
+++ b/marimo/_server/api/endpoints/login.py
@@ -24,7 +24,7 @@ LOGIN_PAGE = """
<html lang="en">
<head>
<meta charset="UTF-8">
-<title>Login Page</title>
+<title>marimo</title>
</head>
<body style="
background-color: #f4f4f9;