Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,8 @@ test = [ # dependencies used for running tests
"mypy",
"gcovr; sys_platform != 'win32' or platform_machine != 'ARM64'",
"gcsfs; sys_platform != 'win32' or platform_machine != 'ARM64'",
"ipykernel",
"ipywidgets",
"packaging",
"polars>=1.33.0",
"psutil",
Expand Down
18 changes: 13 additions & 5 deletions src/jupyter/jupyter_progress_bar_display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ void JupyterProgressBarDisplay::Initialize() {
// Initialize the progress bar
nb::dict style;
style["bar_color"] = "black";
progress_bar = float_progress_attr((nb::arg("min") = 0, nb::arg("max") = 100, nb::arg("style") = style));
progress_bar = float_progress_attr(nb::arg("min") = 0, nb::arg("max") = 100, nb::arg("style") = style);

progress_bar.attr("layout").attr("width") = "auto";

Expand All @@ -31,11 +31,19 @@ JupyterProgressBarDisplay::JupyterProgressBarDisplay() : ProgressBarDisplay() {

void JupyterProgressBarDisplay::Update(double progress) {
nb::gil_scoped_acquire gil;
if (progress_bar.ptr() == nullptr) {
// First print, we first need to initialize the display
Initialize();
try {
if (progress_bar.ptr() == nullptr) {
// First print, we first need to initialize the display
Initialize();
}
progress_bar.attr("value") = nb::cast(progress);
} catch (nb::python_error &error) {
if (!error.matches(PyExc_KeyboardInterrupt)) {
throw;
}
// Raising here consumed the signal; set it again so the query's own interrupt check stops the query
PyErr_SetInterrupt();
}
progress_bar.attr("value") = nb::cast(progress);
}

void JupyterProgressBarDisplay::Finish() {
Expand Down
Loading
Loading