Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update progress bar only once every 100ms #717

Merged
merged 1 commit into from
Feb 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ramalama/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ def configure_arguments(parser):
dest="ngl",
type=int,
default=config.get("ngl", -1),
help="Number of layers to offload to the gpu, if available"
help="Number of layers to offload to the gpu, if available",
)
parser.add_argument(
"--keep-groups",
Expand Down
3 changes: 2 additions & 1 deletion ramalama/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
MNT_FILE = f"{MNT_DIR}/model.file"
HTTP_RANGE_NOT_SATISFIABLE = 416

DEFAULT_IMAGE="quay.io/ramalama/ramalama"
DEFAULT_IMAGE = "quay.io/ramalama/ramalama"


def container_manager():
engine = os.getenv("RAMALAMA_CONTAINER_ENGINE")
Expand Down
9 changes: 8 additions & 1 deletion ramalama/http_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,21 @@ def perform_download(self, file, progress):
self.total_to_download += self.file_size
self.now_downloaded = 0
self.start_time = time.time()
accumulated_size = 0
last_update_time = time.time()
while True:
data = self.response.read(1024)
if not data:
break

size = file.write(data)
if progress:
ericcurtin marked this conversation as resolved.
Show resolved Hide resolved
self.update_progress(size)
accumulated_size += size
if time.time() - last_update_time >= 0.1:
self.now_downloaded += accumulated_size
self.update_progress(self.now_downloaded, self.total_to_download)
accumulated_size = 0
last_update_time = time.time()

def human_readable_time(self, seconds):
hrs = int(seconds) // 3600
Expand Down
Loading