From 93e8fbcff69f08a6b610d9fdc17d57754054cf75 Mon Sep 17 00:00:00 2001 From: Joey LeGrand Date: Sun, 9 Nov 2025 17:28:14 +0000 Subject: [PATCH 1/2] Add marimo container --- docker-compose.yml | 17 ++++++++++++++++- marimo/Dockerfile | 19 +++++++++++++++++++ marimo/marimo.toml | 15 +++++++++++++++ 3 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 marimo/Dockerfile create mode 100644 marimo/marimo.toml diff --git a/docker-compose.yml b/docker-compose.yml index ea0240d..54e35d7 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,7 +1,7 @@ x-airflow-common: &airflow-common build: context: ./airflow - image: sagerx_airflow:v0.0.7 # versioning allows a rebuild of docker image where necessary + image: sagerx_airflow:v0.0.2718 # versioning allows a rebuild of docker image where necessary networks: - airflow-dbt-network env_file: @@ -50,6 +50,21 @@ services: context: . shm_size: "4gb" + marimo: + build: + context: ./marimo + image: sagerx_marimo:v0.0.1 + networks: + - airflow-dbt-network + container_name: marimo + ports: + - "2718:2718" + volumes: + - ./notebooks:/notebooks + working_dir: /notebooks + environment: + - DATABASE_URL=postgresql://sagerx:sagerx@postgres:5432/sagerx + pgadmin: image: dpage/pgadmin4:9.9 networks: diff --git a/marimo/Dockerfile b/marimo/Dockerfile new file mode 100644 index 0000000..c8d11b0 --- /dev/null +++ b/marimo/Dockerfile @@ -0,0 +1,19 @@ +FROM python:3.11-slim + +# Install marimo and database dependencies +RUN pip install --no-cache-dir \ + marimo \ + psycopg2-binary \ + sqlalchemy \ + pandas \ + numpy + +# Create marimo config directory +RUN mkdir -p /root/.marimo + +# Copy the marimo configuration +COPY marimo.toml /root/.config/marimo/marimo.toml + +WORKDIR /notebooks + +CMD ["marimo", "edit", "--host", "0.0.0.0", "--port", "2718", "--no-token"] \ No newline at end of file diff --git a/marimo/marimo.toml b/marimo/marimo.toml new file mode 100644 index 0000000..9c0d1a8 --- /dev/null +++ b/marimo/marimo.toml @@ -0,0 +1,15 @@ +[display] +theme = "dark" + +[datasources] +auto_discover_schemas = true +auto_discover_tables = true +auto_discover_columns = true + +[datasources.sources.postgres] +dialect = "postgresql" +host = "postgres" +port = 5432 +database = "sagerx" +username = "sagerx" +password = "sagerx" From a3b72b9b5b4f678757a4da4b3e1ecd8ab41e0d46 Mon Sep 17 00:00:00 2001 From: Joseph LeGrand Date: Mon, 10 Nov 2025 21:15:12 -0600 Subject: [PATCH 2/2] Add template for Marimo application with SQL query --- notebooks/template.py | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 notebooks/template.py diff --git a/notebooks/template.py b/notebooks/template.py new file mode 100644 index 0000000..de19705 --- /dev/null +++ b/notebooks/template.py @@ -0,0 +1,39 @@ +import marimo + +__generated_with = "0.17.7" +app = marimo.App(width="medium") + + +@app.cell +def _(): + import os + import sqlalchemy + + DATABASE_URL = os.environ.get("DATABASE_URL") + sagerx = sqlalchemy.create_engine(DATABASE_URL) + return (sagerx,) + + +@app.cell +def _(): + import marimo as mo + return (mo,) + + +@app.cell +def _(mo, sagerx): + _df = mo.sql( + f""" + select + * + from sagerx_dev.stg_fda_ndc__ndcs + limit 100 + + """, + engine=sagerx + ) + return + + +if __name__ == "__main__": + app.run()