Skip to content

Conversation

@ghukill
Copy link
Contributor

@ghukill ghukill commented Aug 26, 2025

Purpose and background context

This PR adds support for launching a notebook with a URL prefix. It was learned that requests coming from the ALB will likely have a URL request that we cannot control, but it's fairly trivial to just launch the notebook at a specific URL.

Either the CLI arg --base-url or the env var NOTEBOOK_BASE_URL will be set by the ECS service definition.

For local devlopment work, all behavior is default absence of a URL prefix; just host + port.

How can a reviewer manually see the effects of these changes?

Run a notebook with a custom prefix:

marimo-launcher run \
--repo https://github.com/MITLibraries/marimo-notebook-template \
--base-url /super/duper/fun/times

Output showing running notebook:

Running notebook.py ⚡

➜  URL: http://0.0.0.0:2718/super/duper/fun/times
➜  Network: http://192.168.1.144:2718/super/duper/fun/times

Includes new or updated dependencies?

YES

Changes expectations for external applications?

YES

What are the relevant tickets?

Why these changes are being introduced:

Based on the interplay of the ALB and the notebook running in an ECS
fargate container, we realized that we would need to launch the notebook on
a particular URL path.

Thankfully, Marimo supports this with a --base-url flag.

How this addresses that need:

* Adds --base-url / NOTEBOOK_BASE_URL configurations to explicitly set a
base url to launch on
* Adds flags + env vars to skip a base URL entirely
* If neither are passed, the default behavior is to construct a base URL
from the repository name + notebook path

Side effects of this change:
* This aligns with the URL patterns that ALB requests will send to the running
notebook.  By passing --repo https://github.com/foo/bar and --path super/notebook.py,
the resulting base URL will be "bar/super/notebook.py" which is precisely
what the ALB will send as requests

Relevant ticket(s):
* https://mitlibraries.atlassian.net/browse/IN-1441
@coveralls
Copy link

coveralls commented Aug 26, 2025

Pull Request Test Coverage Report for Build 17267450290

Details

  • 3 of 3 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.4%) to 88.119%

Totals Coverage Status
Change from base Build 17136136885: 0.4%
Covered Lines: 89
Relevant Lines: 101

💛 - Coveralls

Why these changes are being introduced:

We realized we could simplify this a bit at the infrastructure level
and *always* pass a base URL if needed.  This means we can simplify
this application to only apply a base URL when explicitly passed.

How this addresses that need:
* Removes any notion of "skipping" a base URL
* CLI arg / env var passes along an explicit base URL, or none is set

Side effects of this change:
* ALB + ECS service infra is responsible for knowing and setting the
base URL

Relevant ticket(s):
* https://mitlibraries.atlassian.net/browse/IN-1441
@ghukill ghukill marked this pull request as ready for review August 26, 2025 19:58
@ghukill ghukill requested a review from a team as a code owner August 26, 2025 19:58
Copy link

@ehanson8 ehanson8 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good and works as expected, my reviewing-by-commit process led me to an unnecessary question but there's one potential README.md update. Also, I had to use uv run marimo-launcher run rather than just marimo-launcher run since that ran an older version of the code without --base-url, not sure what happened there

run Launch notebook in 'run' or 'edit' mode.
```

### `launcher run`

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this need to be marimo-launcher run?

@ghukill ghukill merged commit e2107bf into main Aug 27, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants