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

add a progress bar when fetching packages #16463

Closed
andrewrk opened this issue Jul 21, 2023 · 7 comments · Fixed by #16548
Closed

add a progress bar when fetching packages #16463

andrewrk opened this issue Jul 21, 2023 · 7 comments · Fixed by #16548
Labels
contributor friendly This issue is limited in scope and/or knowledge of Zig internals. enhancement Solving this issue will likely involve adding new logic or components to the codebase. zig build system std.Build, the build runner, `zig build` subcommand, package management
Milestone

Comments

@andrewrk
Copy link
Member

Zig is silent while it downloads third party packages from the Internet, which could take an arbitrarily long time.

Instead, it should report the progress, network speed, and which packages it is currently on, as expected by our esteemed users.

zig/src/main.zig

Lines 4449 to 4462 in 8a18abf

const fetch_result = build_pkg.fetchAndAddDependencies(
&main_pkg,
arena,
&thread_pool,
&http_client,
build_directory,
global_cache_directory,
local_cache_directory,
&dependencies_source,
&build_roots_source,
"",
&wip_errors,
&all_modules,
);

@andrewrk andrewrk added enhancement Solving this issue will likely involve adding new logic or components to the codebase. contributor friendly This issue is limited in scope and/or knowledge of Zig internals. zig build system std.Build, the build runner, `zig build` subcommand, package management labels Jul 21, 2023
@andrewrk andrewrk added this to the 0.12.0 milestone Jul 21, 2023
@VeroAsghar
Copy link

I’m willing to attempt solving this issue! I will also respond quickly if I feel this is too far out of my wheelhouse, so that I’m not wasting anyone’s time. (I’m quite new at contributing to OSS, so I’m not sure about the normal way to show interest in a specific issue.)

@mlugg
Copy link
Member

mlugg commented Jul 21, 2023

@VeroAsghar

I'd quite like to get a basic impl of this in for 0.11 - it'll save a lot of confusion over the next few months - so would it be possible for you to try and get it done in the next week or do? I'm happy to take it on if not, I just don't like nabbing contributor-friendly issues from people.

If you want to get started with this, you can take a look at the std.Progress API. It's not the prettiest, and maybe won't satisfy all the goals here, but is fairly easy to use and definitely works for a basic impl. You're welcome to ping me here or on Discord (@mlugg) if you've got any questions :)

@VeroAsghar
Copy link

@mlugg

Thanks for the tips!
On Discord i'm (at)jva, so that you don't have to worry about a random ping.
I'll see how far I get by Monday and can tell you then if I'm able to complete it within the coming week.
Would that be okay still? Or would you like to know earlier?

@mlugg
Copy link
Member

mlugg commented Jul 21, 2023

@VeroAsghar that's totally fine, I'm not trying to rush you, just wanna get it in before 0.11 :) good luck!

@truemedian
Copy link
Contributor

A warning about this implementation: if you want to find the length of a http response you'll need to pull it from request.response.content_length, but this field will be null for chunked messages, so you'll also need a way to handle not knowing how long the response may be.

@VeroAsghar
Copy link

VeroAsghar commented Jul 23, 2023

So far I'm able to increment the progress bar by the amount of packages in the .zon file, with a placeholder file size.

downloading packages... [1/5] libz [1/100]

The problem I currently have is getting the content-length from the request, as fetchAndAddDependencies (where the dependency names are held) calls fetchAndUnpack (where the request is actually made). The request data does not bubble back up to fetchAndAddDependencies from fetchAndUnpack.
I'm currently trying to find a method around this.

@andrewrk
Copy link
Member Author

so you'll also need a way to handle not knowing how long the response may be.

Hmmmmmmmm I think we may have stumbled our way into a proposal: #16528

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contributor friendly This issue is limited in scope and/or knowledge of Zig internals. enhancement Solving this issue will likely involve adding new logic or components to the codebase. zig build system std.Build, the build runner, `zig build` subcommand, package management
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants