Skip to content

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.

fix: emit some errors to stderr (#2399)

Akshay Agrawald1b6016ba8c9
diff --git a/marimo/_plugins/ui/_impl/input.py b/marimo/_plugins/ui/_impl/input.py
index 643c3d5280..39fb878974 100644
--- a/marimo/_plugins/ui/_impl/input.py
+++ b/marimo/_plugins/ui/_impl/input.py
@@ -5,6 +5,7 @@ import base64
import dataclasses
import os
import pathlib
+import sys
import traceback
from dataclasses import dataclass
from typing import (
@@ -229,9 +230,9 @@ class slider(UIElement[Numeric, Numeric]):
value = steps[0] if value is None else value
value = steps.index(value)
except ValueError:
- print(
+ sys.stderr.write(
"Value out of bounds: default value should be in the steps"
- ", set to first value."
+ ", set to first value.\n"
)
value = 0
except AssertionError as e:
@@ -411,9 +412,9 @@ class range_slider(UIElement[List[Numeric], Sequence[Numeric]]):
value = [steps[0], steps[-1]] if value is None else value
value = [steps.index(num) for num in value]
except ValueError:
- print(
+ sys.stderr.write(
"Value out of bounds: default value should be in the"
- "steps, set to first and last values."
+ "steps, set to first and last values.\n"
)
value = [0, len(steps) - 1]
except AssertionError as e:
@@ -1151,10 +1152,9 @@ class button(UIElement[Any, Any]):
try:
return self._on_click(self._value)
except Exception:
- LOGGER.error(
- "on_click handler for button (%s) raised an Exception:\n %s ",
- str(self),
- traceback.format_exc(),
+ sys.stderr.write(
+ "on_click handler for button (%s) raised an Exception:\n %s\n"
+ % (str(self), traceback.format_exc())
)
return None
diff --git a/marimo/_server/models/packages.py b/marimo/_server/models/packages.py
index b7d6ee48be..ab182b3a7a 100644
--- a/marimo/_server/models/packages.py
+++ b/marimo/_server/models/packages.py
@@ -1,3 +1,4 @@
+# Copyright 2024 Marimo. All rights reserved.
from __future__ import annotations
from dataclasses import dataclass