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" 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()