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.
Python artificial-intelligencedagdata-sciencedata-visualizationdataflowdeveloper-toolsmachine-learningnotebookspipelinepythonreactivesqlweb-app
fix: prevent module reload in wasm (#2683)
Myles Scolnickdb05b882102b
diff --git a/frontend/src/components/editor/chrome/wrapper/footer.tsx b/frontend/src/components/editor/chrome/wrapper/footer.tsxindex 539183febb..ebafab7c38 100644--- a/frontend/src/components/editor/chrome/wrapper/footer.tsx+++ b/frontend/src/components/editor/chrome/wrapper/footer.tsx@@ -28,6 +28,7 @@ import {import { ChevronDownIcon } from "lucide-react";import { FooterItem } from "./footer-item";import { useHotkey } from "@/hooks/useHotkey";+import { isWasm } from "@/core/wasm/utils";export const Footer: React.FC = () => {const { selectedPanel, isTerminalOpen } = useChromeState();@@ -136,54 +137,62 @@ export const Footer: React.FC = () => {<div className="border-r border-border h-6 mx-1" />- <FooterItem tooltip={null} selected={false}>- <DropdownMenu>- <DropdownMenuTrigger className="font-prose text-sm flex items-center gap-1">- <span>on module change: </span>- {config.runtime.auto_reload === "off" && <PowerOffIcon size={14} />}- {config.runtime.auto_reload === "lazy" && <ZapOffIcon size={14} />}- {config.runtime.auto_reload === "autorun" && <ZapIcon size={14} />}- <span>{config.runtime.auto_reload}</span>- <ChevronDownIcon size={14} />- </DropdownMenuTrigger>- <DropdownMenuContent>- {["off", "lazy", "autorun"].map((option) => (- <DropdownMenuItem- key={option}- onClick={async () => {- const newConfig: UserConfig = {- ...config,- runtime: {- ...config.runtime,- auto_reload: option as "off" | "lazy" | "autorun",- },- };- await saveUserConfig({ config: newConfig }).then(() =>- setConfig(newConfig),- );- }}- >- {option === "off" && (- <PowerOffIcon- size={14}- className="mr-2 text-muted-foreground"- />- )}- {option === "lazy" && (- <ZapOffIcon- size={14}- className="mr-2 text-muted-foreground"- />- )}- {option === "autorun" && (- <ZapIcon size={14} className="mr-2 text-muted-foreground" />- )}- {option}- </DropdownMenuItem>- ))}- </DropdownMenuContent>- </DropdownMenu>- </FooterItem>+ {!isWasm() && (+ <FooterItem tooltip={null} selected={false}>+ <DropdownMenu>+ <DropdownMenuTrigger className="font-prose text-sm flex items-center gap-1">+ <span>on module change: </span>+ {config.runtime.auto_reload === "off" && (+ <PowerOffIcon size={14} />+ )}+ {config.runtime.auto_reload === "lazy" && (+ <ZapOffIcon size={14} />+ )}+ {config.runtime.auto_reload === "autorun" && (+ <ZapIcon size={14} />+ )}+ <span>{config.runtime.auto_reload}</span>+ <ChevronDownIcon size={14} />+ </DropdownMenuTrigger>+ <DropdownMenuContent>+ {["off", "lazy", "autorun"].map((option) => (+ <DropdownMenuItem+ key={option}+ onClick={async () => {+ const newConfig: UserConfig = {+ ...config,+ runtime: {+ ...config.runtime,+ auto_reload: option as "off" | "lazy" | "autorun",+ },+ };+ await saveUserConfig({ config: newConfig }).then(() =>+ setConfig(newConfig),+ );+ }}+ >+ {option === "off" && (+ <PowerOffIcon+ size={14}+ className="mr-2 text-muted-foreground"+ />+ )}+ {option === "lazy" && (+ <ZapOffIcon+ size={14}+ className="mr-2 text-muted-foreground"+ />+ )}+ {option === "autorun" && (+ <ZapIcon size={14} className="mr-2 text-muted-foreground" />+ )}+ {option}+ </DropdownMenuItem>+ ))}+ </DropdownMenuContent>+ </DropdownMenu>+ </FooterItem>+ )}<div className="mx-auto" />diff --git a/marimo/_runtime/runtime.py b/marimo/_runtime/runtime.pyindex 2c79e25f72..e79b400a4c 100644--- a/marimo/_runtime/runtime.py+++ b/marimo/_runtime/runtime.py@@ -469,6 +469,7 @@ class Kernel:package_manager = config["package_management"]["manager"]autoreload_mode = config["runtime"]["auto_reload"]self.reactive_execution_mode = config["runtime"]["on_cell_change"]+ self.user_config = configif (self.package_manager is None@@ -476,7 +477,10 @@ class Kernel:):self.package_manager = create_package_manager(package_manager)- if autoreload_mode == "lazy" or autoreload_mode == "autorun":+ if (+ autoreload_mode == "lazy" or autoreload_mode == "autorun"+ # Pyodide doesn't support hot module reloading+ ) and not is_pyodide():if self.module_reloader is None:self.module_reloader = ModuleReloader()@@ -501,8 +505,6 @@ class Kernel:self.module_watcher.stop()self.module_watcher = None- self.user_config = config-@propertydef globals(self) -> dict[Any, Any]:return self._module.__dict__