Skip to content

Commit

Permalink
docs: update watching documentation (#3440)
Browse files Browse the repository at this point in the history
Also: fix a bug with autosave override not being respected by the
frontend.

For docs:

* Promote to a top-level nav item, and rename to "Using your own editor"
* Other small edits.

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Myles Scolnick <myles@marimo.io>
  • Loading branch information
3 people authored Jan 15, 2025
1 parent d51c247 commit 72fff11
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 17 deletions.
48 changes: 33 additions & 15 deletions docs/guides/editor_features/watching.md
Original file line number Diff line number Diff line change
@@ -1,29 +1,47 @@
# Watching notebooks
# Using your own editor

marimo's `--watch` flag enables a file watcher that automatically sync your
notebook file with the marimo editor or running application.

This allows you to edit your notebook file in the editor of your choice, and
have the changes automatically reflected in the running editor or application.
While we recommend using the [marimo editor](editor_features/index.md),
we understand that you may prefer to use your own editor. marimo provides a
`--watch` flag that watches your notebook file for changes, syncing them to
the marimo editor or running application. This lets you to edit your notebook
using an editor of your choice, like neovim, VSCode, Cursor, or PyCharm, and
have the changes automatically reflected in your browser.

!!! tip "Install watchdog for better file watching"
For better file watching performance, install watchdog with `pip install watchdog`. Without watchdog, marimo will poll for file changes which is less efficient.
For better performance, install [watchdog](https://pypi.org/project/watchdog/).
Without watchdog, marimo resorts to polling.

## `marimo edit --watch`

When you run `marimo edit` with the `--watch` flag, the marimo server
will open your notebook in the browser and watch the underlying notebook
file for changes. When you make changes to the notebook file, they will be
streamed to the marimo editor in the browser.

Synced code will not be executed automatically, with cells marked as stale instead.
Run all stale cells with the marimo editor's "Run" button, or the [`runStale`
hotkey](hotkeys.md), to see the new outputs.

!!! note "Cell signature and returns"
Don't worry about maintaining the signatures of cells and their return
values; marimo will handle this for you.

## `marimo run --watch`

When you run a notebook with the `--watch` flag, whenever the file watcher
detects a change to the notebook file, the application will be refreshed.
The browser will trigger a page refresh to ensure your notebook starts from a fresh state.

## `marimo watch --watch`
detects a change to the notebook file, the application will be refreshed. The
browser will trigger a page refresh to ensure your notebook starts from a fresh
state.

When you edit a notebook file with the `--watch` flag, whenever the file watcher
detects a change to the notebook file, the new cells and code changes will be streamed to
the browser editor.
## Watching for changes to other modules

This code will not be executed until you run the cell, and instead marked as stale.
marimo can also watch for changes to Python modules that your notebook imports,
letting you edit auxiliary Python files in your own editor as well. Learn how
to enable this feature in our [Module Autoreloading
Guide](module_autoreloading.md)

## Watching for data changes

!!! note
Support for watching data files and automatically refreshing cells that depend on them is coming soon. Follow along at <https://github.com/marimo-team/marimo/issues/3258>

2 changes: 1 addition & 1 deletion frontend/src/core/config/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export const hotkeysAtom = atom((get) => {
});

export const autoSaveConfigAtom = atom((get) => {
return get(userConfigAtom).save;
return get(resolvedMarimoConfigAtom).save;
});

/**
Expand Down
2 changes: 1 addition & 1 deletion mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ nav:
- AI completion: guides/editor_features/ai_completion.md
- Package management: guides/editor_features/package_management.md
- Module autoreloading: guides/editor_features/module_autoreloading.md
- Watching notebooks: guides/editor_features/watching.md
- Hotkeys: guides/editor_features/hotkeys.md
- Using your own editor: guides/editor_features/watching.md
- Run notebooks as apps: guides/apps.md
- Run notebooks as scripts: guides/scripts.md
- Test notebooks:
Expand Down

0 comments on commit 72fff11

Please sign in to comment.