A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.
Python artificial-intelligencedagdata-sciencedata-visualizationdataflowdeveloper-toolsmachine-learningnotebookspipelinepythonreactivesqlweb-app
chore: format/lint dagger dir (#2548)
Myles Scolnick44cc67e16e00
diff --git a/dagger/README.md b/dagger/README.mdnew file mode 100644index 0000000000..3826cb590f--- /dev/null+++ b/dagger/README.md@@ -0,0 +1,19 @@+# Dagger++This directory contains Dagger scripts for building and testing marimo in a+containerized environment. This allows for running tests and builds in an+environment that is similar to CI.++To run a Dagger script, you need to have the Dagger CLI installed. You can install+it by following the instructions [here](https://docs.dagger.io/install).++To run a Dagger script, you can use the following command:++```bash+dagger functions # see what functions are available in the module+dagger call make <any make task> # run make task in a dev environment+dagger call frontend test # run frontend tests+dagger call backend test # run backend tests+# run frontend tests on a remote pull request+dagger call --src https://github.com/marimo-team/marimo\#pull/2542/head frontend test+```diff --git a/dagger/src/main/__init__.py b/dagger/src/main/__init__.pyindex 4f608590ec..628253650d 100644--- a/dagger/src/main/__init__.py+++ b/dagger/src/main/__init__.py@@ -1,3 +1,5 @@-"""A module for Marimo functions-"""+"""A module for Marimo functions"""+from .main import Marimo++__all__ = ["Marimo"]diff --git a/dagger/src/main/backend.py b/dagger/src/main/backend.pyindex 923761fa55..df5bea604e 100644--- a/dagger/src/main/backend.py+++ b/dagger/src/main/backend.py@@ -1,20 +1,23 @@from typing import Annotatedimport dagger-from dagger import DefaultPath, Doc, Ignore, dag, field, function, object_type+from dagger import Doc, field, function, object_typefrom .env import Env@object_typeclass Backend:- src: Annotated[dagger.Directory, Doc("The marimo source tree to use")] = field()+ src: Annotated[dagger.Directory, Doc("The marimo source tree to use")] = (+ field()+ )@functiondef test(self) -> dagger.Container:return (# python base- Env().py()+ Env()+ .py().with_directory("/src", self.src).with_workdir("/src").with_exec(["make", "py"])diff --git a/dagger/src/main/cli.py b/dagger/src/main/cli.pyindex 5a8a883919..18c77dc6d3 100644--- a/dagger/src/main/cli.py+++ b/dagger/src/main/cli.py@@ -6,7 +6,12 @@ from dagger import DefaultPath, Doc, Ignore, dag, field, function, object_type@object_typeclass Cli:- src: Annotated[dagger.Directory, Doc("The marimo source tree to use"), DefaultPath("/"), Ignore(["/dagger", ".venv"])] = field()+ src: Annotated[+ dagger.Directory,+ Doc("The marimo source tree to use"),+ DefaultPath("/"),+ Ignore(["/dagger", ".venv"]),+ ] = field()@functiondef test(self) -> dagger.Container:diff --git a/dagger/src/main/env.py b/dagger/src/main/env.pyindex c4a674b3bc..6045d2d50a 100644--- a/dagger/src/main/env.py+++ b/dagger/src/main/env.py@@ -1,5 +1,5 @@import dagger-from dagger import DefaultPath, dag, function, object_type+from dagger import dag, function, object_type@object_type@@ -10,15 +10,23 @@ class Env:return (# python baseself.py()- .with_mounted_cache("/root/.local/share/pnpm", dag.cache_volume("pnpm"))+ .with_mounted_cache(+ "/root/.local/share/pnpm", dag.cache_volume("pnpm")+ )# package deps.with_exec(["apt", "update"]).with_exec(["apt", "install", "-y", "curl"])# install node 20+- .with_exec(["sh", "-c", "curl -fsSL https://deb.nodesource.com/setup_20.x | bash -"])+ .with_exec(+ [+ "sh",+ "-c",+ "curl -fsSL https://deb.nodesource.com/setup_20.x | bash -", # noqa: E501+ ]+ ).with_exec(["apt", "install", "-y", "nodejs"])- # install pnpm@8- .with_exec(["npm", "install", "-g", "pnpm@8"])+ # install pnpm@9+ .with_exec(["npm", "install", "-g", "pnpm@9"]).with_env_variable("NODE_OPTIONS", "--max-old-space-size=8192"))@@ -27,20 +35,35 @@ class Env:"""Python container with dependencies for the backend"""return (# python base- dag.container().from_("python:3.12-bookworm")- .with_mounted_cache("/root/.cache/pip", dag.cache_volume("python-312"))+ dag.container()+ .from_("python:3.12-bookworm")+ .with_mounted_cache(+ "/root/.cache/pip", dag.cache_volume("python-312")+ ).with_exec(["apt-get", "update"])- .with_exec(["apt-get", "install", "-y", "make", "libgdal-dev", "python3-gdal"])+ .with_exec(+ [+ "apt-get",+ "install",+ "-y",+ "make",+ "libgdal-dev",+ "python3-gdal",+ ]+ ).with_exec(["pip", "install", "hatch", "typos"]))@functiondef pnpm(self) -> dagger.Container:- """Pnpm container with dependencies for the frontend"""+ """A pnpm container with dependencies for the frontend"""return (- dag.container().from_("node:20-slim")+ dag.container()+ .from_("node:20-slim").with_env_variable("CI", "true").with_env_variable("NODE_OPTIONS", "--max-old-space-size=8192")- .with_mounted_cache("/root/.local/share/pnpm", dag.cache_volume("pnpm"))- .with_exec(["corepack", "enable"]) # this enables pnpm+ .with_mounted_cache(+ "/root/.local/share/pnpm", dag.cache_volume("pnpm")+ )+ .with_exec(["corepack", "enable"]) # this enables pnpm)diff --git a/dagger/src/main/frontend.py b/dagger/src/main/frontend.pyindex 61289fa24c..0a87879979 100644--- a/dagger/src/main/frontend.py+++ b/dagger/src/main/frontend.py@@ -1,24 +1,30 @@from typing import Annotatedimport dagger-from dagger import DefaultPath, Doc, Ignore, dag, field, function, object_type+from dagger import Doc, dag, field, function, object_typefrom .env import Env@object_typeclass Frontend:- src: Annotated[dagger.Directory, Doc("The marimo source tree to use")] = field()+ src: Annotated[dagger.Directory, Doc("The marimo source tree to use")] = (+ field()+ )@function- def test(self, turbo_token: dagger.Secret = dag.set_secret("DEFAULT", "")) -> dagger.Container:+ def test(+ self,+ turbo_token: dagger.Secret = dag.set_secret("DEFAULT", ""), # noqa: B008+ ) -> dagger.Container:"""Replace .github/workflows/test_fe.yaml"""return (- Env().pnpm()+ Env()+ .pnpm().with_env_variable("MARIMO_SKIP_UPDATE_CHECK", "true")- .with_secret_variable("TURBO_TOKEN" , turbo_token)+ .with_secret_variable("TURBO_TOKEN", turbo_token).with_env_variable("TURBO_TEAM", "marimo").with_workdir("/src/frontend").with_directory("/src", self.src)diff --git a/dagger/src/main/main.py b/dagger/src/main/main.pyindex 7a012ddc13..b5c9a15d72 100644--- a/dagger/src/main/main.py+++ b/dagger/src/main/main.py@@ -1,7 +1,7 @@from typing import Annotatedimport dagger-from dagger import DefaultPath, Doc, Ignore, dag, field, function, object_type+from dagger import DefaultPath, Doc, Ignore, field, function, object_typefrom .backend import Backendfrom .cli import Cli@@ -12,7 +12,10 @@ from .frontend import Frontend@object_typeclass Marimo:"""A collection of tasks for the Marimo project."""- src: Annotated[dagger.Directory, Doc("The marimo source tree to use")] = field()++ src: Annotated[dagger.Directory, Doc("The marimo source tree to use")] = (+ field()+ )frontend: Annotated[Frontend, Doc("Frontend components")] = field()backend: Annotated[Backend, Doc("Backend components")] = field()cli: Annotated[Cli, Doc("CLI components")] = field()@@ -21,14 +24,19 @@ class Marimo:@classmethoddef create(cls,- src: Annotated[dagger.Directory, Doc("The marimo source tree to use"), DefaultPath("/"), Ignore(["**/dagger", "**/.venv"])],- ):+ src: Annotated[+ dagger.Directory,+ Doc("The marimo source tree to use"),+ DefaultPath("/"),+ Ignore(["**/dagger", "**/.venv"]),+ ],+ ) -> "Marimo":return cls(src=src,frontend=Frontend(src=src),backend=Backend(src=src),cli=Cli(src=src),- env=Env()+ env=Env(),)@function@@ -38,9 +46,9 @@ class Marimo:) -> dagger.Container:"""A container that runs a make task."""return (- self.env.dev().- with_directory("/src", self.src).- with_workdir("/src").- with_exec(["make", "install-all"]).- with_exec(["make", task])+ self.env.dev()+ .with_directory("/src", self.src)+ .with_workdir("/src")+ .with_exec(["make", "install-all"])+ .with_exec(["make", task]))diff --git a/pyproject.toml b/pyproject.tomlindex 99eec4000d..0c4797ce63 100644--- a/pyproject.toml+++ b/pyproject.toml@@ -261,8 +261,6 @@ extend-select = ["ANN202", # missing-return-type-private-function"ANN205", # missing-return-type-static-method"ANN206", # missing-return-type-class-method- # future annotations- "FA102",# isort"I001",# Enable entire ruff rule section@@ -300,6 +298,7 @@ unfixable = ["F401"][tool.ruff.lint.per-file-ignores]"**/{tests}/*" = ["ANN201", "ANN202"]+"dagger/*" = ["TID252"][tool.ruff.lint.isort]required-imports = ["from __future__ import annotations"]