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
feat: add 'marimo config show' CLI command (#1513)
Myles Scolnickcaa39df03d96
diff --git a/.github/workflows/test_cli.yaml b/.github/workflows/test_cli.yamlindex 16113b91e1..e644d2a194 100644--- a/.github/workflows/test_cli.yaml+++ b/.github/workflows/test_cli.yaml@@ -41,6 +41,8 @@ jobs:- name: 📦 Build frontendrun: make fe+ env:+ NODE_OPTIONS: "--max_old_space_size=8192"- name: 🐍 Setup Python 3.10uses: actions/setup-python@v5diff --git a/frontend/src/components/editor/renderers/vertical-layout/vertical-layout.tsx b/frontend/src/components/editor/renderers/vertical-layout/vertical-layout.tsxindex 13f3f8cf8c..bd7aff5166 100644--- a/frontend/src/components/editor/renderers/vertical-layout/vertical-layout.tsx+++ b/frontend/src/components/editor/renderers/vertical-layout/vertical-layout.tsx@@ -28,7 +28,6 @@ import {DropdownMenuTrigger,} from "@/components/ui/dropdown-menu";import { downloadHTMLAsImage } from "@/utils/download";-import { useFilename } from "@/core/saving/filename";import { downloadAsHTML } from "@/core/static/download-html";type VerticalLayout = null;diff --git a/marimo/_cli/cli.py b/marimo/_cli/cli.pyindex d0c0cc90f1..cbb6bb1ea7 100644--- a/marimo/_cli/cli.py+++ b/marimo/_cli/cli.py@@ -12,6 +12,7 @@ import clickimport marimo._cli.cli_validators as validatorsfrom marimo import __version__, _loggersfrom marimo._ast import codegen+from marimo._cli.config.commands import configfrom marimo._cli.convert.commands import convertfrom marimo._cli.envinfo import get_system_infofrom marimo._cli.export.commands import export@@ -601,3 +602,4 @@ def env() -> None:main.command()(convert)main.add_command(export)+main.add_command(config)diff --git a/marimo/_cli/config/commands.py b/marimo/_cli/config/commands.pynew file mode 100644index 0000000000..a7d52f22b6--- /dev/null+++ b/marimo/_cli/config/commands.py@@ -0,0 +1,31 @@+# Copyright 2024 Marimo. All rights reserved.+from __future__ import annotations++import click+import tomlkit++from marimo._cli.config.utils import highlight_toml_headers+from marimo._cli.print import green+from marimo._config.manager import UserConfigManager++[email protected](help="""Various commands for the marimo config.""")+def config() -> None:+ pass++[email protected](help="""Show the marimo config""")+def show() -> None:+ """+ Print out marimo config information.+ Example usage:++ marimo config show+ """+ config_manager = UserConfigManager()+ click.echo(f"User config from {green(config_manager.get_config_path())}\n")+ toml_string = tomlkit.dumps(config_manager.get_config())+ click.echo(highlight_toml_headers(toml_string))+++config.add_command(show)diff --git a/marimo/_cli/config/utils.py b/marimo/_cli/config/utils.pynew file mode 100644index 0000000000..c0d9d0b650--- /dev/null+++ b/marimo/_cli/config/utils.py@@ -0,0 +1,17 @@+from __future__ import annotations++from marimo._cli.print import orange+++def highlight_toml_headers(toml_string: str) -> str:+ lines = toml_string.splitlines()+ highlighted_lines: list[str] = []++ for line in lines:+ stripped_line = line.strip()+ if stripped_line.startswith("[") and stripped_line.endswith("]"):+ highlighted_lines.append(orange(line))+ else:+ highlighted_lines.append(line)++ return "\n".join(highlighted_lines)diff --git a/marimo/_config/manager.py b/marimo/_config/manager.pyindex 1392f72c3b..becaf81c5d 100644--- a/marimo/_config/manager.py+++ b/marimo/_config/manager.py@@ -23,7 +23,7 @@ class UserConfigManager:def save_config(self, config: MarimoConfig) -> MarimoConfig:import tomlkit- config_path = self._get_config_path()+ config_path = self.get_config_path()LOGGER.debug("Saving user configuration to %s", config_path)# Remove the secret placeholders from the incoming configconfig = remove_secret_placeholders(config)@@ -41,7 +41,7 @@ class UserConfigManager:return mask_secrets(self.config)return self.config- def _get_config_path(self) -> str:+ def get_config_path(self) -> str:return get_config_path() or self._default_config_path()def _default_config_path(self) -> str:diff --git a/scripts/buildfrontend.sh b/scripts/buildfrontend.shindex e923018731..3455834815 100755--- a/scripts/buildfrontend.sh+++ b/scripts/buildfrontend.sh@@ -20,4 +20,5 @@ if $cmd; thenecho "Compilation succeeded.\n"elseecho "Frontend compilation failed.\n"+ exit 1fidiff --git a/tests/_cli/test_cli_config.py b/tests/_cli/test_cli_config.pynew file mode 100644index 0000000000..ae8a18a43e--- /dev/null+++ b/tests/_cli/test_cli_config.py@@ -0,0 +1,15 @@+# Copyright 2024 Marimo. All rights reserved.+from __future__ import annotations++import subprocess+++def test_config_show() -> None:+ p = subprocess.run(+ ["marimo", "config", "show"],+ capture_output=True,+ )+ assert p.returncode == 0, p.stderr.decode()+ output = p.stdout.decode()+ assert "User config from" in output+ assert "[formatting]" in output