From 1a31e0994cf96e2f6a19724a0065d7c9f252ba27 Mon Sep 17 00:00:00 2001 From: ebolam Date: Mon, 19 Sep 2022 09:40:49 -0400 Subject: [PATCH] Colab Fix --- koboldai_settings.py | 2 +- utils.py | 9 ++++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/koboldai_settings.py b/koboldai_settings.py index c91253cd..1989ce62 100644 --- a/koboldai_settings.py +++ b/koboldai_settings.py @@ -502,7 +502,7 @@ class model_settings(settings): self.tqdm_progress = 0 else: self.tqdm.update(value-old_value) - self.tqdm_progress = round(float(self.downloaded_chunks)/float(self.total_download_chunks)*100, 1) + self.tqdm_progress = 0 if self.total_download_chunks==0 else round(float(self.downloaded_chunks)/float(self.total_download_chunks)*100, 1) if self.tqdm.format_dict['rate'] is not None: self.tqdm_rem_time = str(datetime.timedelta(seconds=int(float(self.total_download_chunks-self.downloaded_chunks)/self.tqdm.format_dict['rate']))) diff --git a/utils.py b/utils.py index cb3721c6..91fc5abc 100644 --- a/utils.py +++ b/utils.py @@ -212,10 +212,6 @@ def _download_with_aria2(aria2_config: str, total_length: int, directory: str = p.terminate() done = True break - if bar is None: - bar = tqdm(total=total_length, desc=f"[aria2] Downloading model", unit="B", unit_scale=True, unit_divisor=1000) - koboldai_vars.total_download_chunks = total_length - visited = set() for x in r: filename = x["files"][0]["path"] lengths[filename] = (int(x["completedLength"]), int(x["totalLength"])) @@ -223,8 +219,11 @@ def _download_with_aria2(aria2_config: str, total_length: int, directory: str = for k, v in lengths.items(): if k not in visited: lengths[k] = (v[1], v[1]) + if bar is None: + bar = tqdm(total=total_length, desc=f"[aria2] Downloading model", unit="B", unit_scale=True, unit_divisor=1000) + koboldai_vars.total_download_chunks = sum(v[1] for v in lengths.values()) + visited = set() koboldai_vars.downloaded_chunks = sum(v[0] for v in lengths.values()) - koboldai_vars.total_download_chunks = sum(v[1] for v in lengths.values()) bar.n = koboldai_vars.downloaded_chunks bar.update() time.sleep(0.1)