jo-jstrm / SmartHomeBuddy

GNU General Public License v3.0
4 stars 0 forks source link

Read: Extract current progress from JIT code and send it to GUI #105

Open jo-jstrm opened 1 year ago

jo-jstrm commented 1 year ago

Aim

Get accurate progress of read displayed in the GUI.

Problem

One cannot simply wrap the numba ProgressBar apparently. Basically I would like to not only update the CLI progress bar, but also send an update via RPC, i.e. call a regular Python function on each update.

I tried replacing the numba ProgressBar with the following, which resulted in weird errors.

from numba_progress import ProgressBar

from ..rpc.client import ReadUpdateClient

class PacketProgressBar(ProgressBar):
    def __init__(self, **kwargs):
        super().__init__(kwargs)
        self.client = ReadUpdateClient()
        self.total_num_packets = kwargs["total"]

    def update(self, value: int):
        super().update(value)
        pct = int(100 * value / self.total_num_packets)
        self.client.send_update(pct)
TB-DevAcc commented 1 year ago

106 does not add a progress bar, but adds a backdrop and spinner to show that something is being done.