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
improvement: add Upgrade action to package manager UI (#5106)
Myles Scolnick18cbcc1d1a0f
diff --git a/examples/third_party/great_tables/great_tables_example.py b/examples/third_party/great_tables/great_tables_example.pyindex 768fa830f2..f44735d49b 100644--- a/examples/third_party/great_tables/great_tables_example.py+++ b/examples/third_party/great_tables/great_tables_example.py@@ -1,32 +1,32 @@# /// script# requires-python = ">=3.9"# dependencies = [-# "great-tables==0.11.1",+# "great-tables==0.17.0",# "marimo",-# "polars==1.8.2",+# "polars==1.30.0",# ]# ///import marimo-__generated_with = "0.8.19"+__generated_with = "0.13.13"app = marimo.App(width="medium")@app.cell(hide_code=True)-def __(mo):+def _(mo):mo.md(r"""- # [Great-tables](https://github.com/posit-dev/great-tables) + marimo+ # [Great-tables](https://github.com/posit-dev/great-tables) + marimo- Adapted from https://github.com/machow/coffee-sales-data- """+ Adapted from https://github.com/machow/coffee-sales-data+ """)return@app.cell-def __(__file__):+def _():import polars as plimport polars.selectors as csimport os@@ -38,17 +38,17 @@ def __(__file__):coffee_sales = pl.DataFrame.deserialize(Path(current_dir) / "coffee-sales.json", format="json")- return GT, Path, coffee_sales, cs, current_dir, loc, mo, os, pl, style+ return GT, coffee_sales, cs, loc, mo, pl, style@app.cell-def __(coffee_sales, mo):+def _(coffee_sales, mo):revenue = mo.ui.range_slider.from_series(coffee_sales["revenue_dollars"])return (revenue,)@app.cell(hide_code=True)-def __(mo, revenue):+def _(mo, revenue):mo.hstack([revenue, f"${revenue.value[0]:,.0f} - ${revenue.value[1]:,.0f}"]).left()@@ -56,18 +56,18 @@ def __(mo, revenue):@app.cell(hide_code=True)-def __(coffee_sales, revenue):+def _(coffee_sales, revenue):lower = revenue.value[0]upper = revenue.value[1]filterered_coffee_sales = coffee_sales.filter((coffee_sales["revenue_dollars"] >= lower)& (coffee_sales["revenue_dollars"] <= upper))- return filterered_coffee_sales, lower, upper+ return (filterered_coffee_sales,)@app.cell(hide_code=True)-def __(GT, cs, filterered_coffee_sales, loc, pl, style):+def _(GT, cs, filterered_coffee_sales, loc, pl, style):sel_rev = cs.starts_with("revenue")sel_prof = cs.starts_with("profit")@@ -111,7 +111,7 @@ def __(GT, cs, filterered_coffee_sales, loc, pl, style):)coffee_table- return coffee_table, sel_prof, sel_rev+ returnif __name__ == "__main__":diff --git a/frontend/src/components/editor/chrome/panels/packages-panel.tsx b/frontend/src/components/editor/chrome/panels/packages-panel.tsxindex 16fabca7b8..75ebd16863 100644--- a/frontend/src/components/editor/chrome/panels/packages-panel.tsx+++ b/frontend/src/components/editor/chrome/panels/packages-panel.tsx@@ -31,6 +31,110 @@ import { PACKAGES_INPUT_ID } from "./constants";import { useOpenSettingsToTab } from "@/components/app-config/state";import { packagesToInstallAtom } from "./packages-state";import { useAtomValue, useSetAtom } from "jotai";+import { isWasm } from "@/core/wasm/utils";++const showAddPackageToast = (packageName: string, error?: string | null) => {+ if (error) {+ toast({+ title: "Failed to add package",+ description: error,+ variant: "danger",+ });+ } else {+ toast({+ title: "Package added",+ description: (+ <div>+ <div>+ The package <Kbd className="inline">{packageName}</Kbd> and its+ dependencies has been added to your environment.+ </div>+ <div className="text-xs text-muted-foreground mt-1">+ Some Python packages may require a kernel restart to see changes.+ </div>+ </div>+ ),+ });+ }+};++const showUpgradePackageToast = (+ packageName: string,+ error?: string | null,+) => {+ if (error) {+ toast({+ title: "Failed to upgrade package",+ description: error,+ variant: "danger",+ });+ } else {+ toast({+ title: "Package upgraded",+ description: (+ <div>+ <div>+ The package <Kbd className="inline">{packageName}</Kbd> has been+ upgraded.+ </div>+ <div className="text-xs text-muted-foreground mt-1">+ Some Python packages may require a kernel restart to see changes.+ </div>+ </div>+ ),+ });+ }+};++const showRemovePackageToast = (packageName: string, error?: string | null) => {+ if (error) {+ toast({+ title: "Failed to remove package",+ description: error,+ variant: "danger",+ });+ } else {+ toast({+ title: "Package removed",+ description: (+ <div>+ <div>+ The package <Kbd className="inline">{packageName}</Kbd> has been+ removed from your environment.+ </div>+ <div className="text-xs text-muted-foreground mt-1">+ Some Python packages may require a kernel restart to see changes.+ </div>+ </div>+ ),+ });+ }+};++const PackageActionButton: React.FC<{+ onClick: () => void;+ loading: boolean;+ children: React.ReactNode;+ className?: string;+}> = ({ onClick, loading, children, className }) => {+ if (loading) {+ return <Spinner size="small" className="h-4 w-4 shrink-0 opacity-50" />;+ }++ return (+ <button+ type="button"+ className={cn(+ "px-2 h-full text-xs text-muted-foreground hover:text-foreground",+ "invisible group-hover:visible",+ className,+ )}+ onClick={Events.stopPropagation(onClick)}+ >+ {children}+ </button>+ );+};export const PackagesPanel: React.FC = () => {const [config] = useResolvedMarimoConfig();@@ -86,21 +190,9 @@ const InstallPackageForm: React.FC<{const response = await addPackage({ package: input });if (response.success) {onSuccess();- toast({- title: "Package added",- description: (- <span>- The package <Kbd className="inline">{input}</Kbd> and its- dependencies has been added to your environment.- </span>- ),- });+ showAddPackageToast(input);} else {- toast({- title: "Failed to add package",- description: response.error,- variant: "danger",- });+ showAddPackageToast(input, response.error);}} finally {setInput("");@@ -246,7 +338,8 @@ const PackagesList: React.FC<{><TableCell>{item.name}</TableCell><TableCell>{item.version}</TableCell>- <TableCell>+ <TableCell className="flex justify-end">+ <UpgradeButton packageName={item.name} onSuccess={onSuccess} /><RemoveButton packageName={item.name} onSuccess={onSuccess} /></TableCell></TableRow>@@ -256,6 +349,42 @@ const PackagesList: React.FC<{);};+const UpgradeButton: React.FC<{+ packageName: string;+ onSuccess: () => void;+}> = ({ packageName, onSuccess }) => {+ const [loading, setLoading] = React.useState(false);++ // Hide upgrade button in WASM+ if (isWasm()) {+ return null;+ }++ const handleUpgradePackage = async () => {+ try {+ setLoading(true);+ const response = await addPackage({+ package: packageName,+ upgrade: true,+ });+ if (response.success) {+ onSuccess();+ showUpgradePackageToast(packageName);+ } else {+ showUpgradePackageToast(packageName, response.error);+ }+ } finally {+ setLoading(false);+ }+ };++ return (+ <PackageActionButton onClick={handleUpgradePackage} loading={loading}>+ Upgrade+ </PackageActionButton>+ );+};+const RemoveButton: React.FC<{packageName: string;onSuccess: () => void;@@ -268,46 +397,18 @@ const RemoveButton: React.FC<{const response = await removePackage({ package: packageName });if (response.success) {onSuccess();- toast({- title: "Package removed",- description: (- <span>- The package <Kbd className="inline">{packageName}</Kbd> has been- removed from your environment.- </span>- ),- });+ showRemovePackageToast(packageName);} else {- toast({- title: "Failed to add package",- description: response.error,- variant: "danger",- });+ showRemovePackageToast(packageName, response.error);}} finally {setLoading(false);}};- if (loading) {- return (- <Spinner- size="small"- className="float-right mr-2 h-4 w-4 shrink-0 opacity-50"- />- );- }-return (- <button- type="button"- className={cn(- "float-right px-2 h-full text-xs text-muted-foreground hover:text-foreground",- "invisible group-hover:visible",- )}- onClick={Events.stopPropagation(handleRemovePackage)}- >+ <PackageActionButton onClick={handleRemovePackage} loading={loading}>Remove- </button>+ </PackageActionButton>);};diff --git a/marimo/_runtime/packages/conda_package_manager.py b/marimo/_runtime/packages/conda_package_manager.pyindex 2509933dda..e4bf8c6c9c 100644--- a/marimo/_runtime/packages/conda_package_manager.py+++ b/marimo/_runtime/packages/conda_package_manager.py@@ -22,8 +22,11 @@ class CondaPackageManager(CanonicalizingPackageManager):class PixiPackageManager(CondaPackageManager):name = "pixi"- async def _install(self, package: str) -> bool:- return self.run(["pixi", "add", *split_packages(package)])+ async def _install(self, package: str, *, upgrade: bool) -> bool:+ if upgrade:+ return self.run(["pixi", "upgrade", *split_packages(package)])+ else:+ return self.run(["pixi", "add", *split_packages(package)])async def uninstall(self, package: str) -> bool:return self.run(["pixi", "remove", *split_packages(package)])diff --git a/marimo/_runtime/packages/package_manager.py b/marimo/_runtime/packages/package_manager.pyindex 1f2740d26d..1969c56258 100644--- a/marimo/_runtime/packages/package_manager.py+++ b/marimo/_runtime/packages/package_manager.py@@ -50,17 +50,21 @@ class PackageManager(abc.ABC):return False@abc.abstractmethod- async def _install(self, package: str) -> bool:+ async def _install(self, package: str, *, upgrade: bool) -> bool:"""Installation logic."""...- async def install(self, package: str, version: Optional[str]) -> bool:+ async def install(+ self, package: str, version: Optional[str], upgrade: bool = False+ ) -> bool:"""Attempt to install a package that makes this module available.Returns True if installation succeeded, else False."""self._attempted_packages.add(package)- return await self._install(append_version(package, version))+ return await self._install(+ append_version(package, version), upgrade=upgrade+ )@abc.abstractmethodasync def uninstall(self, package: str) -> bool:@@ -92,6 +96,7 @@ class PackageManager(abc.ABC):packages_to_remove: Optional[list[str]] = None,import_namespaces_to_add: Optional[list[str]] = None,import_namespaces_to_remove: Optional[list[str]] = None,+ upgrade: bool,) -> None:del (filepath,@@ -99,6 +104,7 @@ class PackageManager(abc.ABC):packages_to_remove,import_namespaces_to_add,import_namespaces_to_remove,+ upgrade,)"""Add or remove inline script metadata metadatadiff --git a/marimo/_runtime/packages/pypi_package_manager.py b/marimo/_runtime/packages/pypi_package_manager.pyindex 98393ce69b..ce9100bacd 100644--- a/marimo/_runtime/packages/pypi_package_manager.py+++ b/marimo/_runtime/packages/pypi_package_manager.py@@ -52,11 +52,13 @@ class PipPackageManager(PypiPackageManager):name = "pip"docs_url = "https://pip.pypa.io/"- async def _install(self, package: str) -> bool:+ async def _install(self, package: str, *, upgrade: bool) -> bool:LOGGER.info(f"Installing {package} with pip")- return self.run(- ["pip", "--python", PY_EXE, "install", *split_packages(package)]- )+ cmd = ["pip", "--python", PY_EXE, "install"]+ if upgrade:+ cmd.append("--upgrade")+ cmd.extend(split_packages(package))+ return self.run(cmd)async def uninstall(self, package: str) -> bool:LOGGER.info(f"Uninstalling {package} with pip")@@ -86,10 +88,18 @@ class MicropipPackageManager(PypiPackageManager):def is_manager_installed(self) -> bool:return is_pyodide()- async def _install(self, package: str) -> bool:+ async def _install(self, package: str, *, upgrade: bool) -> bool:assert is_pyodide()import micropip # type: ignore+ # If we're upgrading, we need to uninstall the package first+ # to avoid conflicts+ if upgrade:+ try:+ await micropip.uninstall(split_packages(package))+ except ValueError:+ pass+try:await micropip.install(split_packages(package))return True@@ -125,7 +135,7 @@ class UvPackageManager(PypiPackageManager):name = "uv"docs_url = "https://docs.astral.sh/uv/"- async def _install(self, package: str) -> bool:+ async def _install(self, package: str, *, upgrade: bool) -> bool:install_cmd: list[str]if self.is_in_uv_project:LOGGER.info(f"Installing in {package} with 'uv add'")@@ -134,6 +144,9 @@ class UvPackageManager(PypiPackageManager):LOGGER.info(f"Installing in {package} with 'uv pip install'")install_cmd = ["uv", "pip", "install"]+ if upgrade:+ install_cmd.append("--upgrade")+return self.run(# trade installation time for faster start timeinstall_cmd + ["--compile", *split_packages(package), "-p", PY_EXE]@@ -147,6 +160,7 @@ class UvPackageManager(PypiPackageManager):packages_to_remove: Optional[list[str]] = None,import_namespaces_to_add: Optional[list[str]] = None,import_namespaces_to_remove: Optional[list[str]] = None,+ upgrade: bool,) -> None:"""Update the notebook's script metadata with the packages to add/remove.@@ -156,6 +170,7 @@ class UvPackageManager(PypiPackageManager):packages_to_remove: List of packages to remove from the script metadataimport_namespaces_to_add: List of import namespaces to addimport_namespaces_to_remove: List of import namespaces to remove+ upgrade: Whether to upgrade the packages"""packages_to_add = packages_to_add or []packages_to_remove = packages_to_remove or []@@ -200,10 +215,10 @@ class UvPackageManager(PypiPackageManager):if filepath.endswith(".md") or filepath.endswith(".qmd"):# md and qmd require writing to a faux python file first.return self._process_md_changes(- filepath, packages_to_add, packages_to_remove+ filepath, packages_to_add, packages_to_remove, upgrade=upgrade)return self._process_changes_for_script_metadata(- filepath, packages_to_add, packages_to_remove+ filepath, packages_to_add, packages_to_remove, upgrade=upgrade)def _process_md_changes(@@ -211,6 +226,7 @@ class UvPackageManager(PypiPackageManager):filepath: str,packages_to_add: list[str],packages_to_remove: list[str],+ upgrade: bool,) -> None:from marimo._cli.convert.markdown import extract_frontmatterfrom marimo._utils import yaml@@ -241,6 +257,7 @@ class UvPackageManager(PypiPackageManager):temp_file.name,packages_to_add,packages_to_remove,+ upgrade=upgrade,)with open(temp_file.name, encoding="utf-8") as f:header = f.read()@@ -271,12 +288,14 @@ class UvPackageManager(PypiPackageManager):filepath: str,packages_to_add: list[str],packages_to_remove: list[str],+ upgrade: bool,) -> None:if packages_to_add:- self.run(- ["uv", "--quiet", "add", "--script", filepath]- + packages_to_add- )+ cmd = ["uv", "--quiet", "add", "--script", filepath]+ if upgrade:+ cmd.append("--upgrade")+ cmd.extend(packages_to_add)+ self.run(cmd)if packages_to_remove:self.run(["uv", "--quiet", "remove", "--script", filepath]@@ -343,7 +362,11 @@ class RyePackageManager(PypiPackageManager):name = "rye"docs_url = "https://rye.astral.sh/"- async def _install(self, package: str) -> bool:+ async def _install(self, package: str, *, upgrade: bool) -> bool:+ if upgrade:+ return self.run(+ ["rye", "sync", "--update", *split_packages(package)]+ )return self.run(["rye", "add", *split_packages(package)])async def uninstall(self, package: str) -> bool:@@ -358,7 +381,17 @@ class PoetryPackageManager(PypiPackageManager):name = "poetry"docs_url = "https://python-poetry.org/docs/"- async def _install(self, package: str) -> bool:+ async def _install(self, package: str, *, upgrade: bool) -> bool:+ if upgrade:+ return self.run(+ [+ "poetry",+ "update",+ "--no-interaction",+ *split_packages(package),+ ]+ )+return self.run(["poetry", "add", "--no-interaction", *split_packages(package)])diff --git a/marimo/_runtime/runtime.py b/marimo/_runtime/runtime.pyindex c81a2c6c70..8489a6cf34 100644--- a/marimo/_runtime/runtime.py+++ b/marimo/_runtime/runtime.py@@ -2572,6 +2572,7 @@ class PackagesCallbacks:self.package_manager.update_notebook_script_metadata(filepath=filename,import_namespaces_to_add=import_namespaces_to_add,+ upgrade=False,)except Exception as e:LOGGER.error("Failed to add script metadata to notebook: %s", e)diff --git a/marimo/_server/api/endpoints/packages.py b/marimo/_server/api/endpoints/packages.pyindex f67e8ec09c..2696700d94 100644--- a/marimo/_server/api/endpoints/packages.py+++ b/marimo/_server/api/endpoints/packages.py@@ -53,7 +53,10 @@ async def add_package(request: Request) -> PackageOperationResponse:f"Check out the docs for installation instructions: {package_manager.docs_url}" # noqa: E501)- success = await package_manager.install(body.package, version=None)+ upgrade = body.upgrade or False+ success = await package_manager.install(+ body.package, version=None, upgrade=upgrade+ )# Update the script metadatafilename = _get_filename(request)@@ -61,6 +64,7 @@ async def add_package(request: Request) -> PackageOperationResponse:package_manager.update_notebook_script_metadata(filepath=filename,packages_to_add=split_packages(body.package),+ upgrade=upgrade,)if success:@@ -106,6 +110,7 @@ async def remove_package(request: Request) -> PackageOperationResponse:package_manager.update_notebook_script_metadata(filepath=filename,packages_to_remove=split_packages(body.package),+ upgrade=False,)if success:diff --git a/marimo/_server/models/packages.py b/marimo/_server/models/packages.pyindex b253375cec..e78fe088d7 100644--- a/marimo/_server/models/packages.py+++ b/marimo/_server/models/packages.py@@ -23,6 +23,7 @@ class AddPackageRequest:"""package: str+ upgrade: Optional[bool] = False@dataclassdiff --git a/openapi/api.yaml b/openapi/api.yamlindex 99b8efe605..d4f2991b85 100644--- a/openapi/api.yaml+++ b/openapi/api.yaml@@ -4,8 +4,11 @@ components:properties:package:type: string+ upgrade:+ nullable: true+ type: booleanrequired:- - package+ - packagetype: objectAiCompletionContext:properties:@@ -16,12 +19,12 @@ components:variables:items:oneOf:- - $ref: '#/components/schemas/VariableContext'- - type: string+ - $ref: '#/components/schemas/VariableContext'+ - type: stringtype: arrayrequired:- - schema- - variables+ - schema+ - variablestype: objectAiCompletionRequest:properties:@@ -34,9 +37,9 @@ components:type: stringlanguage:enum:- - python- - markdown- - sql+ - python+ - markdown+ - sqltype: stringprompt:type: string@@ -44,27 +47,27 @@ components:nullable: truetype: stringrequired:- - prompt- - includeOtherCode- - code- - language+ - prompt+ - includeOtherCode+ - code+ - languagetype: objectAiInlineCompletionRequest:properties:language:enum:- - python- - markdown- - sql+ - python+ - markdown+ - sqltype: stringprefix:type: stringsuffix:type: stringrequired:- - prefix- - suffix- - language+ - prefix+ - suffix+ - languagetype: objectAlert:properties:@@ -72,61 +75,61 @@ components:type: stringname:enum:- - alert+ - alerttype: stringtitle:type: stringvariant:enum:- - danger+ - dangernullable: truetype: stringrequired:- - title- - description- - name+ - title+ - description+ - nametype: objectBanner:properties:action:enum:- - restart+ - restartnullable: truetype: stringdescription:type: stringname:enum:- - banner+ - bannertype: stringtitle:type: stringvariant:enum:- - danger+ - dangernullable: truetype: stringrequired:- - title- - description- - name+ - title+ - description+ - nametype: objectBaseResponse:properties:success:type: booleanrequired:- - success+ - successtype: objectCellChannel:enum:- - stdout- - stderr- - stdin- - pdb- - output- - marimo-error- - media+ - stdout+ - stderr+ - stdin+ - pdb+ - output+ - marimo-error+ - mediatype: stringCellConfig:properties:@@ -138,8 +141,8 @@ components:hide_code:type: booleanrequired:- - disabled- - hide_code+ - disabled+ - hide_codetype: objectCellOp:properties:@@ -148,13 +151,13 @@ components:console:nullable: trueoneOf:- - $ref: '#/components/schemas/CellOutput'- - items:- $ref: '#/components/schemas/CellOutput'- type: array+ - $ref: '#/components/schemas/CellOutput'+ - items:+ $ref: '#/components/schemas/CellOutput'+ type: arrayname:enum:- - cell-op+ - cell-optype: stringoutput:$ref: '#/components/schemas/CellOutput'@@ -174,9 +177,9 @@ components:timestamp:type: numberrequired:- - cell_id- - timestamp- - name+ - cell_id+ - timestamp+ - nametype: objectCellOutput:properties:@@ -184,21 +187,21 @@ components:$ref: '#/components/schemas/CellChannel'data:oneOf:- - type: string- - items:- $ref: '#/components/schemas/Error'- type: array- - additionalProperties: {}- type: object+ - type: string+ - items:+ $ref: '#/components/schemas/Error'+ type: array+ - additionalProperties: {}+ type: objectmimetype:$ref: '#/components/schemas/MimeType'timestamp:type: numberrequired:- - channel- - mimetype- - data- - timestamp+ - channel+ - mimetype+ - data+ - timestamptype: objectChatRequest:properties:@@ -220,8 +223,8 @@ components:url:type: stringrequired:- - url- - name+ - url+ - nametype: objectnullable: truetype: array@@ -230,13 +233,13 @@ components:type: objectrole:enum:- - user- - assistant- - system+ - user+ - assistant+ - systemtype: stringrequired:- - role- - content+ - role+ - contenttype: objecttype: arraymodel:@@ -245,14 +248,14 @@ components:variables:items:oneOf:- - $ref: '#/components/schemas/VariableContext'- - type: string+ - $ref: '#/components/schemas/VariableContext'+ - type: stringnullable: truetype: arrayrequired:- - context- - includeOtherCode- - messages+ - context+ - includeOtherCode+ - messagestype: objectCodeCompletionRequest:properties:@@ -263,9 +266,9 @@ components:id:type: stringrequired:- - id- - document- - cellId+ - id+ - document+ - cellIdtype: objectColumnStats:properties:@@ -316,10 +319,10 @@ components:properties:name:enum:- - completed-run+ - completed-runtype: stringrequired:- - name+ - nametype: objectCompletionResult:properties:@@ -327,7 +330,7 @@ components:type: stringname:enum:- - completion-result+ - completion-resulttype: stringoptions:items:@@ -340,17 +343,17 @@ components:type:type: stringrequired:- - name- - type+ - name+ - typetype: objecttype: arrayprefix_length:type: integerrequired:- - completion_id- - prefix_length- - options- - name+ - completion_id+ - prefix_length+ - options+ - nametype: objectCopyNotebookRequest:properties:@@ -359,8 +362,8 @@ components:source:type: stringrequired:- - source- - destination+ - source+ - destinationtype: objectCreateSecretRequest:properties:@@ -370,36 +373,36 @@ components:type: stringprovider:enum:- - env- - dotenv+ - env+ - dotenvtype: stringvalue:type: stringrequired:- - key- - value- - provider- - name+ - key+ - value+ - provider+ - nametype: objectCycleError:properties:edges_with_vars:items:prefixItems:- - type: string- - items:- type: string- type: array- - type: string+ - type: string+ - items:+ type: string+ type: array+ - type: stringtype: arraytype: arraytype:enum:- - cycle+ - cycletype: stringrequired:- - edges_with_vars- - type+ - edges_with_vars+ - typetype: objectDataColumnPreview:properties:@@ -423,7 +426,7 @@ components:type: arrayname:enum:- - data-column-preview+ - data-column-previewtype: stringstats:$ref: '#/components/schemas/ColumnStats'@@ -431,10 +434,10 @@ components:table_name:type: stringrequired:- - chart_max_rows_errors- - table_name- - column_name- - name+ - chart_max_rows_errors+ - table_name+ - column_name+ - nametype: objectDataSourceConnection:properties:@@ -458,14 +461,14 @@ components:$ref: '#/components/schemas/DataTable'type: arrayrequired:- - name- - tables+ - name+ - tablestype: objecttype: arrayrequired:- - name- - dialect- - schemas+ - name+ - dialect+ - schemastype: objecttype: arraydefault_database:@@ -483,11 +486,11 @@ components:source:type: stringrequired:- - source- - dialect- - name- - display_name- - databases+ - source+ - dialect+ - name+ - display_name+ - databasestype: objectDataSourceConnections:properties:@@ -497,11 +500,11 @@ components:type: arrayname:enum:- - data-source-connections+ - data-source-connectionstype: stringrequired:- - connections- - name+ - connections+ - nametype: objectDataTable:properties:@@ -534,25 +537,25 @@ components:type: stringsource_type:enum:- - local- - duckdb- - connection- - catalog+ - local+ - duckdb+ - connection+ - catalogtype: stringtype:enum:- - table- - view+ - table+ - viewtype: stringvariable_name:nullable: truetype: stringrequired:- - source_type- - source- - name- - columns- - type+ - source_type+ - source+ - name+ - columns+ - typetype: objectDataTableColumn:properties:@@ -566,21 +569,21 @@ components:type:$ref: '#/components/schemas/DataType'required:- - name- - type- - external_type- - sample_values+ - name+ - type+ - external_type+ - sample_valuestype: objectDataType:enum:- - string- - boolean- - integer- - number- - date- - datetime- - time- - unknown+ - string+ - boolean+ - integer+ - number+ - date+ - datetime+ - time+ - unknowntype: stringDatabase:properties:@@ -596,38 +599,38 @@ components:$ref: '#/components/schemas/Schema'type: arrayrequired:- - name- - dialect- - schemas+ - name+ - dialect+ - schemastype: objectDatasets:properties:clear_channel:enum:- - local- - duckdb- - connection- - catalog+ - local+ - duckdb+ - connection+ - catalognullable: truetype: stringname:enum:- - datasets+ - datasetstype: stringtables:items:$ref: '#/components/schemas/DataTable'type: arrayrequired:- - tables- - name+ - tables+ - nametype: objectDeleteCellRequest:properties:cellId:type: stringrequired:- - cellId+ - cellIdtype: objectDeleteNonlocalError:properties:@@ -639,35 +642,35 @@ components:type: stringtype:enum:- - delete-nonlocal+ - delete-nonlocaltype: stringrequired:- - name- - cells- - type+ - name+ - cells+ - typetype: objectDeleteSecretRequest:properties:key:type: stringrequired:- - key+ - keytype: objectError:oneOf:- - $ref: '#/components/schemas/SetupRootError'- - $ref: '#/components/schemas/CycleError'- - $ref: '#/components/schemas/MultipleDefinitionError'- - $ref: '#/components/schemas/ImportStarError'- - $ref: '#/components/schemas/DeleteNonlocalError'- - $ref: '#/components/schemas/MarimoAncestorStoppedError'- - $ref: '#/components/schemas/MarimoAncestorPreventedError'- - $ref: '#/components/schemas/MarimoExceptionRaisedError'- - $ref: '#/components/schemas/MarimoStrictExecutionError'- - $ref: '#/components/schemas/MarimoInterruptionError'- - $ref: '#/components/schemas/MarimoSyntaxError'- - $ref: '#/components/schemas/MarimoInternalError'- - $ref: '#/components/schemas/UnknownError'+ - $ref: '#/components/schemas/SetupRootError'+ - $ref: '#/components/schemas/CycleError'+ - $ref: '#/components/schemas/MultipleDefinitionError'+ - $ref: '#/components/schemas/ImportStarError'+ - $ref: '#/components/schemas/DeleteNonlocalError'+ - $ref: '#/components/schemas/MarimoAncestorStoppedError'+ - $ref: '#/components/schemas/MarimoAncestorPreventedError'+ - $ref: '#/components/schemas/MarimoExceptionRaisedError'+ - $ref: '#/components/schemas/MarimoStrictExecutionError'+ - $ref: '#/components/schemas/MarimoInterruptionError'+ - $ref: '#/components/schemas/MarimoSyntaxError'+ - $ref: '#/components/schemas/MarimoInternalError'+ - $ref: '#/components/schemas/UnknownError'ExecuteMultipleRequest:properties:cellIds:@@ -684,9 +687,9 @@ components:timestamp:type: numberrequired:- - cellIds- - codes- - timestamp+ - cellIds+ - codes+ - timestamptype: objectExecuteScratchpadRequest:properties:@@ -696,7 +699,7 @@ components:$ref: '#/components/schemas/HTTPRequest'nullable: truerequired:- - code+ - codetype: objectExecuteStaleRequest:properties:@@ -716,9 +719,9 @@ components:timestamp:type: numberrequired:- - cellId- - code- - timestamp+ - cellId+ - code+ - timestamptype: objectExportAsHTMLRequest:properties:@@ -734,30 +737,30 @@ components:includeCode:type: booleanrequired:- - download- - files- - includeCode+ - download+ - files+ - includeCodetype: objectExportAsIPYNBRequest:properties:download:type: booleanrequired:- - download+ - downloadtype: objectExportAsMarkdownRequest:properties:download:type: booleanrequired:- - download+ - downloadtype: objectExportAsScriptRequest:properties:download:type: booleanrequired:- - download+ - downloadtype: objectFileCreateRequest:properties:@@ -770,13 +773,13 @@ components:type: stringtype:enum:- - file- - directory+ - file+ - directorytype: stringrequired:- - path- - type- - name+ - path+ - type+ - nametype: objectFileCreateResponse:properties:@@ -789,14 +792,14 @@ components:success:type: booleanrequired:- - success+ - successtype: objectFileDeleteRequest:properties:path:type: stringrequired:- - path+ - pathtype: objectFileDeleteResponse:properties:@@ -806,14 +809,14 @@ components:success:type: booleanrequired:- - success+ - successtype: objectFileDetailsRequest:properties:path:type: stringrequired:- - path+ - pathtype: objectFileDetailsResponse:properties:@@ -826,7 +829,7 @@ components:nullable: truetype: stringrequired:- - file+ - filetype: objectFileInfo:properties:@@ -848,12 +851,12 @@ components:path:type: stringrequired:- - id- - path- - name- - isDirectory- - isMarimoFile- - children+ - id+ - path+ - name+ - isDirectory+ - isMarimoFile+ - childrentype: objectFileListRequest:properties:@@ -870,8 +873,8 @@ components:root:type: stringrequired:- - files- - root+ - files+ - roottype: objectFileMoveRequest:properties:@@ -880,8 +883,8 @@ components:path:type: stringrequired:- - path- - newPath+ - path+ - newPathtype: objectFileMoveResponse:properties:@@ -894,14 +897,14 @@ components:success:type: booleanrequired:- - success+ - successtype: objectFileOpenRequest:properties:path:type: stringrequired:- - path+ - pathtype: objectFileUpdateRequest:properties:@@ -910,8 +913,8 @@ components:path:type: stringrequired:- - path- - contents+ - path+ - contentstype: objectFileUpdateResponse:properties:@@ -924,7 +927,7 @@ components:success:type: booleanrequired:- - success+ - successtype: objectFocusCell:properties:@@ -932,11 +935,11 @@ components:type: stringname:enum:- - focus-cell+ - focus-celltype: stringrequired:- - cell_id- - name+ - cell_id+ - nametype: objectFormatRequest:properties:@@ -947,8 +950,8 @@ components:lineLength:type: integerrequired:- - codes- - lineLength+ - codes+ - lineLengthtype: objectFormatResponse:properties:@@ -957,7 +960,7 @@ components:type: stringtype: objectrequired:- - codes+ - codestype: objectFunctionCallRequest:properties:@@ -971,10 +974,10 @@ components:namespace:type: stringrequired:- - functionCallId- - namespace- - functionName- - args+ - functionCallId+ - namespace+ - functionName+ - argstype: objectFunctionCallResult:properties:@@ -982,30 +985,30 @@ components:type: stringname:enum:- - function-call-result+ - function-call-resulttype: stringreturn_value:nullable: trueoneOf:- - additionalProperties:- $ref: '#/components/schemas/JSONType'- type: object- - items:- $ref: '#/components/schemas/JSONType'- type: array- - type: string- - type: integer- - type: number- - type: boolean- - additionalProperties: true- type: object- - $ref: '#/components/schemas/MIME'+ - additionalProperties:+ $ref: '#/components/schemas/JSONType'+ type: object+ - items:+ $ref: '#/components/schemas/JSONType'+ type: array+ - type: string+ - type: integer+ - type: number+ - type: boolean+ - additionalProperties: true+ type: object+ - $ref: '#/components/schemas/MIME'status:$ref: '#/components/schemas/HumanReadableStatus'required:- - function_call_id- - status- - name+ - function_call_id+ - status+ - nametype: objectHTTPRequest:type: 'null'@@ -1013,8 +1016,8 @@ components:properties:code:enum:- - ok- - error+ - ok+ - errortype: stringmessage:nullable: true@@ -1023,7 +1026,7 @@ components:nullable: truetype: stringrequired:- - code+ - codetype: objectImportStarError:properties:@@ -1031,11 +1034,11 @@ components:type: stringtype:enum:- - import-star+ - import-startype: stringrequired:- - msg- - type+ - msg+ - typetype: objectInstallMissingPackagesRequest:properties:@@ -1046,27 +1049,27 @@ components:type: stringtype: objectrequired:- - manager- - versions+ - manager+ - versionstype: objectInstallingPackageAlert:properties:name:enum:- - installing-package-alert+ - installing-package-alerttype: stringpackages:additionalProperties:enum:- - queued- - installing- - installed- - failed+ - queued+ - installing+ - installed+ - failedtype: stringtype: objectrequired:- - packages- - name+ - packages+ - nametype: objectInstantiateRequest:properties:@@ -1080,27 +1083,27 @@ components:items: {}type: arrayrequired:- - objectIds- - values- - autoRun+ - objectIds+ - values+ - autoRuntype: objectInterrupted:properties:name:enum:- - interrupted+ - interruptedtype: stringrequired:- - name+ - nametype: objectJSONType:oneOf:- - type: string- - type: number- - type: object- - type: array- - type: boolean- - type: 'null'+ - type: string+ - type: number+ - type: object+ - type: array+ - type: boolean+ - type: 'null'KernelReady:properties:app_config:@@ -1111,8 +1114,8 @@ components:auto_download:items:enum:- - html- - markdown+ - html+ - markdowntype: stringtype: arraycss_file:@@ -1126,24 +1129,24 @@ components:type: stringsql_output:enum:- - polars- - lazy-polars- - pandas- - native- - auto+ - polars+ - lazy-polars+ - pandas+ - native+ - autotype: stringwidth:enum:- - normal- - compact- - medium- - full- - columns+ - normal+ - compact+ - medium+ - full+ - columnstype: stringrequired:- - width- - auto_download- - sql_output+ - width+ - auto_download+ - sql_outputtype: objectcapabilities:properties:@@ -1152,8 +1155,8 @@ components:terminal:type: booleanrequired:- - terminal- - pylsp+ - terminal+ - pylsptype: objectcell_ids:items:@@ -1188,12 +1191,12 @@ components:type:type: stringrequired:- - type- - data+ - type+ - datatype: objectname:enum:- - kernel-ready+ - kernel-readytype: stringnames:items:@@ -1205,59 +1208,59 @@ components:additionalProperties:nullable: trueoneOf:- - additionalProperties:- nullable: true- oneOf:- - additionalProperties:- $ref: '#/components/schemas/JSONType'- type: object- - items:- $ref: '#/components/schemas/JSONType'- type: array- - type: string- - type: integer- - type: number- - type: boolean- - additionalProperties: true- type: object- - $ref: '#/components/schemas/MIME'- type: object- - items:- nullable: true- oneOf:- - additionalProperties:- $ref: '#/components/schemas/JSONType'- type: object- - items:- $ref: '#/components/schemas/JSONType'- type: array- - type: string- - type: integer- - type: number- - type: boolean- - additionalProperties: true- type: object- - $ref: '#/components/schemas/MIME'- type: array- - type: string- - type: integer- - type: number- - type: boolean- - additionalProperties: true- type: object- - $ref: '#/components/schemas/MIME'+ - additionalProperties:+ nullable: true+ oneOf:+ - additionalProperties:+ $ref: '#/components/schemas/JSONType'+ type: object+ - items:+ $ref: '#/components/schemas/JSONType'+ type: array+ - type: string+ - type: integer+ - type: number+ - type: boolean+ - additionalProperties: true+ type: object+ - $ref: '#/components/schemas/MIME'+ type: object+ - items:+ nullable: true+ oneOf:+ - additionalProperties:+ $ref: '#/components/schemas/JSONType'+ type: object+ - items:+ $ref: '#/components/schemas/JSONType'+ type: array+ - type: string+ - type: integer+ - type: number+ - type: boolean+ - additionalProperties: true+ type: object+ - $ref: '#/components/schemas/MIME'+ type: array+ - type: string+ - type: integer+ - type: number+ - type: boolean+ - additionalProperties: true+ type: object+ - $ref: '#/components/schemas/MIME'nullable: truetype: objectrequired:- - cell_ids- - codes- - names- - configs- - resumed- - app_config- - kiosk- - capabilities- - name+ - cell_ids+ - codes+ - names+ - configs+ - resumed+ - app_config+ - kiosk+ - capabilities+ - nametype: objectListPackagesResponse:properties:@@ -1266,14 +1269,14 @@ components:$ref: '#/components/schemas/PackageDescription'type: arrayrequired:- - packages+ - packagestype: objectListSecretKeysRequest:properties:requestId:type: stringrequired:- - requestId+ - requestIdtype: objectListSecretKeysResponse:properties:@@ -1282,7 +1285,7 @@ components:$ref: '#/components/schemas/SecretKeysWithProvider'type: arrayrequired:- - keys+ - keystype: objectMIME:properties: {}@@ -1298,12 +1301,12 @@ components:type: stringtype:enum:- - ancestor-prevented+ - ancestor-preventedtype: stringrequired:- - msg- - raising_cell- - type+ - msg+ - raising_cell+ - typetype: objectMarimoAncestorStoppedError:properties:@@ -1313,12 +1316,12 @@ components:type: stringtype:enum:- - ancestor-stopped+ - ancestor-stoppedtype: stringrequired:- - msg- - raising_cell- - type+ - msg+ - raising_cell+ - typetype: objectMarimoConfig:properties:@@ -1380,39 +1383,39 @@ components:type: stringcopilot:oneOf:- - type: boolean- - enum:- - github- - codeium- - custom- type: string+ - type: boolean+ - enum:+ - github+ - codeium+ - custom+ type: stringmodel:nullable: truetype: stringrequired:- - activate_on_typing- - copilot+ - activate_on_typing+ - copilottype: objectdatasources:properties:auto_discover_columns:oneOf:- - type: boolean- - enum:- - auto- type: string+ - type: boolean+ - enum:+ - auto+ type: stringauto_discover_schemas:oneOf:- - type: boolean- - enum:- - auto- type: string+ - type: boolean+ - enum:+ - auto+ type: stringauto_discover_tables:oneOf:- - type: boolean- - enum:- - auto- type: string+ - type: boolean+ - enum:+ - auto+ type: stringtype: objectdiagnostics:properties:@@ -1423,8 +1426,8 @@ components:properties:cell_output:enum:- - above- - below+ - above+ - belowtype: stringcode_editor_font_size:type: integer@@ -1434,32 +1437,32 @@ components:type: arraydataframes:enum:- - rich- - plain+ - rich+ - plaintype: stringdefault_table_page_size:type: integerdefault_width:enum:- - normal- - compact- - medium- - full- - columns+ - normal+ - compact+ - medium+ - full+ - columnstype: stringtheme:enum:- - light- - dark- - system+ - light+ - dark+ - systemtype: stringrequired:- - theme- - code_editor_font_size- - cell_output- - default_width- - dataframes- - default_table_page_size+ - theme+ - code_editor_font_size+ - cell_output+ - default_width+ - dataframes+ - default_table_page_sizetype: objectexperimental:additionalProperties: {}@@ -1469,7 +1472,7 @@ components:line_length:type: integerrequired:- - line_length+ - line_lengthtype: objectkeymap:properties:@@ -1479,14 +1482,14 @@ components:type: objectpreset:enum:- - default- - vim+ - default+ - vimtype: stringvimrc:nullable: truetype: stringrequired:- - preset+ - presettype: objectlanguage_servers:properties:@@ -1512,14 +1515,14 @@ components:properties:manager:enum:- - pip- - rye- - uv- - poetry- - pixi+ - pip+ - rye+ - uv+ - poetry+ - pixitype: stringrequired:- - manager+ - managertype: objectruntime:properties:@@ -1527,17 +1530,17 @@ components:type: booleanauto_reload:enum:- - 'off'- - lazy- - autorun+ - 'off'+ - lazy+ - autoruntype: stringdefault_sql_output:enum:- - polars- - lazy-polars- - pandas- - native- - auto+ - polars+ - lazy-polars+ - pandas+ - native+ - autotype: stringdotenv:items:@@ -1545,8 +1548,8 @@ components:type: arrayon_cell_change:enum:- - lazy- - autorun+ - lazy+ - autoruntype: stringoutput_max_bytes:type: integer@@ -1560,48 +1563,48 @@ components:type: integerwatcher_on_save:enum:- - lazy- - autorun+ - lazy+ - autoruntype: stringrequired:- - auto_instantiate- - auto_reload- - reactive_tests- - on_cell_change- - watcher_on_save- - output_max_bytes- - std_stream_max_bytes- - default_sql_output+ - auto_instantiate+ - auto_reload+ - reactive_tests+ - on_cell_change+ - watcher_on_save+ - output_max_bytes+ - std_stream_max_bytes+ - default_sql_outputtype: objectsave:properties:autosave:enum:- - 'off'- - after_delay+ - 'off'+ - after_delaytype: stringautosave_delay:type: integerformat_on_save:type: booleanrequired:- - autosave- - autosave_delay- - format_on_save+ - autosave+ - autosave_delay+ - format_on_savetype: objectserver:properties:browser:oneOf:- - enum:- - default- type: string- - type: string+ - enum:+ - default+ type: string+ - type: stringfollow_symlink:type: booleanrequired:- - browser- - follow_symlink+ - browser+ - follow_symlinktype: objectsnippets:properties:@@ -1613,14 +1616,14 @@ components:type: booleantype: objectrequired:- - completion- - display- - formatting- - keymap- - runtime- - save- - server- - package_management+ - completion+ - display+ - formatting+ - keymap+ - runtime+ - save+ - server+ - package_managementtype: objectMarimoExceptionRaisedError:properties:@@ -1633,12 +1636,12 @@ components:type: stringtype:enum:- - exception+ - exceptiontype: stringrequired:- - msg- - exception_type- - type+ - msg+ - exception_type+ - typetype: objectMarimoFile:properties:@@ -1656,8 +1659,8 @@ components:nullable: truetype: stringrequired:- - name- - path+ - name+ - pathtype: objectMarimoInternalError:properties:@@ -1667,21 +1670,21 @@ components:type: stringtype:enum:- - internal+ - internaltype: stringrequired:- - error_id- - type- - msg+ - error_id+ - type+ - msgtype: objectMarimoInterruptionError:properties:type:enum:- - interruption+ - interruptiontype: stringrequired:- - type+ - typetype: objectMarimoStrictExecutionError:properties:@@ -1694,12 +1697,12 @@ components:type: stringtype:enum:- - strict-exception+ - strict-exceptiontype: stringrequired:- - msg- - ref- - type+ - msg+ - ref+ - typetype: objectMarimoSyntaxError:properties:@@ -1707,65 +1710,65 @@ components:type: stringtype:enum:- - syntax+ - syntaxtype: stringrequired:- - msg- - type+ - msg+ - typetype: objectMessageOperation:oneOf:- - $ref: '#/components/schemas/CellOp'- - $ref: '#/components/schemas/FunctionCallResult'- - $ref: '#/components/schemas/SendUIElementMessage'- - $ref: '#/components/schemas/RemoveUIElements'- - $ref: '#/components/schemas/Reload'- - $ref: '#/components/schemas/Reconnected'- - $ref: '#/components/schemas/Interrupted'- - $ref: '#/components/schemas/CompletedRun'- - $ref: '#/components/schemas/KernelReady'- - $ref: '#/components/schemas/CompletionResult'- - $ref: '#/components/schemas/Alert'- - $ref: '#/components/schemas/Banner'- - $ref: '#/components/schemas/MissingPackageAlert'- - $ref: '#/components/schemas/InstallingPackageAlert'- - $ref: '#/components/schemas/Variables'- - $ref: '#/components/schemas/VariableValues'- - $ref: '#/components/schemas/QueryParamsSet'- - $ref: '#/components/schemas/QueryParamsAppend'- - $ref: '#/components/schemas/QueryParamsDelete'- - $ref: '#/components/schemas/QueryParamsClear'- - $ref: '#/components/schemas/Datasets'- - $ref: '#/components/schemas/DataColumnPreview'- - $ref: '#/components/schemas/SQLTablePreview'- - $ref: '#/components/schemas/SQLTableListPreview'- - $ref: '#/components/schemas/DataSourceConnections'- - $ref: '#/components/schemas/SecretKeysResult'- - $ref: '#/components/schemas/FocusCell'- - $ref: '#/components/schemas/UpdateCellCodes'- - $ref: '#/components/schemas/UpdateCellIdsRequest'+ - $ref: '#/components/schemas/CellOp'+ - $ref: '#/components/schemas/FunctionCallResult'+ - $ref: '#/components/schemas/SendUIElementMessage'+ - $ref: '#/components/schemas/RemoveUIElements'+ - $ref: '#/components/schemas/Reload'+ - $ref: '#/components/schemas/Reconnected'+ - $ref: '#/components/schemas/Interrupted'+ - $ref: '#/components/schemas/CompletedRun'+ - $ref: '#/components/schemas/KernelReady'+ - $ref: '#/components/schemas/CompletionResult'+ - $ref: '#/components/schemas/Alert'+ - $ref: '#/components/schemas/Banner'+ - $ref: '#/components/schemas/MissingPackageAlert'+ - $ref: '#/components/schemas/InstallingPackageAlert'+ - $ref: '#/components/schemas/Variables'+ - $ref: '#/components/schemas/VariableValues'+ - $ref: '#/components/schemas/QueryParamsSet'+ - $ref: '#/components/schemas/QueryParamsAppend'+ - $ref: '#/components/schemas/QueryParamsDelete'+ - $ref: '#/components/schemas/QueryParamsClear'+ - $ref: '#/components/schemas/Datasets'+ - $ref: '#/components/schemas/DataColumnPreview'+ - $ref: '#/components/schemas/SQLTablePreview'+ - $ref: '#/components/schemas/SQLTableListPreview'+ - $ref: '#/components/schemas/DataSourceConnections'+ - $ref: '#/components/schemas/SecretKeysResult'+ - $ref: '#/components/schemas/FocusCell'+ - $ref: '#/components/schemas/UpdateCellCodes'+ - $ref: '#/components/schemas/UpdateCellIdsRequest'MimeType:enum:- - application/json- - application/vnd.marimo+error- - application/vnd.marimo+traceback- - application/vnd.marimo+mimebundle- - application/vnd.vega.v5+json- - application/vnd.vegalite.v5+json- - image/png- - image/svg+xml- - image/tiff- - image/avif- - image/bmp- - image/gif- - image/jpeg- - video/mp4- - video/mpeg- - text/html- - text/plain- - text/markdown- - text/latex- - text/csv+ - application/json+ - application/vnd.marimo+error+ - application/vnd.marimo+traceback+ - application/vnd.marimo+mimebundle+ - application/vnd.vega.v5+json+ - application/vnd.vegalite.v5+json+ - image/png+ - image/svg+xml+ - image/tiff+ - image/avif+ - image/bmp+ - image/gif+ - image/jpeg+ - video/mp4+ - video/mpeg+ - text/html+ - text/plain+ - text/markdown+ - text/latex+ - text/csvtype: stringMissingPackageAlert:properties:@@ -1773,16 +1776,16 @@ components:type: booleanname:enum:- - missing-package-alert+ - missing-package-alerttype: stringpackages:items:type: stringtype: arrayrequired:- - packages- - isolated- - name+ - packages+ - isolated+ - nametype: objectMultipleDefinitionError:properties:@@ -1794,49 +1797,49 @@ components:type: stringtype:enum:- - multiple-defs+ - multiple-defstype: stringrequired:- - name- - cells- - type+ - name+ - cells+ - typetype: objectNonNestedLiteral:oneOf:- - type: integer- - type: number- - format: date- type: string- - format: time- type: string- - format: date-time- type: string- - format: duration- type: string- - type: string- - type: boolean- - format: byte- type: string+ - type: integer+ - type: number+ - format: date+ type: string+ - format: time+ type: string+ - format: date-time+ type: string+ - format: duration+ type: string+ - type: string+ - type: boolean+ - format: byte+ type: stringOpenTutorialRequest:properties:tutorialId:oneOf:- - enum:- - intro- - dataflow- - ui- - markdown- - plots- - sql- - layout- - fileformat- - for-jupyter-users- type: string- - enum:- - markdown-format- type: string+ - enum:+ - intro+ - dataflow+ - ui+ - markdown+ - plots+ - sql+ - layout+ - fileformat+ - for-jupyter-users+ type: string+ - enum:+ - markdown-format+ type: stringrequired:- - tutorialId+ - tutorialIdtype: objectPackageDescription:properties:@@ -1845,8 +1848,8 @@ components:version:type: stringrequired:- - name- - version+ - name+ - versiontype: objectPackageOperationResponse:properties:@@ -1856,7 +1859,7 @@ components:success:type: booleanrequired:- - success+ - successtype: objectPdbRequest:properties:@@ -1866,14 +1869,14 @@ components:$ref: '#/components/schemas/HTTPRequest'nullable: truerequired:- - cellId+ - cellIdtype: objectPreviewDataSourceConnectionRequest:properties:engine:type: stringrequired:- - engine+ - enginetype: objectPreviewDatasetColumnRequest:properties:@@ -1886,18 +1889,18 @@ components:type: stringsourceType:enum:- - local- - duckdb- - connection- - catalog+ - local+ - duckdb+ - connection+ - catalogtype: stringtableName:type: stringrequired:- - sourceType- - source- - tableName- - columnName+ - sourceType+ - source+ - tableName+ - columnNametype: objectPreviewSQLTableListRequest:properties:@@ -1910,10 +1913,10 @@ components:schema:type: stringrequired:- - requestId- - engine- - database- - schema+ - requestId+ - engine+ - database+ - schematype: objectPreviewSQLTableRequest:properties:@@ -1928,11 +1931,11 @@ components:tableName:type: stringrequired:- - requestId- - engine- - database- - schema- - tableName+ - requestId+ - engine+ - database+ - schema+ - tableNametype: objectQueryParamsAppend:properties:@@ -1940,23 +1943,23 @@ components:type: stringname:enum:- - query-params-append+ - query-params-appendtype: stringvalue:type: stringrequired:- - key- - value- - name+ - key+ - value+ - nametype: objectQueryParamsClear:properties:name:enum:- - query-params-clear+ - query-params-cleartype: stringrequired:- - name+ - nametype: objectQueryParamsDelete:properties:@@ -1964,14 +1967,14 @@ components:type: stringname:enum:- - query-params-delete+ - query-params-deletetype: stringvalue:nullable: truetype: stringrequired:- - key- - name+ - key+ - nametype: objectQueryParamsSet:properties:@@ -1979,25 +1982,25 @@ components:type: stringname:enum:- - query-params-set+ - query-params-settype: stringvalue:oneOf:- - type: string- - items:- type: string- type: array+ - type: string+ - items:+ type: string+ type: arrayrequired:- - key- - value- - name+ - key+ - value+ - nametype: objectReadCodeResponse:properties:contents:type: stringrequired:- - contents+ - contentstype: objectRecentFilesResponse:properties:@@ -2006,32 +2009,32 @@ components:$ref: '#/components/schemas/MarimoFile'type: arrayrequired:- - files+ - filestype: objectReconnected:properties:name:enum:- - reconnected+ - reconnectedtype: stringrequired:- - name+ - nametype: objectReload:properties:name:enum:- - reload+ - reloadtype: stringrequired:- - name+ - nametype: objectRemovePackageRequest:properties:package:type: stringrequired:- - package+ - packagetype: objectRemoveUIElements:properties:@@ -2039,25 +2042,25 @@ components:type: stringname:enum:- - remove-ui-elements+ - remove-ui-elementstype: stringrequired:- - cell_id- - name+ - cell_id+ - nametype: objectRenameFileRequest:properties:filename:type: stringrequired:- - filename+ - filenametype: objectRenameRequest:properties:filename:type: stringrequired:- - filename+ - filenametype: objectRunRequest:properties:@@ -2073,8 +2076,8 @@ components:$ref: '#/components/schemas/HTTPRequest'nullable: truerequired:- - cellIds- - codes+ - cellIds+ - codestype: objectRunningNotebooksResponse:properties:@@ -2083,14 +2086,14 @@ components:$ref: '#/components/schemas/MarimoFile'type: arrayrequired:- - files+ - filestype: objectRuntimeState:enum:- - idle- - queued- - running- - disabled-transitively+ - idle+ - queued+ - running+ - disabled-transitivelytype: stringSQLTableListPreview:properties:@@ -2099,7 +2102,7 @@ components:type: stringname:enum:- - sql-table-list-preview+ - sql-table-list-previewtype: stringrequest_id:type: string@@ -2108,9 +2111,9 @@ components:$ref: '#/components/schemas/DataTable'type: arrayrequired:- - request_id- - tables- - name+ - request_id+ - tables+ - nametype: objectSQLTablePreview:properties:@@ -2119,7 +2122,7 @@ components:type: stringname:enum:- - sql-table-preview+ - sql-table-previewtype: stringrequest_id:type: string@@ -2127,8 +2130,8 @@ components:$ref: '#/components/schemas/DataTable'nullable: truerequired:- - request_id- - name+ - request_id+ - nametype: objectSaveAppConfigurationRequest:properties:@@ -2136,7 +2139,7 @@ components:additionalProperties: {}type: objectrequired:- - config+ - configtype: objectSaveNotebookRequest:properties:@@ -2165,19 +2168,19 @@ components:persist:type: booleanrequired:- - cellIds- - codes- - names- - configs- - filename- - persist+ - cellIds+ - codes+ - names+ - configs+ - filename+ - persisttype: objectSaveUserConfigurationRequest:properties:config:$ref: '#/components/schemas/MarimoConfig'required:- - config+ - configtype: objectSchema:properties:@@ -2188,8 +2191,8 @@ components:$ref: '#/components/schemas/DataTable'type: arrayrequired:- - name- - tables+ - name+ - tablestype: objectSchemaColumn:properties:@@ -2201,9 +2204,9 @@ components:type:type: stringrequired:- - name- - type- - sampleValues+ - name+ - type+ - sampleValuestype: objectSchemaTable:properties:@@ -2214,14 +2217,14 @@ components:name:type: stringrequired:- - name- - columns+ - name+ - columnstype: objectSecretKeysResult:properties:name:enum:- - secret-keys-result+ - secret-keys-resulttype: stringrequest_id:type: string@@ -2230,9 +2233,9 @@ components:$ref: '#/components/schemas/SecretKeysWithProvider'type: arrayrequired:- - request_id- - secrets- - name+ - request_id+ - secrets+ - nametype: objectSecretKeysWithProvider:properties:@@ -2244,13 +2247,13 @@ components:type: stringprovider:enum:- - env- - dotenv+ - env+ - dotenvtype: stringrequired:- - provider- - name- - keys+ - provider+ - name+ - keystype: objectSendUIElementMessage:properties:@@ -2267,14 +2270,14 @@ components:type: stringname:enum:- - send-ui-element-message+ - send-ui-element-messagetype: stringui_element:nullable: truetype: stringrequired:- - message- - name+ - message+ - nametype: objectSetCellConfigRequest:properties:@@ -2284,7 +2287,7 @@ components:type: objecttype: objectrequired:- - configs+ - configstype: objectSetModelMessageRequest:properties:@@ -2299,22 +2302,22 @@ components:items:items:oneOf:- - type: string- - type: integer+ - type: string+ - type: integertype: arraytype: arraystate:additionalProperties: {}type: objectrequired:- - state- - bufferPaths+ - state+ - bufferPathstype: objectmodelId:type: stringrequired:- - modelId- - message+ - modelId+ - messagetype: objectSetUIElementValueRequest:properties:@@ -2331,43 +2334,43 @@ components:items: {}type: arrayrequired:- - objectIds- - values- - token+ - objectIds+ - values+ - tokentype: objectSetUserConfigRequest:properties:config:$ref: '#/components/schemas/MarimoConfig'required:- - config+ - configtype: objectSetupRootError:properties:edges_with_vars:items:prefixItems:- - type: string- - items:- type: string- type: array- - type: string+ - type: string+ - items:+ type: string+ type: array+ - type: stringtype: arraytype: arraytype:enum:- - setup-refs+ - setup-refstype: stringrequired:- - edges_with_vars- - type+ - edges_with_vars+ - typetype: objectShutdownSessionRequest:properties:sessionId:type: stringrequired:- - sessionId+ - sessionIdtype: objectSnippet:properties:@@ -2378,8 +2381,8 @@ components:title:type: stringrequired:- - title- - sections+ - title+ - sectionstype: objectSnippetSection:properties:@@ -2392,7 +2395,7 @@ components:id:type: stringrequired:- - id+ - idtype: objectSnippets:properties:@@ -2401,14 +2404,14 @@ components:$ref: '#/components/schemas/Snippet'type: arrayrequired:- - snippets+ - snippetstype: objectStdinRequest:properties:text:type: stringrequired:- - text+ - texttype: objectStopRequest:properties: {}@@ -2418,7 +2421,7 @@ components:success:type: booleanrequired:- - success+ - successtype: objectUnknownError:properties:@@ -2426,11 +2429,11 @@ components:type: stringtype:enum:- - unknown+ - unknowntype: stringrequired:- - msg- - type+ - msg+ - typetype: objectUpdateCellCodes:properties:@@ -2446,13 +2449,13 @@ components:type: arrayname:enum:- - update-cell-codes+ - update-cell-codestype: stringrequired:- - cell_ids- - codes- - code_is_stale- - name+ - cell_ids+ - codes+ - code_is_stale+ - nametype: objectUpdateCellIdsRequest:properties:@@ -2462,11 +2465,11 @@ components:type: arrayname:enum:- - update-cell-ids+ - update-cell-idstype: stringrequired:- - cell_ids- - name+ - cell_ids+ - nametype: objectUpdateComponentValuesRequest:properties:@@ -2478,8 +2481,8 @@ components:items: {}type: arrayrequired:- - objectIds- - values+ - objectIds+ - valuestype: objectVariableContext:properties:@@ -2489,9 +2492,9 @@ components:valueType:type: stringrequired:- - name- - valueType- - previewValue+ - name+ - valueType+ - previewValuetype: objectVariableDeclaration:properties:@@ -2506,9 +2509,9 @@ components:type: stringtype: arrayrequired:- - name- - declared_by- - used_by+ - name+ - declared_by+ - used_bytype: objectVariableValue:properties:@@ -2521,42 +2524,42 @@ components:nullable: truetype: stringrequired:- - name+ - nametype: objectVariableValues:properties:name:enum:- - variable-values+ - variable-valuestype: stringvariables:items:$ref: '#/components/schemas/VariableValue'type: arrayrequired:- - variables- - name+ - variables+ - nametype: objectVariables:properties:name:enum:- - variables+ - variablestype: stringvariables:items:$ref: '#/components/schemas/VariableDeclaration'type: arrayrequired:- - variables- - name+ - variables+ - nametype: objectWorkspaceFilesRequest:properties:includeMarkdown:type: booleanrequired:- - includeMarkdown+ - includeMarkdowntype: objectWorkspaceFilesResponse:properties:@@ -2567,8 +2570,8 @@ components:root:type: stringrequired:- - root- - files+ - root+ - filestype: objectinfo:title: marimo API@@ -2578,12 +2581,12 @@ paths:/@file/{filename_and_length}:get:parameters:- - description: The filename and byte length of the virtual file- in: path- name: filename_and_length- required: true- schema:- type: string+ - description: The filename and byte length of the virtual file+ in: path+ name: filename_and_length+ required: true+ schema:+ type: stringresponses:200:content:@@ -3403,7 +3406,7 @@ paths:percent:type: numberrequired:- - percent+ - percenttype: objectgpu:items:@@ -3421,17 +3424,17 @@ paths:used:type: integerrequired:- - total- - used- - free- - percent+ - total+ - used+ - free+ - percenttype: objectname:type: stringrequired:- - index- - memory- - name+ - index+ - memory+ - nametype: objecttype: arraykernel:@@ -3452,22 +3455,22 @@ paths:used:type: integerrequired:- - total- - available- - percent- - used- - free+ - total+ - available+ - percent+ - used+ - freetype: objectserver:properties:memory:type: integerrequired:- - memory+ - memorytype: objectrequired:- - memory- - cpu+ - memory+ - cputype: objectdescription: Get the current memory and CPU usage of the application/api/version:@@ -3505,5 +3508,4 @@ paths:type: stringsummary: Submit login formtags:- - auth-+ - authdiff --git a/openapi/src/api.ts b/openapi/src/api.tsindex ed69036f71..04af119bc0 100644--- a/openapi/src/api.ts+++ b/openapi/src/api.ts@@ -2462,6 +2462,7 @@ export interface components {schemas: {AddPackageRequest: {package: string;+ upgrade?: boolean | null;};AiCompletionContext: {schema: components["schemas"]["SchemaTable"][];diff --git a/tests/_runtime/packages/test_package_managers.py b/tests/_runtime/packages/test_package_managers.pyindex df22e57208..adedf15f27 100644--- a/tests/_runtime/packages/test_package_managers.py+++ b/tests/_runtime/packages/test_package_managers.py@@ -38,7 +38,10 @@ def test_update_script_metadata() -> None:pm = MockUvPackageManager()pm.update_notebook_script_metadata(- "nb.py", packages_to_add=["foo"], packages_to_remove=["bar"]+ "nb.py",+ packages_to_add=["foo"],+ packages_to_remove=["bar"],+ upgrade=False,)assert runs_calls == [["uv", "--quiet", "add", "--script", "nb.py", "foo==1.0"],@@ -62,11 +65,15 @@ def test_update_script_metadata_with_version_map() -> None:pm = MockUvPackageManager()# It should ignore when not in the version map# as this implies it failed to install- pm.update_notebook_script_metadata("nb.py", packages_to_add=["baz"])+ pm.update_notebook_script_metadata(+ "nb.py", packages_to_add=["baz"], upgrade=False+ )assert runs_calls == []# It will attempt to uninstall even if not in the version map- pm.update_notebook_script_metadata("nb.py", packages_to_remove=["baz"])+ pm.update_notebook_script_metadata(+ "nb.py", packages_to_remove=["baz"], upgrade=False+ )assert runs_calls == [["uv", "--quiet", "remove", "--script", "nb.py", "baz"],]@@ -85,7 +92,9 @@ def test_update_script_metadata_with_mapping() -> None:pm = MockUvPackageManager()# It should not canonicalize when passed explicitly- pm.update_notebook_script_metadata("nb.py", packages_to_add=["ibis"])+ pm.update_notebook_script_metadata(+ "nb.py", packages_to_add=["ibis"], upgrade=False+ )assert runs_calls == [["uv", "--quiet", "add", "--script", "nb.py", "ibis==2.0"],]@@ -94,7 +103,7 @@ def test_update_script_metadata_with_mapping() -> None:# It should not canonicalize when passed as an import name# case-insensitivepm.update_notebook_script_metadata(- "nb.py", import_namespaces_to_add=["yaml"]+ "nb.py", import_namespaces_to_add=["yaml"], upgrade=False)assert runs_calls == [["uv", "--quiet", "add", "--script", "nb.py", "PyYAML==1.0"],@@ -104,7 +113,7 @@ def test_update_script_metadata_with_mapping() -> None:# It should not canonicalize when passed as an import name# and works with bracketspm.update_notebook_script_metadata(- "nb.py", import_namespaces_to_add=["ibis"]+ "nb.py", import_namespaces_to_add=["ibis"], upgrade=False)assert runs_calls == [[@@ -142,6 +151,7 @@ def test_update_script_metadata_marimo_packages() -> None:"marimo-ai", # Should have version (different package)"pandas", # Should have version],+ upgrade=False,)assert runs_calls == [[@@ -164,6 +174,7 @@ def test_update_script_metadata_marimo_packages() -> None:"marimo[sql]","pandas",],+ upgrade=False,)assert runs_calls == [[@@ -188,6 +199,7 @@ def test_update_script_metadata_marimo_packages() -> None:"marimo[recommended]","pandas",],+ upgrade=False,)assert runs_calls == [[@@ -211,6 +223,7 @@ def test_update_script_metadata_marimo_packages() -> None:"marimo","pandas",],+ upgrade=False,)assert runs_calls == [[@@ -225,6 +238,25 @@ def test_update_script_metadata_marimo_packages() -> None:]runs_calls.clear()+ # Test 5: Upgrade+ pm.update_notebook_script_metadata(+ filepath="nb.py",+ packages_to_add=["pandas"],+ upgrade=True,+ )+ assert runs_calls == [+ [+ "uv",+ "--quiet",+ "add",+ "--script",+ "nb.py",+ "--upgrade",+ "pandas==2.0.0",+ ],+ ]+ runs_calls.clear()+async def test_uv_pip_install() -> None:runs_calls: list[list[str]] = []@@ -235,7 +267,7 @@ async def test_uv_pip_install() -> None:return Truepm = MockUvPackageManager()- await pm._install("foo")+ await pm._install("foo", upgrade=False)assert runs_calls == [["uv", "pip", "install", "--compile", "foo", "-p", PY_EXE],]diff --git a/tests/_runtime/packages/test_pypi_package_manager.py b/tests/_runtime/packages/test_pypi_package_manager.pyindex d7cc996b32..978d822ca7 100644--- a/tests/_runtime/packages/test_pypi_package_manager.py+++ b/tests/_runtime/packages/test_pypi_package_manager.py@@ -44,7 +44,7 @@ manager = PipPackageManager()async def test_install(mock_run: MagicMock):mock_run.return_value = MagicMock(returncode=0)- result = await manager._install("package1 package2")+ result = await manager._install("package1 package2", upgrade=False)mock_run.assert_called_once_with(["pip", "--python", PY_EXE, "install", "package1", "package2"],@@ -56,7 +56,7 @@ async def test_install(mock_run: MagicMock):async def test_install_failure(mock_run: MagicMock):mock_run.return_value = MagicMock(returncode=1)- result = await manager._install("nonexistent-package")+ result = await manager._install("nonexistent-package", upgrade=False)assert result is False@@ -199,7 +199,7 @@ async def test_uv_install_not_in_project(mock_run: MagicMock):mock_run.return_value = MagicMock(returncode=0)mgr = UvPackageManager()- result = await mgr._install("package1 package2")+ result = await mgr._install("package1 package2", upgrade=False)mock_run.assert_called_once_with([@@ -223,7 +223,7 @@ async def test_uv_install_in_project(mock_run: MagicMock):mock_run.return_value = MagicMock(returncode=0)mgr = UvPackageManager()- result = await mgr._install("package1 package2")+ result = await mgr._install("package1 package2", upgrade=False)mock_run.assert_called_once_with(["uv", "add", "--compile", "package1", "package2", "-p", PY_EXE],@@ -283,3 +283,74 @@ def test_uv_list_packages(mock_run: MagicMock):assert len(packages) == 2assert packages[0] == PackageDescription(name="package1", version="1.0.0")assert packages[1] == PackageDescription(name="package2", version="2.1.0")+++@patch("subprocess.run")[email protected](PipPackageManager, "is_manager_installed", return_value=True)+async def test_install_with_upgrade(+ mock_is_installed: MagicMock, mock_run: MagicMock+):+ del mock_is_installed+ mock_run.return_value = MagicMock(returncode=0)++ result = await manager._install("package1", upgrade=True)++ mock_run.assert_called_once_with(+ ["pip", "--python", PY_EXE, "install", "--upgrade", "package1"],+ )+ assert result is True+++@patch("subprocess.run")[email protected](PipPackageManager, "is_manager_installed", return_value=True)+async def test_install_without_upgrade(+ mock_is_installed: MagicMock, mock_run: MagicMock+):+ del mock_is_installed+ mock_run.return_value = MagicMock(returncode=0)++ result = await manager._install("package1", upgrade=False)++ mock_run.assert_called_once_with(+ ["pip", "--python", PY_EXE, "install", "package1"],+ )+ assert result is True+++@patch("subprocess.run")[email protected](UvPackageManager, "is_in_uv_project", False)+async def test_uv_install_with_upgrade_not_in_project(mock_run: MagicMock):+ """Test UV install with upgrade uses pip subcommand when not in UV project"""+ mock_run.return_value = MagicMock(returncode=0)+ mgr = UvPackageManager()++ result = await mgr._install("package1", upgrade=True)++ mock_run.assert_called_once_with(+ [+ "uv",+ "pip",+ "install",+ "--upgrade",+ "--compile",+ "package1",+ "-p",+ PY_EXE,+ ]+ )+ assert result is True+++@patch("subprocess.run")[email protected](UvPackageManager, "is_in_uv_project", True)+async def test_uv_install_with_upgrade_in_project(mock_run: MagicMock):+ """Test UV install with upgrade uses add subcommand when in UV project"""+ mock_run.return_value = MagicMock(returncode=0)+ mgr = UvPackageManager()++ result = await mgr._install("package1", upgrade=True)++ mock_run.assert_called_once_with(+ ["uv", "add", "--upgrade", "--compile", "package1", "-p", PY_EXE]+ )+ assert result is Truediff --git a/tests/_server/api/endpoints/test_packages.py b/tests/_server/api/endpoints/test_packages.pyindex 84da5df98e..e32f58b18a 100644--- a/tests/_server/api/endpoints/test_packages.py+++ b/tests/_server/api/endpoints/test_packages.py@@ -51,7 +51,7 @@ def test_add_package(client: TestClient, mock_package_manager: Mock) -> None:assert response.status_code == 200assert response.json() == {"success": True, "error": None}mock_package_manager.install.assert_called_once_with(- "test-package", version=None+ "test-package", version=None, upgrade=False)@@ -134,3 +134,35 @@ def test_remove_package_failure("success": False,"error": "Failed to uninstall test-package. See terminal for error logs.", # noqa: E501}+++def test_add_package_with_upgrade(+ client: TestClient, mock_package_manager: Mock+) -> None:+ assert isinstance(mock_package_manager, MagicMock)+ response = client.post(+ "/api/packages/add",+ headers=HEADERS,+ json={"package": "test-package", "upgrade": True},+ )+ assert response.status_code == 200+ assert response.json() == {"success": True, "error": None}+ mock_package_manager.install.assert_called_once_with(+ "test-package", version=None, upgrade=True+ )+++def test_add_package_without_upgrade(+ client: TestClient, mock_package_manager: Mock+) -> None:+ assert isinstance(mock_package_manager, MagicMock)+ response = client.post(+ "/api/packages/add",+ headers=HEADERS,+ json={"package": "test-package", "upgrade": False},+ )+ assert response.status_code == 200+ assert response.json() == {"success": True, "error": None}+ mock_package_manager.install.assert_called_once_with(+ "test-package", version=None, upgrade=False+ )