-
Notifications
You must be signed in to change notification settings - Fork 316
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
allow --global-session for marimo run #2489
base: main
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
this is great! the direction looks right - could we verify with some e2e tests? some examples:
could you also help update |
@@ -661,6 +661,7 @@ def __init__( | |||
cli_args: SerializedCLIArgs, | |||
auth_token: Optional[AuthToken], | |||
redirect_console_to_browser: bool = False, | |||
global_session: bool = False, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe we can rename to global_session_in_run_mode
or something similar. it is verbose, but this could be confused that edit mode also as global session configuration
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah certainly, any name that makes sense is good for me :)
I looked at the e2e tests, and it seems the edit test does this by checking presence of the message banner: test("can resume a session", async ({ page }) => {
const appUrl = getAppUrl("shutdown.py");
await page.goto(appUrl);
await expect(page.getByText("None", { exact: true })).toBeVisible();
// type in the form
await page.locator("#output-Hbol").getByRole("textbox").fill("12345");
// shift enter to run the form
await page.keyboard.press("Meta+Enter");
// wait for the output to appear
let secondCell = await page.locator(".Cell").nth(1);
await expect(secondCell.getByText("12345")).toBeVisible();
await expect(secondCell.getByText("54321")).toBeVisible();
// Refresh the page
await page.reload();
await expect(
page.getByText("You have reconnected to an existing session."),
).toBeVisible();
secondCell = await page.locator(".Cell").nth(1);
await expect(page.getByText("12345")).toBeVisible();
await expect(page.getByText("54321")).toBeVisible();
}); My PR doesn't display such banner, so I guess I have to add that same banner to make sure we can run a similar test |
sorry i mispoke, you can just add the tests to the python side. our e2e tests with playright are a bit finicky and flakey so we don't keep those updated. |
Ok, I'm currently checking out the Python tests, how they work etc |
@mscolnick I looked into the test_ws.py, I see how my test would fit there, but I'm struggling to understand where the server is launched, is there some place where the tests are initated? |
@peterwilli - an marimo server is not launched in those tests, but rather we use the starlette TestClient https://www.starlette.io/testclient/ |
@peterwilli, can we help unblock you? |
📝 Summary
I encountered this use-case here: #2488
When doing large computations running entirely locally, especially with non-coder users, it is often important to be able to resume the session when the browser refreshes, or tabs wake up from sleep, especially when loading large files into memory.
In my case, a customer has refreshed their browser, causing a large model to load in memory twice. We don't run marimo on a server but locally, so there's no need for unique sessions.
This feature lets you add
--global-session
to yourmarimo run
command, sharing the session even when refreshing, asserting the same session behaviour asmarimo edit
.For the rest, default behaviour stays, so after this PR, everyone still gets unique sessions in
marimo run
, except if they provide the argument.This is a living PR, and certainly not perfect yet - I assume that we have to add some e2e tests, but I'm not familiar enough to make this work yet, and need some guidance.
🔍 Description of Changes
📋 Checklist
📜 Reviewers
@akshayka OR @mscolnick