rsalmei / alive-progress

A new kind of Progress Bar, with real-time throughput, ETA, and very cool animations!
MIT License
5.53k stars 206 forks source link

Windows lame font #161

Closed dorphalsig closed 2 years ago

dorphalsig commented 2 years ago

Hey guys, first of all let me say this thing is amazing, and super simple to get off the ground. Kudos on that!!

Now for my issues: I am querying a db for results every second or so, so my progress is not nice and linear, the main bar goes super chunky, which I guess its ok, because its the discrete amount of work that has been completed, but the side thingy that goes up and down besides the ETA is suuuuper chunky even though I've set calibrate=0.8. Here's the piece of code...

Now I have another operation with everything unknown, which I also check about every 2 secs, With the same calibrate the main bar looks smooth-ish (with hiccups every so often), and the side thingy is also suuuuuper chunky.

I'm not sure if this is a bug, but any guidance would be much appreciated, thanks!

Snippet 1: Discrete non-linear steps

def import_files(src, dst, num) -> set:
    print("Copying files...")
    # returns a set of the ctual names of the files copied
    copied_files = copy_file(src, dst, num)
    total_files = len(copied_files)
    print("Waiting for IMM to import the files")
    t0 = datetime.now()
    with alive_bar(total_files, manual=True, calibrate=0.6) as bar:
        while (imported := len(copied_files - set(os.listdir(dst)))) < total_files:
            t1 = datetime.now()
            if (t0 - t1).total_seconds() > MAX_WAIT:
                raise Exception("Hotfolder import failed. Please double check.")
            bar((imported + 1) / total_files)
            sleep(3)

Snppet 2: Unknown with large-ish time gaps

def wait(dnumbers):
    dnumbers_text = "','".join(dnumbers)
    t0 = datetime.now()
    statement_fpro = f"select COUNT(*) from fprotokoll where FPRO_XCN_KEY in ('{dnumbers_text}')"
    statement_fwfl = f"select COUNT(*) from f_wflcall where WFCL_PNR in ('{dnumbers_text}')"
    # statement_mq = "select count(*) from f_msgqueue"
    with alive_bar(unknown='fishes', monitor=False, calibrate=0.8) as bar:
        while (numrows := CONN.execute(f"select ({statement_fpro}) + ({statement_fwfl})").fetchval()) > 0:
            t1 = datetime.now()
            if (t0 - t1).total_seconds() > MAX_WAIT:
                raise Exception("Timeout while waiting for completion. Please double check logs.")
            bar()
            sleep(2)
rsalmei commented 2 years ago

Hey, thanks man!

Please, make an animated gif or a video, I can't imagine what you mean by "super chunky". And since the codes you provided are not runnable snippets, I can't run them either.

What I can say now, is that your calibrate is way too low... Remember calibrate sets a linear regression between 4 and 60 frames per second, which is a big range. When you set calibrate=0.6, it means when only 0.6 updates are done in a sec (3 in 5 secs), the bar will jump from 4 to 60 fps! That's waaay too fast, and perhaps that's what you mean by "chunky". The bar gets super-sensitive that way. I always recommend setting it to at least 2x to 3x your expected maximum for best results.

dorphalsig commented 2 years ago

Hey, so I simplified the example its now

def testit(v1,v2,v3):
    cls()
    for c in (v1,v2,v3):
        with alive_bar(100,calibrate=c) as bar:
            for i in range(10):
                time.sleep(2)
                bar(10)

tested it with 5e4,5e2,50 I'm pretty sure I have not been able to get a correct calibrate value? and this is what I get.. test .

rsalmei commented 2 years ago

First of all, let's try to fix those weird characters... Install some nerd-fonts and configure your terminal to use any.

Second, instead of pure Python, I strongly recommend ipython. Just pip install ipython, it is way better to interact with code.

And lastly, given your example numbers, it seems 50 to 100 would be the best calibrations.

dorphalsig commented 2 years ago

Installing nerd fonts did the trick, now it all makes sense. Also since I cant install this stuff @ the customer's I'll just use the crab spinner. thanks!!

TheTechRobo commented 2 years ago

Microsoft needs to use an actually usable font in cmd. I get that the all-new, shining Windows Terminal is supposed to replace it, but still