Skip to content

Commit

Permalink
many fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
xtianpoli committed Nov 3, 2024
1 parent ee074f1 commit 62ee474
Show file tree
Hide file tree
Showing 6 changed files with 140 additions and 34 deletions.
3 changes: 2 additions & 1 deletion ipyprogressivis/widgets/chaining/aggregate.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from .utils import (make_button, stage_register, VBoxTyped, TypedBase,
amend_last_record, get_recording_state, disable_all, runner)
amend_last_record, get_recording_state, disable_all, runner, needs_dtypes)
import ipywidgets as ipw
import pandas as pd
from progressivis.table.api import Aggregate
Expand All @@ -21,6 +21,7 @@ class Typed(TypedBase):
freeze_ck: ipw.Checkbox
start_btn: ipw.Button

@needs_dtypes
def initialize(self) -> None:
self.hidden_cols: List[str] = []
fncs = ["hide"] + list(Aggregate.registry.keys())
Expand Down
6 changes: 2 additions & 4 deletions ipyprogressivis/widgets/chaining/code_cell.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from .utils import (VBoxTyped, TypedBase, stage_register,
make_replay_next_btn, is_replay_only)
from .utils import VBoxTyped, TypedBase, stage_register

import ipywidgets as ipw

Expand All @@ -9,8 +8,7 @@ class Typed(TypedBase):
dongle: ipw.Label | ipw.Button

def initialize(self) -> None:
self.c_.dongle = (make_replay_next_btn() if is_replay_only()
else ipw.Label("Chaining ..."))
self.c_.dongle = ipw.Label("Code cell")


stage_register["Python"] = CodeCellW
19 changes: 14 additions & 5 deletions ipyprogressivis/widgets/chaining/constructor.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
bunpack,
replay_list,
replay_next,
replay_sequence,
b642json,
PARAMS,
reset_recorder,
Expand Down Expand Up @@ -97,6 +98,7 @@ def __init__(
PARAMS["replay_before_resume"] = False
PARAMS["step_by_step"] = False
PARAMS["deleted_stages"] = set()
PARAMS["command_list"] = []
set_recording_state(False)

def _locked(self) -> bool:
Expand Down Expand Up @@ -181,7 +183,7 @@ def _record_cb(self, change: dict[str, AnyType]) -> None:
restore_recorder()
set_recording_state(False)

def do_replay(self) -> None:
def do_replay(self, batch: bool = False) -> None:
PARAMS["is_replay"] = True
self.child.csv.children[-1].disabled = True
self.child.parquet.children[-1].disabled = True
Expand All @@ -194,7 +196,10 @@ def do_replay(self) -> None:
replay_list.append({}) # end of tape marker
# chaining_boxes_to_make.clear()
disable_all(self)
replay_next(self)
if batch:
replay_sequence(self)
else:
replay_next(self)

def disable_all_btn(self) -> None:
self.child.replay.disabled = True
Expand All @@ -203,18 +208,22 @@ def disable_all_btn(self) -> None:

def _replay_cb(self, btn: ipw.Button) -> None:
self.disable_all_btn()
self.do_replay()
self.do_replay(batch=True)

def _resume_cb(self, btn: ipw.Button) -> None:
self.disable_all_btn()
PARAMS["replay_before_resume"] = True
reset_recorder()
set_recording_state(True)
self.do_replay()
self.do_replay(batch=True)

def _step_by_step_cb(self, btn: ipw.Button) -> None:
PARAMS["step_by_step"] = True
self._resume_cb(btn)
self.disable_all_btn()
PARAMS["replay_before_resume"] = True
reset_recorder()
set_recording_state(True)
self.do_replay(batch=False)

@staticmethod
def widget_by_id(key: int) -> NodeCarrier:
Expand Down
5 changes: 2 additions & 3 deletions ipyprogressivis/widgets/chaining/custom_loader.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from .utils import VBoxTyped, TypedBase, make_replay_next_btn, is_replay_only
from .utils import VBoxTyped, TypedBase
import ipywidgets as ipw


Expand All @@ -7,5 +7,4 @@ class Typed(TypedBase):
dongle: ipw.Label | ipw.Button

def initialize(self) -> None:
self.c_.dongle = (make_replay_next_btn() if is_replay_only()
else ipw.Label("Custom loader"))
self.c_.dongle = ipw.Label("Custom loader")
3 changes: 2 additions & 1 deletion ipyprogressivis/widgets/chaining/group_by.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from .utils import (make_button, stage_register, dongle_widget, VBoxTyped,
TypedBase, amend_last_record,
get_recording_state, disable_all, runner)
get_recording_state, disable_all, runner, needs_dtypes)
import ipywidgets as ipw
from progressivis.core.api import Module, Sink
from progressivis.table.group_by import (
Expand Down Expand Up @@ -31,6 +31,7 @@ class Typed(TypedBase):
freeze_ck: ipw.Checkbox
start_btn: ipw.Button

@needs_dtypes
def initialize(self) -> None:
self.child.grouping_mode = self.make_gr_mode()
self.child.by_box = self.make_sel_multiple()
Expand Down
Loading

0 comments on commit 62ee474

Please sign in to comment.