### Open example notebook Source: https://github.com/marimo-team/marimo/blob/main/docs/integrations/motherduck.md Command to launch the official marimo MotherDuck example notebook. ```bash marimo edit https://github.com/marimo-team/marimo/blob/main/examples/sql/connect_to_motherduck.py ``` -------------------------------- ### Run Google Cloud Storage Example Source: https://github.com/marimo-team/marimo/blob/main/docs/integrations/google_cloud_storage.md Provides instructions on how to run a full example of Google Cloud Storage integration with Marimo, either by providing a URL to the example script or by downloading and running it locally. ```bash marimo run https://raw.githubusercontent.com/marimo-team/marimo/main/examples/cloud/gcp/google_cloud_storage.py ``` -------------------------------- ### Run Polars Example Notebook (Bash) Source: https://github.com/marimo-team/marimo/blob/main/docs/guides/working_with_data/dataframes.md Open a remote Marimo notebook that demonstrates Polars integration. This command requires the marimo CLI to be installed. ```bash marimo edit https://raw.githubusercontent.com/marimo-team/marimo/main/examples/third_party/polars/polars_example.py ``` -------------------------------- ### Install Marimo and Run Tutorial Source: https://github.com/marimo-team/marimo/blob/main/README.md Use this command to install marimo via pip and immediately run the introductory tutorial. ```bash pip install marimo && marimo tutorial intro ``` -------------------------------- ### Install Tracing Dependencies Source: https://github.com/marimo-team/marimo/blob/main/development_docs/traces.md Install the 'otel' extra to enable tracing functionality. This is also included in a development install. ```bash pip install "marimo[otel]" ``` -------------------------------- ### Run marimo Example Notebook Source: https://github.com/marimo-team/marimo/blob/main/docs/integrations/google_cloud_bigquery.md Execute a pre-built marimo notebook example for BigQuery directly from the remote repository. ```bash marimo run https://raw.githubusercontent.com/marimo-team/marimo/main/examples/cloud/gcp/google_cloud_bigquery.py ``` -------------------------------- ### Setup Marimo Import Source: https://github.com/marimo-team/marimo/blob/main/tests/_convert/ipynb/snapshots/complex_file_format_top_down.ipynb.txt Initializes the Marimo environment by importing the library. This is a standard setup step for any Marimo application. ```python # Complex file format with setup cell import marimo as mo ``` -------------------------------- ### Quick Setup for Marimo Development Source: https://github.com/marimo-team/marimo/blob/main/AGENTS.md Run these commands for a quick setup of the marimo development environment. Refer to CONTRIBUTING.md for more detailed options. ```bash make fe && make py make dev ``` -------------------------------- ### Initialize Library Project with Marimo Examples Source: https://github.com/marimo-team/marimo/blob/main/docs/guides/package_management/notebooks_in_projects.md Bash commands to set up a Python library project, add Marimo as a dev dependency, create a sandbox example notebook, and add the library as an editable dependency to the notebook. ```bash # Initialize the project uv init --lib my-library && cd my-library # Add marimo as development dependency uv add --dev marimo # Create a sandbox notebook mkdir examples uv run marimo edit --sandbox examples/quickstart.py # Add your library as editable dependency uv add --script examples/quickstart.py . --editable ``` -------------------------------- ### Install kubectl-marimo CLI Plugin Source: https://github.com/marimo-team/marimo/blob/main/docs/guides/deploying/deploying_kubernetes.md Installs the kubectl-marimo CLI plugin, which simplifies deploying Marimo notebooks from local files. It can be installed using 'uv' (recommended) or 'pip'. ```bash # With uv (recommended) uv tool install kubectl-marimo # Or with pip pip install kubectl-marimo ``` -------------------------------- ### Live Example: Selectable DataFrame Table Source: https://github.com/marimo-team/marimo/blob/main/docs/guides/working_with_data/dataframes.md A live example demonstrating a multi-selectable Pandas DataFrame table in Marimo. ```python @app.cell def __(): import pandas as pd df = pd.DataFrame({"a": [1, 2, 3], "b": [4, 5, 6]}) table = mo.ui.table(df, selection="multi") table return ``` ```python @app.cell def __(): table.value return ``` -------------------------------- ### Create a setup cell for notebook imports Source: https://github.com/marimo-team/marimo/blob/main/docs/guides/reusing_functions.md Illustrates how to create a setup cell in a Marimo notebook to manage imports required by top-level functions and classes. The setup cell ensures these imports are available before other cells are executed, adhering to the criteria for reusable code. ```python import numpy as np ``` -------------------------------- ### Install marimo with uv Source: https://github.com/marimo-team/marimo/blob/main/docs/index.md Installs marimo using the uv package manager and runs the tutorial. uv is a fast Python package installer and resolver. ```bash uv add marimo && uv run marimo tutorial intro ``` -------------------------------- ### Install Optional Dependencies Source: https://github.com/marimo-team/marimo/blob/main/docs/getting_started/quickstart.md Commands to install recommended dependencies for advanced features like SQL cells, charts, and AI completion. ```bash # Using pip pip install "marimo[recommended]" # Using uv uv add "marimo[recommended]" # Using conda conda install -c conda-forge marimo duckdb altair polars openai ruff ``` -------------------------------- ### Print Hello World in Marimo Source: https://github.com/marimo-team/marimo/blob/main/docs/guides/editor_features/watching.md A basic example of printing output in a marimo notebook. ```python print("Hello World!") ``` -------------------------------- ### Run Google Sheets Example Source: https://github.com/marimo-team/marimo/blob/main/docs/integrations/google_sheets.md Executes a Marimo application that demonstrates Google Sheets integration. This command downloads and runs the example script. ```bash marimo run https://raw.githubusercontent.com/marimo-team/marimo/main/examples/cloud/gcp/google_sheets.py ``` -------------------------------- ### Using State with UI Elements (Todo List Example) Source: https://github.com/marimo-team/marimo/blob/main/docs/guides/state.md An example demonstrating the creation of a todo list using Marimo state to manage the list of tasks. ```APIDOC ## Using State with UI Elements: Todo List Example This example uses state to create a todo list. ### Setup ```python import marimo as mo from dataclasses import dataclass ``` ### Data Structure and State Initialization ```python @dataclass class Task: name: str done: bool = False get_tasks, set_tasks = mo.state([]) task_added, set_task_added = mo.state(False) ``` ### Note This snippet is incomplete and only shows the setup for the todo list example. Further code would be needed to define the UI for adding, viewing, and managing tasks. ``` -------------------------------- ### Install SQL Dependencies Source: https://github.com/marimo-team/marimo/blob/main/tests/_convert/markdown/snapshots/sql.md.txt Install the necessary dependencies for SQL support in Marimo, including DuckDB. ```bash pip install 'marimo[sql]' ``` -------------------------------- ### Build and Serve Marimo Local Backend for Pyodide Source: https://github.com/marimo-team/marimo/blob/main/development_docs/pyodide.md These commands are used to run the Marimo frontend against a local backend. First, build the backend once. Then, start the server and watch for changes. Finally, in a separate terminal, navigate to the frontend directory and start the development server with Pyodide enabled. ```bash # build once uv build ``` ```bash # server and watch for changes uv run pyodide/build_and_serve.py ``` ```bash # in another terminal cd frontend PYODIDE=true pnpm dev ``` -------------------------------- ### Setup Cell Dependency Patterns Source: https://github.com/marimo-team/marimo/blob/main/docs/guides/lint_rules/rules/setup_cell_dependencies.md Demonstrates the invalid pattern of referencing external variables within a setup cell and the corrected approach where the setup cell defines its own variables for use by subsequent cells. ```python # Problematic setup cell # Setup cell y = x + 1 # Error: setup depends on other cells # Cell 1 x = 1 ``` ```python # Corrected setup cell # Setup cell y = 1 # Setup defines its own variables # Cell 1 x = y + 1 # Other cells can use setup variables ``` -------------------------------- ### Install and Configure Sage Source: https://github.com/marimo-team/marimo/blob/main/examples/third_party/sage/README.md Installs the Sage CLI tool and indexes a specific GitHub repository. Requires Ollama to be running with the llama3.1 model. ```bash ollama pull llama3.1 pipx install git+https://github.com/Storia-AI/sage.git@main export GITHUB_REPO=marimo-team/marimo sage-index $GITHUB_REPO ``` -------------------------------- ### Install marimo pair with uv Source: https://github.com/marimo-team/marimo/blob/main/docs/guides/generate_with_ai/marimo_pair.md Use this command to install the marimo pair agent skill via uv. ```bash uvx deno -A npm:skills add marimo-team/marimo-pair ``` -------------------------------- ### Installing Sandboxed Home Dependencies (Bash) Source: https://github.com/marimo-team/marimo/blob/main/docs/guides/editor_features/home.md Command to install the necessary packages for Sandboxed Home, including `pyzmq` for inter-process communication and `uv` for environment management. ```bash uv add 'marimo[sandbox]' ``` -------------------------------- ### Install Marimo and Dependencies with UV Source: https://github.com/marimo-team/marimo/blob/main/docs/guides/package_management/using_uv.md This snippet demonstrates how to set up a Python virtual environment and install Marimo and the numpy library using the UV package manager. It also shows how to launch the Marimo editor, enabling Python code execution within the notebook environment. ```console $ uv venv $ uv pip install numpy $ uv pip install marimo $ uv run marimo edit ``` -------------------------------- ### Local Development with Editable Installs Source: https://github.com/marimo-team/marimo/blob/main/docs/guides/package_management/inlining_dependencies.md Configure local package development by specifying an editable install source in the script metadata. ```python # /// script # requires-python = ">=3.11" # dependencies = [ # "my-package", # ] # # [tool.uv.sources] # my-package = { path = "../", editable = true } # /// ``` -------------------------------- ### Using State with UI Elements (Tied Elements Example) Source: https://github.com/marimo-team/marimo/blob/main/docs/guides/state.md An example demonstrating how to tie two different UI elements together so that their values are interdependent, which is only possible using Marimo state. ```APIDOC ## Using State with UI Elements: Tied Elements Example This example shows how to tie two different UI elements so that each one's value depends on the other. This is impossible to do without `mo.state`. ### Setup ```python import marimo as mo ``` ### State Initialization ```python get_x, set_x = mo.state(0) ``` ### UI Element: Slider ```python x = mo.ui.slider( 0, 10, value=get_x(), on_change=set_x, label="$x$:") ``` ### UI Element: Number Input ```python x_plus_one = mo.ui.number( 1, 11, value=get_x() + 1, on_change=lambda v: set_x(v - 1), label="$x + 1$:") ``` ### Layout ```python [x, x_plus_one] ``` ### Important Considerations - Create tied UI elements in separate cells. - Be careful not to introduce infinite loops when creating cycles at runtime. ``` -------------------------------- ### Create a 'setup' cell for imports Source: https://github.com/marimo-team/marimo/blob/main/marimo/_server/ai/skills/marimo-pair/references/notebook-improvements.md Use `ctx.create_cell` to define a 'setup' cell for module imports. This cell is automatically positioned at the beginning of the notebook and runs before all other cells. It must be self-contained and cannot reference variables from other cells. ```python cid = ctx.create_cell('''import polars as pl import marimo as mo import anywidget import traitlets''', name="setup") ctx.run_cell(cid) ``` -------------------------------- ### Install VegaFusion for Transformations Source: https://github.com/marimo-team/marimo/blob/main/docs/guides/working_with_data/plotting.md Provides the installation commands for VegaFusion, which is required to support data transformations like filtering and aggregation in Marimo's reactive plots. ```bash pip install "vegafusion[embed]>=1.4.0" conda install -c conda-forge "vegafusion-python-embed>=1.4.0" "vegafusion>=1.4.0" ``` -------------------------------- ### Populate Marimo Form with Predefined Examples Source: https://github.com/marimo-team/marimo/blob/main/docs/recipes.md Demonstrates how to populate a Marimo form with predefined example data, useful for illustrating complex API requests or database queries. The form can be populated from URL query parameters as well. ```python import marimo as mo ``` ```python examples = mo.ui.dropdown( options={ "ex 1": {"t1": "hello", "t2": "world"}, "ex 2": {"t1": "marimo", "t2": "notebook"}, }, value="ex 1", label="examples", ) ``` ```python form = ( mo.md( """ ### Your form {t1} {t2} """ ) .batch( t1=mo.ui.text(label="enter text", value=examples.value.get("t1", "")), t2=mo.ui.text(label="more text", value=examples.value.get("t2", "")), ) .form( submit_button_label="go" ) ) ``` ```python output = ( " ".join(form.value.values()).upper() if form.value is not None else " ".join(examples.value.values()).upper() ) examples, form, output ``` -------------------------------- ### Run Button Example in Marimo Source: https://github.com/marimo-team/marimo/blob/main/docs/_static/CLAUDE.md Demonstrates the usage of `mo.ui.run_button` to create buttons that trigger actions. This example shows two buttons, and the output indicates which button was clicked. ```python @app.cell def _(): import marimo as mo return ``` ```python @app.cell def _(): first_button = mo.ui.run_button(label="Option 1") second_button = mo.ui.run_button(label="Option 2") [first_button, second_button] return ``` ```python @app.cell def _(): if first_button.value: print("You chose option 1!") elif second_button.value: print("You chose option 2!") else: print("Click a button!") return ``` -------------------------------- ### Pair with a local notebook Source: https://github.com/marimo-team/marimo/blob/main/docs/guides/generate_with_ai/marimo_pair.md Paste this command into your agent CLI to start pairing with a local marimo notebook. ```bash /marimo-pair pair with me on my_notebook.py ``` -------------------------------- ### Display DuckDB Installation Status Source: https://github.com/marimo-team/marimo/blob/main/tests/_convert/markdown/snapshots/sql.md.txt Conditionally displays a tip or a warning message based on whether DuckDB is installed. This helps users understand their current setup. ```python if has_duckdb_installed: mo.output.replace( mo.md( """ /// Tip | "Installed" If you see this, DuckDB is already installed. /// """ ) ) else: mo.output.replace( mo.md( """ /// Warning | "Not Installed" If you see this, DuckDB is not installed. /// """ ) ) ``` -------------------------------- ### Launch SQL Tutorial Source: https://github.com/marimo-team/marimo/blob/main/docs/guides/working_with_data/sql.md Command-line instruction to launch the interactive SQL tutorial within the marimo environment. ```bash marimo tutorial sql ``` -------------------------------- ### Define a function with setup cell dependencies in Marimo Source: https://github.com/marimo-team/marimo/blob/main/docs/guides/reusing_functions.md Provides an example of defining a function within a Marimo notebook that utilizes imports from a setup cell. The function `calculate_statistics` uses `numpy` to compute statistics, demonstrating how to create reusable functions that depend on setup imports. ```python with app.setup: import numpy as np @app.function def calculate_statistics(data): """Calculate basic statistics for a dataset""" return { "mean": np.mean(data), "median": np.median(data), "std": np.std(data) } ``` -------------------------------- ### Custom Fonts Setup Source: https://github.com/marimo-team/marimo/blob/main/docs/guides/configuration/html_head.md Link to Google Fonts to use custom fonts in your notebook. This example includes preconnect directives for performance. ```html ``` -------------------------------- ### Pull and List Ollama Models Source: https://github.com/marimo-team/marimo/blob/main/docs/guides/configuration/llm_providers.md Install and manage LLM models locally using Ollama. Ensure models are pulled before starting the server. ```bash ollama pull llama3.1 ollama pull codellama # recommended for code generation # View your installed models ollama ls ``` -------------------------------- ### Run Marimo Tutorial Source: https://github.com/marimo-team/marimo/blob/main/tests/_convert/markdown/snapshots/dataflow.md.txt Command to launch the Marimo UI tutorial. ```bash marimo tutorial ui ``` -------------------------------- ### Basic WebAssembly Notebook Cell Source: https://github.com/marimo-team/marimo/blob/main/docs/guides/wasm.md This is a minimal example of a cell within a WebAssembly notebook. It demonstrates the basic structure and requires no external setup beyond the marimo environment. ```python @app.cell async def __(): return ``` -------------------------------- ### Marimo Development Workflow with Watch Source: https://github.com/marimo-team/marimo/blob/main/docs/guides/editor_features/watching.md A multi-terminal setup for developing WebAssembly notebooks. It involves starting a watched edit session, exporting to HTML-WASM with watching, and serving the WASM application. ```bash # in one terminal, start a watched edit (or run) session marimo edit notebook.py --watch ``` ```bash # in another terminal marimo export html-wasm notebook.py -o output_dir --watch ``` ```bash # in a third terminal, serve the WASM application cd path/to/output_dir python -m http.server # or a server that watches for changes ``` -------------------------------- ### Sandbox Notebook PEP 723 Metadata Source: https://github.com/marimo-team/marimo/blob/main/docs/guides/package_management/notebooks_in_projects.md Example PEP 723 metadata header for a sandbox notebook. It specifies Python version, dependencies, and local package sources for editable installs. ```python # /// script # requires-python = ">=3.11" dependencies = [ "my-package", "pandas", "matplotlib", ] [tool.uv.sources] my-package = { path = "../", editable = true } # /// ``` -------------------------------- ### List Marimo Tutorials Source: https://github.com/marimo-team/marimo/blob/main/README.md View available Marimo tutorials by running the tutorial command with the --help flag. ```bash marimo tutorial --help ``` -------------------------------- ### Marimo UI Slider Example (Python) Source: https://github.com/marimo-team/marimo/blob/main/tests/_cli/snapshots/export/script/script_sandboxed.txt Demonstrates the creation of a UI slider element using the marimo library. This slider can be used to control numerical input within a Marimo application. It requires the 'marimo' library to be installed. ```python import marimo as mo slider = mo.ui.slider(0, 10) ``` -------------------------------- ### Run Marimo Dataflow Tutorial Source: https://github.com/marimo-team/marimo/blob/main/docs/getting_started/key_concepts.md This command-line instruction launches the marimo dataflow tutorial, which helps users understand how data flows through their notebooks. It's a practical way to learn about marimo's reactive execution model. ```bash marimo tutorial dataflow ``` -------------------------------- ### Use Marimo Container in Dockerfile Source: https://github.com/marimo-team/marimo/blob/main/docs/guides/deploying/prebuilt_containers.md This Dockerfile snippet demonstrates how to use a Marimo prebuilt container as a base image for your own application. It specifies the Marimo container, allows for additional dependency installation, and sets the default command to start the Marimo server in edit mode, accessible on port 8080. ```dockerfile FROM ghcr.io/marimo-team/marimo:latest-sql # Install any additional dependencies here CMD ["marimo", "edit", "--no-token", "-p", "8080", "--host", "0.0.0.0"] ``` -------------------------------- ### Initialize and configure a uv project Source: https://github.com/marimo-team/marimo/blob/main/docs/guides/package_management/using_uv.md Commands to create a new uv project directory and add marimo as a dependency to the project's pyproject.toml file. ```console uv init hello-world cd hello-world uv add marimo ``` -------------------------------- ### Setup Cell Dependency Violation Source: https://github.com/marimo-team/marimo/blob/main/tests/_lint/snapshots/setup_dependencies_errors.txt Demonstrates a violation of the MR003 rule where a setup cell attempts to reference variables defined outside of the setup block. Setup cells must be independent to ensure proper execution order. ```python with app.setup: y = x + 1 # This triggers MR003: setup cell cannot have dependencies ``` -------------------------------- ### Initialize and Run a Marimo Application Source: https://github.com/marimo-team/marimo/blob/main/tests/_convert/snapshots/basic_marimo_example_roundtrip.py.txt Demonstrates how to instantiate a marimo App object with custom metadata and define an execution entry point. This structure allows the notebook to be run as a standalone script. ```python import marimo app = marimo.App(width="medium", app_title="Test Notebook") @app.cell def _(): x = 1 return (x,) if __name__ == "__main__": app.run() ``` -------------------------------- ### Install Marimo Source: https://github.com/marimo-team/marimo/blob/main/README.md Install Marimo using pip or conda. For additional features like SQL cells and AI completion, install with the 'recommended' extra. ```bash pip install marimo # or conda install -c conda-forge marimo marimo tutorial intro ``` ```bash pip install "marimo[recommended]" ``` -------------------------------- ### Manage marimo Tutorials Source: https://github.com/marimo-team/marimo/blob/main/docs/getting_started/quickstart.md Commands to access and list available marimo tutorials to help users learn the platform features. ```bash marimo tutorial intro marimo tutorial --help ``` -------------------------------- ### Check for DuckDB Installation Source: https://github.com/marimo-team/marimo/blob/main/tests/_convert/markdown/snapshots/sql.md.txt This Python code checks if the DuckDB library is installed and sets a flag accordingly. It's used to conditionally display messages about installation status. ```python has_duckdb_installed = False try: import duckdb has_duckdb_installed = True except ImportError: pass has_polars_installed = False try: import polars has_polars_installed = True except ImportError: pass has_pandas_installed = False try: import pandas has_pandas_installed = True except ImportError: pass ``` -------------------------------- ### Initialize Search Infrastructure with Docker Source: https://github.com/marimo-team/marimo/blob/main/examples/third_party/sage/README.md Sets up the Marqo vector search engine container required for Sage to index and search codebase content. This command pulls the latest image and maps the necessary ports. ```bash docker rm -f marqo docker pull marqoai/marqo:latest docker run --name marqo -it -p 8882:8882 marqoai/marqo:latest ``` -------------------------------- ### Install Marimo with Jupyter Extension (Bash) Source: https://github.com/marimo-team/marimo/blob/main/docs/guides/deploying/jupyterhub.md Installs the Marimo package with sandbox support and the Jupyter extension using uv pip. This command is suitable for single-environment installations. ```bash uv pip install 'marimo[sandbox]>=0.19.11' marimo-jupyter-extension ``` -------------------------------- ### Activating Virtual Environment for Single Notebook (Bash) Source: https://github.com/marimo-team/marimo/blob/main/docs/guides/editor_features/home.md Example of activating a virtual environment before running Marimo for a single notebook, when not using Sandboxed Home. ```bash source path/to/venv/bin/activate marimo edit notebook.py ``` -------------------------------- ### Initialize and Run Marimo App Source: https://github.com/marimo-team/marimo/blob/main/tests/_convert/markdown/snapshots/frontmatter-only.py.txt This snippet demonstrates how to import the marimo library, instantiate an App object with a title, and execute the application using the standard entry point pattern. ```python import marimo __generated_with = "0.0.0" app = marimo.App(app_title="My Title") if __name__ == "__main__": app.run() ``` -------------------------------- ### Marimo UI Tabs Component Usage Source: https://github.com/marimo-team/marimo/blob/main/docs/api/inputs/tabs.md This snippet shows how to define and display tabs using the `marimo.ui.tabs` component. It allows organizing content into different sections accessible via tabs. The component takes a list of `(label, content)` tuples, where `label` is the tab title and `content` is the UI element or Marimo object to display within that tab. This example assumes a Python environment where Marimo is installed. ```python import marimo as mo tabs = mo.ui.tabs({ "Tab 1": mo.md("# Content for Tab 1"), "Tab 2": mo.ui.slider(0, 10, label="Slider in Tab 2"), "Tab 3": mo.hstack([ mo.ui.text("Input in Tab 3:"), mo.ui.input(label="Text Input") ]) }) tabs ``` -------------------------------- ### Initialize Marimo and Render Markdown Source: https://github.com/marimo-team/marimo/blob/main/tests/_cli/snapshots/export/ipynb/ipynb.txt Demonstrates how to import the marimo library and render both static and parameterized markdown strings. This is essential for creating interactive documentation or reports within a marimo notebook. ```python import marimo as mo # Render static markdown mo.md("markdown") # Render parameterized markdown mo.md(f"parameterized markdown {123}") ``` -------------------------------- ### Initialize Marimo App Source: https://github.com/marimo-team/marimo/blob/main/tests/_cli/snapshots/converted_markdown.py.txt Sets up a new Marimo application instance. This is the foundational step for creating any Marimo-based interactive application. ```python import marimo app = marimo.App() ``` -------------------------------- ### Marimo App Setup and Run (Python) Source: https://github.com/marimo-team/marimo/blob/main/tests/_cli/snapshots/converted_juv.py.txt This snippet demonstrates how to initialize a Marimo application, define cells, and run the app. It includes a section for specifying project dependencies like 'anywidget' and 'polars'. The code defines a simple app with one cell and includes the standard Python entry point for execution. ```python # /// script # dependencies = [ # "anywidget", # "polars", # ] # /// import marimo app = marimo.App() @app.cell def _(): return if __name__ == "__main__": app.run() ``` -------------------------------- ### Install Python Packages with %pip Source: https://github.com/marimo-team/marimo/blob/main/tests/_convert/ipynb/fixtures/ipynb/pip_commands.ipynb Installs Python packages using the `%pip` magic command, which is often preferred for package management within IPython-based environments like Marimo. This command ensures packages are installed into the current environment. ```python %pip install requests ``` -------------------------------- ### Import micropip for package installation Source: https://github.com/marimo-team/marimo/blob/main/docs/guides/wasm.md Import the micropip module to manage package installations within the WASM environment. ```python import micropip ``` -------------------------------- ### Download CLAUDE.md configuration Source: https://github.com/marimo-team/marimo/blob/main/docs/guides/generate_with_ai/prompts.md Command to fetch the recommended starting context file for AI agents to better understand the marimo environment. ```console curl https://docs.marimo.io/CLAUDE.md > CLAUDE.md ``` -------------------------------- ### Install Google Sheets Packages Source: https://github.com/marimo-team/marimo/blob/main/docs/integrations/google_sheets.md Installs the required Python packages, `gspread` and `oauth2client`, for interacting with Google Sheets. ```bash pip install gspread oauth2client ``` -------------------------------- ### Install marimo pair with npm Source: https://github.com/marimo-team/marimo/blob/main/docs/guides/generate_with_ai/marimo_pair.md Use this command to install the marimo pair agent skill via npm. ```bash npx skills add marimo-team/marimo-pair ``` -------------------------------- ### Start Ollama Server Source: https://github.com/marimo-team/marimo/blob/main/docs/guides/configuration/llm_providers.md Start the Ollama server to serve local LLMs. This command should be run in a separate terminal. ```bash ollama serve ``` -------------------------------- ### Initialize and Run Marimo App Source: https://github.com/marimo-team/marimo/blob/main/tests/_cli/snapshots/ipynb_to_marimo_with_output.txt This snippet demonstrates how to instantiate a marimo.App object, define a reactive cell, and execute the application using the standard entry point pattern. ```python import marimo app = marimo.App() @app.cell def _(): print('Hello, Output!') return if __name__ == "__main__": app.run() ``` -------------------------------- ### Initialize and Run a Marimo Application Source: https://github.com/marimo-team/marimo/blob/main/tests/_convert/snapshots/simple_script.py.txt Demonstrates how to import the marimo library, instantiate an application object, and define a cell containing a function to calculate the area of a circle. The script concludes with a standard entry point to execute the application. ```python import marimo __generated_with = "0.0.0" app = marimo.App() @app.cell def _(): """A simple script.""" import math def calculate_area(radius): return math.pi * radius ** 2 print(calculate_area(5)) return if __name__ == "__main__": app.run() ``` -------------------------------- ### Marimo notebook with simple-parsing for command-line arguments Source: https://github.com/marimo-team/marimo/blob/main/docs/guides/scripts.md This example shows how to use the `simple-parsing` library in a marimo notebook to manage command-line arguments when executed as a script, providing default values for interactive use. ```python import marimo as mo from simple_parsing import ArgumentParser # Define a data class for arguments class Args: message: str = "Hello" count: int = 1 parser = ArgumentParser() parser.add_arguments(Args, dest="args") # If running as a script, parse arguments from sys.argv[1:] # If running interactively, use default values. # simple-parsing handles this automatically when called without arguments # or with an empty list, it uses defaults. parsed_args = parser.parse_args() message = parsed_args.args.message count = parsed_args.args.count mo.md(f"## Command-line arguments received:") mo.write(f"Message: {message}") mo.write(f"Count: {count}") # Example of using the arguments for _ in range(count): print(message) ``` -------------------------------- ### Install BigQuery Dependencies Source: https://github.com/marimo-team/marimo/blob/main/docs/integrations/google_cloud_bigquery.md Install the necessary Python packages for BigQuery connectivity and data type handling using pip. ```bash pip install google-cloud-bigquery db-dtypes ``` -------------------------------- ### Install marimo with conda Source: https://github.com/marimo-team/marimo/blob/main/docs/index.md Installs marimo from the conda-forge channel and launches the tutorial. This is suitable for users managing environments with Conda. ```bash conda install -c conda-forge marimo && marimo tutorial intro ``` -------------------------------- ### POST /instantiate_notebook Source: https://github.com/marimo-team/marimo/blob/main/tests/_internal/snapshots/internal_api.txt Initializes a new notebook session instance. ```APIDOC ## POST /instantiate_notebook ### Description Instantiates a new notebook session based on the provided configuration. ### Method POST ### Endpoint /instantiate_notebook ``` -------------------------------- ### Install and Configure Claude Code Agent Source: https://github.com/marimo-team/marimo/blob/main/docs/guides/editor_features/agents.md Commands to install the Claude Code CLI globally and initiate the login process. ```bash npm install -g @anthropic-ai/claude-code claude # Then type /login ``` -------------------------------- ### Execute Notebooks with Package Dependencies Source: https://github.com/marimo-team/marimo/blob/main/docs/guides/package_management/importing_packages.md Shows how to run or edit notebooks that rely on installed packages, including using uv for environment management. ```console uv run --with marimo marimo edit notebooks/my_notebook.py ``` -------------------------------- ### Inline Script Metadata Example Source: https://github.com/marimo-team/marimo/blob/main/docs/guides/package_management/inlining_dependencies.md This is an example of inline script metadata used to specify Python version and dependencies for a notebook. ```python # /// script # requires-python = ">=3.11" # dependencies = [ # "pandas==", # "altair==", # ] # /// ``` -------------------------------- ### Markdown Notebook Frontmatter Example Source: https://github.com/marimo-team/marimo/blob/main/docs/guides/editor_features/watching.md Example of frontmatter metadata in a Marimo Markdown notebook, including title, marimo-version, and description. ```markdown --- title: My Notebook marimo-version: 0.0.0 description: A notebook with a description --- ``` -------------------------------- ### Initialize Marimo and UI Components Source: https://github.com/marimo-team/marimo/blob/main/frontend/islands/__demo__/output.html This snippet demonstrates how to import the marimo library, display markdown text, and create an interactive slider component. ```python import marimo as mo # Display markdown text mo.md('Hello, islands!') # Create an interactive slider slider = mo.ui.slider(0, 100, 2) slider ``` -------------------------------- ### Query and Visualize BigQuery Data in marimo Source: https://github.com/marimo-team/marimo/blob/main/docs/integrations/google_cloud_bigquery.md A multi-cell example demonstrating how to initialize a BigQuery client, list datasets and tables via marimo UI dropdowns, and display results in a data table. ```python import marimo as mo from google.cloud import bigquery client = bigquery.Client() datasets = list(client.list_datasets()) selected_dataset = mo.ui.dropdown( label="Select dataset", options=[d.dataset_id for d in datasets] ) selected_dataset dataset = client.dataset(selected_dataset.value) tables = list(client.list_tables(dataset)) selected_table = mo.ui.dropdown( label="Select table", options=[t.table_id for t in tables] ) selected_table results = client.list_rows(dataset.table(selected_table.value), max_results=10) mo.ui.table(results.to_dataframe(), selection=None) ``` -------------------------------- ### Install Pre-commit Hooks Source: https://github.com/marimo-team/marimo/blob/main/CONTRIBUTING.md Install pre-commit hooks to automatically run validation checks before each commit. This helps maintain code quality. ```bash uvx pre-commit install ```