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.

Allow progress bar rate calculation when rate display is disabled (#5024)

alex175a82ef2f3f
diff --git a/marimo/_plugins/stateless/status/_progress.py b/marimo/_plugins/stateless/status/_progress.py
index 871d7455b7..7d4a367f7d 100644
--- a/marimo/_plugins/stateless/status/_progress.py
+++ b/marimo/_plugins/stateless/status/_progress.py
@@ -126,19 +126,22 @@ class _Progress(Html):
),
)
+ def _calculate_rate(self) -> Optional[float]:
+ diff = time.time() - self.start_time
+ if diff == 0:
+ return None
+ rate = self.current / diff
+ return round(rate, 2)
+
def _get_rate(self) -> Optional[float]:
if self.show_rate:
- diff = time.time() - self.start_time
- if diff == 0:
- return None
- rate = self.current / diff
- return round(rate, 2)
+ return self._calculate_rate()
else:
return None
def _get_eta(self) -> Optional[float]:
if self.show_eta and self.total is not None:
- rate = self._get_rate()
+ rate = self._calculate_rate()
if rate is not None and rate > 0:
return round((self.total - self.current) / rate, 2)
else:
diff --git a/tests/_convert/test_ipynb.py b/tests/_convert/test_ipynb.py
index 138ea908ed..785eb3f540 100644
--- a/tests/_convert/test_ipynb.py
+++ b/tests/_convert/test_ipynb.py
@@ -148,6 +148,7 @@ def test_transform_add_marimo_import():
]
assert transform_add_marimo_import(existing) == existing
+
def test_transform_magic_commands():
sources = [
"%%sql\nSELECT * FROM table",