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
improvement: enable markdown support in the fe by default (#1391)
Myles Scolnick4a4889391639
diff --git a/frontend/e2e-tests/helper.ts b/frontend/e2e-tests/helper.tsindex e0e27097e2..d0a0b345cb 100644--- a/frontend/e2e-tests/helper.ts+++ b/frontend/e2e-tests/helper.ts@@ -171,7 +171,6 @@ export async function maybeRestartKernel(page: Page) {await page.getByTestId("notebook-menu-dropdown").click();await page.getByText("Restart kernel", { exact: true }).click();await page.getByText("Restart", { exact: true }).click();- await page.waitForTimeout(1000);}/**diff --git a/frontend/e2e-tests/mode.spec.ts b/frontend/e2e-tests/mode.spec.tsindex 3059148c23..80aa697188 100644--- a/frontend/e2e-tests/mode.spec.ts+++ b/frontend/e2e-tests/mode.spec.ts@@ -1,14 +1,38 @@/* Copyright 2024 Marimo. All rights reserved. */-import { test, expect } from "@playwright/test";-import { getAppUrl } from "../playwright.config";-import { takeScreenshot } from "./helper";+import { test, expect, Page, BrowserContext } from "@playwright/test";+import { ApplicationNames, getAppMode, getAppUrl } from "../playwright.config";+import { maybeRestartKernel, takeScreenshot } from "./helper";import { fileURLToPath } from "node:url";const __filename = fileURLToPath(import.meta.url);-test("page renders edit feature in edit mode", async ({ page }) => {- const appUrl = getAppUrl("title.py");- await page.goto(appUrl);+async function gotoPage(+ app: ApplicationNames,+ page: Page,+ context: BrowserContext,+) {+ const url = getAppUrl(app);+ const mode = getAppMode(app);++ await page.goto(url);++ // Verify is has loaded+ if (mode === "edit") {+ await maybeRestartKernel(page);+ }+}++// Re-use page for all tests+let page: Page;+test.beforeAll(async ({ browser }) => {+ page = await browser.newPage();+});+test.afterAll(async () => {+ await page.close();+});++test("page renders edit feature in edit mode", async ({ context }) => {+ await gotoPage("title.py", page, context);// 'title.py' to be in the document.expect(await page.getByText("title.py").count()).toBeGreaterThan(0);@@ -22,9 +46,8 @@ test("page renders edit feature in edit mode", async ({ page }) => {await takeScreenshot(page, __filename);});-test.skip("can bring up the find/replace dialog", async ({ page }) => {- const appUrl = getAppUrl("title.py");- await page.goto(appUrl);+test.skip("can bring up the find/replace dialog", async ({ context }) => {+ await gotoPage("title.py", page, context);// Wait for the cells to loadawait expect(page.locator("h1").getByText("Hello Marimo!")).toBeVisible();@@ -39,9 +62,8 @@ test.skip("can bring up the find/replace dialog", async ({ page }) => {await takeScreenshot(page, __filename);});-test("can toggle to presenter mode", async ({ page }) => {- const appUrl = getAppUrl("title.py");- await page.goto(appUrl);+test("can toggle to presenter mode", async ({ context }) => {+ await gotoPage("title.py", page, context);// Can see output and codeawait expect(page.locator("h1").getByText("Hello Marimo!")).toBeVisible();@@ -65,9 +87,8 @@ test("can toggle to presenter mode", async ({ page }) => {await takeScreenshot(page, __filename);});-test("page renders read only view in read mode", async ({ page }) => {- const appUrl = getAppUrl("components.py");- await page.goto(appUrl);+test("page renders read only view in read mode", async ({ context }) => {+ await gotoPage("components.py", page, context);// Filename is not visibleawait expect(page.getByText("components.py").last()).not.toBeVisible();diff --git a/frontend/playwright.config.ts b/frontend/playwright.config.tsindex b1dcc87265..d3882aa8e6 100644--- a/frontend/playwright.config.ts+++ b/frontend/playwright.config.ts@@ -71,6 +71,13 @@ export function getAppUrl(app: ApplicationNames): string {}return getUrl(options.port, options.baseUrl);}+export function getAppMode(app: ApplicationNames): "edit" | "run" {+ const options: ServerOptions = appToOptions[app];+ if (!options) {+ throw new Error(`No server options for app: ${app}`);+ }+ return options.command;+}// Reset file via git checkoutexport async function resetFile(app: ApplicationNames): Promise<void> {diff --git a/frontend/src/components/pages/home-page.tsx b/frontend/src/components/pages/home-page.tsxindex bc93cffa2b..9699fb1d6a 100644--- a/frontend/src/components/pages/home-page.tsx+++ b/frontend/src/components/pages/home-page.tsx@@ -29,7 +29,6 @@ import { ConfigButton } from "../app-config/app-config-button";import { Checkbox } from "@/components/ui/checkbox";import { Label } from "@/components/ui/label";import { MarkdownIcon } from "@/components/editor/cell/code/icons";-import { getFeatureFlag } from "@/core/config/feature-flag";function tabTarget(path: string) {// Consistent tab target so we open in the same tab when clicking on the same notebook@@ -115,7 +114,6 @@ const HomePage: React.FC = () => {<NotebookListheader="All notebooks"control={- getFeatureFlag("markdown") && (<div className="flex items-center gap-2">{fileResponse.loading && <Spinner size="small" />}<Checkbox@@ -128,7 +126,6 @@ const HomePage: React.FC = () => {/><Label htmlFor="include-markdown">Include markdown</Label></div>- )}files={workspace.files}runningNotebooks={runningNotebooks}diff --git a/frontend/src/core/config/feature-flag.ts b/frontend/src/core/config/feature-flag.tsindex 99ec77d8cf..b06c23f083 100644--- a/frontend/src/core/config/feature-flag.ts+++ b/frontend/src/core/config/feature-flag.ts@@ -12,7 +12,7 @@ export interface ExperimentalFeatures {}const defaultValues: ExperimentalFeatures = {- markdown: import.meta.env.DEV,+ markdown: true,};export function getFeatureFlag<T extends keyof ExperimentalFeatures>(diff --git a/tests/_server/api/endpoints/test_resume_session.py b/tests/_server/api/endpoints/test_resume_session.pyindex 44e4935d73..1a93c171a5 100644--- a/tests/_server/api/endpoints/test_resume_session.py+++ b/tests/_server/api/endpoints/test_resume_session.py@@ -236,11 +236,13 @@ def test_restart_session(client: TestClient) -> None:data = websocket.receive_json()assert_kernel_ready_response(data, create_response({}))- # Send save request- client.post(+ # Restart the session+ response = client.post("/api/kernel/restart_session",headers=headers("123"),)+ assert response.status_code == 200, response.text+ assert response.json() == {"success": True}# Check the session still exists after closing the websocketassert not get_session(client, "123")