genomescan / gsport

3 stars 3 forks source link

ZeroDivisionError on project with an dash #6

Open mmterpstra opened 2 years ago

mmterpstra commented 2 years ago

I keep having this with a project with the project name matching \d{6}-\d{3} eg 100001-001. Tried it with a regular project matching \d{6} and this works... (also gives the same error on 1.6.2).

command ran

 (for p in "100001-001"; do (GSDIR="./20220705_${p}"; mkdir -p "$GSDIR" && cd "$GSDIR"; gsport -p "$p" -a -r ); done)
Traceback (most recent call last):
  File "/path/to/gsport/1.6.1-foss-2018b-Python-3.7.4/bin/gsport", line 8, in <module>
    sys.exit(main())
  File "/path/to/gsport/1.6.1-foss-2018b-Python-3.7.4/lib/python3.7/site-packages/gsport.py", line 445, in main
    download_all(session)
  File "//path/to/gsport/1.6.1-foss-2018b-Python-3.7.4/lib/python3.7/site-packages/gsport.py", line 428, in download_all
    "ETA:", human_readable_eta((dl_sum - downloaded_bytes) / rate),
ZeroDivisionError: float division by zero
mmterpstra commented 2 years ago

here is the same error in 1.6.2:

Traceback (most recent call last):
  File "/home/terpstramm/.local/bin/gsport", line 11, in <module>
    sys.exit(main())
  File "/home/terpstramm/.local/lib/python3.6/site-packages/gsport.py", line 455, in main
    download_all(session)
  File "/home/terpstramm/.local/lib/python3.6/site-packages/gsport.py", line 438, in download_all
    "ETA:", human_readable_eta((dl_sum - downloaded_bytes) / rate),
ZeroDivisionError: float division by zero
hzpc-joostk commented 2 years ago

Interesting. I tweaked gsport myself and got rid of that ETA. It would be nice to replace that code with a decent progress indicator like tqdm. If you don't need it, just comment out lines 433-439 (and perhaps comment lines 240-244 and add pass in the same indent block to prevent an IndentationError).

You can also try to add + 1 to rate at line 432 to make sure it is never zero (with the side effect that the ETA is a little off).

 432   │         rate = downloaded_bytes // (time.time() - start) + 1

I am not working for GenomeScan, nor do I maintain this program. ;-)

mmterpstra commented 2 years ago

Thanks!

fixed with:

            if rate > 0:
                  print("\r", str(round(downloaded_bytes / dl_sum * 100))+"%",
                      "Downloading", sizeofmetric_fmt(downloaded_bytes), "of",
                      sizeofmetric_fmt(dl_sum),
                      str(sizeofmetric_fmt(rate)) + "/sec",
                      "ETA:", human_readable_eta((dl_sum - downloaded_bytes) / rate),
                      end='     ')
            elif rate == 0:
                   print("\r", str(round(downloaded_bytes / dl_sum * 100))+"%",
                      "Downloading", sizeofmetric_fmt(downloaded_bytes), "of",
                      sizeofmetric_fmt(dl_sum),
                      str(sizeofmetric_fmt(rate)) + "/sec",
                      "ETA:", "Never",
                      end='     ')

It seems to start the download. Although still a bit jank probably due to my setup... ( it seems to work by only downloading the Demux folder --cd Demux though...)

hzpc-joostk commented 2 years ago

"Never", nice fix. 😄