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
update: refresh plugin to allow 100ms (#837)
Myles Scolnick93a2ab5cf6b7
diff --git a/frontend/src/plugins/impl/RefreshPlugin.tsx b/frontend/src/plugins/impl/RefreshPlugin.tsxindex de66e82364..4029859d20 100644--- a/frontend/src/plugins/impl/RefreshPlugin.tsx+++ b/frontend/src/plugins/impl/RefreshPlugin.tsx@@ -29,13 +29,15 @@ interface Data {label?: string | null;}+const MIN_INTERVAL = 0.1;+const zodTimestring = z.string().superRefine((s, ctx) => {try {const seconds = timestring(s);- if (seconds < 1) {+ if (seconds < MIN_INTERVAL) {ctx.addIssue({code: z.ZodIssueCode.custom,- message: "Must be greater than 1 second.",+ message: `Must be greater than ${MIN_INTERVAL} seconds.`,});}return;@@ -52,8 +54,12 @@ export class RefreshPlugin implements IPlugin<Value, Data> {tagName = "marimo-refresh";validator = z.object({- options: z.array(z.union([zodTimestring, z.number().min(1)])).default([]),- defaultInterval: z.union([zodTimestring, z.number().min(1)]).optional(),+ options: z+ .array(z.union([zodTimestring, z.number().min(MIN_INTERVAL)]))+ .default([]),+ defaultInterval: z+ .union([zodTimestring, z.number().min(MIN_INTERVAL)])+ .optional(),label: z.string().nullable(),});diff --git a/marimo/_plugins/ui/_impl/refresh.py b/marimo/_plugins/ui/_impl/refresh.pyindex 15a924bdcf..f2470e4e23 100644--- a/marimo/_plugins/ui/_impl/refresh.py+++ b/marimo/_plugins/ui/_impl/refresh.py@@ -18,6 +18,12 @@ class refresh(UIElement[int, int]):You can also combine multiple time units (e.g. "1m 30s").+ Note: The refresh interval may not be exact, as it depends on the+ time it takes to render the content and the time it takes to send+ the content to the client. Also, due to the buffering of UI element+ changes, if the downstream cells take a long time to render, the+ refresh interval may be longer than expected.+**Example.**```pythondiff --git a/marimo/_smoke_tests/refresh.py b/marimo/_smoke_tests/refresh.pyindex 3bdca36895..dae7f10138 100644--- a/marimo/_smoke_tests/refresh.py+++ b/marimo/_smoke_tests/refresh.py@@ -1,7 +1,8 @@# Copyright 2024 Marimo. All rights reserved.+import marimo-__generated_with = "0.1.1"+__generated_with = "0.2.8"app = marimo.App()@@ -29,7 +30,7 @@ def __(mo, random, reset_button):@app.celldef __(mo):- refresh = mo.ui.refresh(options=["1s", "10s", "1m"])+ refresh = mo.ui.refresh(options=["1s", "10s", "1m", "100ms"])mo.md(f"Choose an interval to guess {refresh}")return refresh,