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

Silence download 404 errors when using bazel downloader (experimental_index_url and experimental_extra_index_urls) #2100

Closed
dougthor42 opened this issue Jul 29, 2024 · 2 comments · Fixed by #2531
Assignees
Labels
need: upstream support An issue that needs changes in upstream code type: pip pip/pypi integration

Comments

@dougthor42
Copy link
Collaborator

🚀 feature request

Relevant Rules

pip.parse when using experimental_index_url and experimental_extra_index_urls

Description

Using the bazel downloader can result in a lot of warnings:

$ bazel test //src/pyle_xc/fab/package_tester:web_api_test
Starting local Bazel server and connecting to it...
WARNING: Download from https://[REDACTED]/simple/rsa/ failed: class java.io.FileNotFoundException GET returned 404 Not Found
WARNING: Download from https://[REDACTED]/simple/uv/ failed: class java.io.FileNotFoundException GET returned 404 Not Found
WARNING: Download from https://[REDACTED]/simple/h11/ failed: class java.io.FileNotFoundException GET returned 404 Not Found
WARNING: Download from https://[REDACTED]/simple/ply/ failed: class java.io.FileNotFoundException GET returned 404 Not Found
WARNING: Download from https://[REDACTED]/simple/jq/ failed: class java.io.FileNotFoundException GET returned 404 Not Found

Can these be silenced in some way?

This may not be feasible/reasonable via rules_python because it's part of Bazel core.

Describe the solution you'd like

An attribute on pip.parse would be nice.

Describe alternatives you've considered

I'm investigating the bazel --logging flag and asking around.

@aignas
Copy link
Collaborator

aignas commented Jul 31, 2024

It's not possible to silence it, but it is possible to explicitly pass the packages that should use a different index, then the error is not present.

See https://rules-python.readthedocs.io/en/latest/api/python/extensions/pip.html#pip.parse.experimental_index_url_overrides

It might be a good idea to raise a ticket to bazelbuild/bazel to allow silencing it via some attribute on https://bazel.build/rules/lib/builtins/module_ctx#download. The only way to silence this would be to reimplement the downloading of the Python index in some other language (e.g. Rust, go or Python) or to have a lock file support that has URLs in the lockfile itself, then we would not need to query PyPI at all.

Leaving this open for now because there is a solution, but not sure how high on the priority list the solution is.

@dougthor42
Copy link
Collaborator Author

Thanks @aignas! I've opened bazelbuild/bazel#23173 for such thing - we'll see what they say.

I'll see about using experimental_index_url_overrides. It may not be super feasible given how many custom packages we have, but it's worth a shot. I might have to write a script that keeps things in sync somehow...

@aignas aignas added type: pip pip/pypi integration need: upstream support An issue that needs changes in upstream code type: feature request and removed type: feature request labels Aug 1, 2024
aignas added a commit to aignas/rules_python that referenced this issue Dec 24, 2024
Later in the code we would only use the results of SimpleAPI
if the package has shas, so actually doing these calls is just
wasting time, because we would be dropping the results anyway.

Work towards bazelbuild#2100
aignas added a commit to aignas/rules_python that referenced this issue Dec 24, 2024
Instead of querying everything in parallel and yielding a lot of 404
warnings, let's query the main index first and then query the other
indexes only for the packages that were not yet found. This should make
the problem in bazelbuild#2100 not as serious.

What is more, we can print the value of  for the users
to use.

Work towards bazelbuild#2100
github-merge-queue bot pushed a commit that referenced this issue Dec 27, 2024
Later in the code we would only use the results of SimpleAPI
if the package has shas, so actually doing these calls is just
wasting time, because we would be dropping the results anyway.

Work towards #2100
github-merge-queue bot pushed a commit that referenced this issue Dec 31, 2024
…2531)

Instead of querying everything in parallel and yielding a lot of 404
warnings, let's query the main index first and then query the other
indexes only for the packages that were not yet found.

What is more, we can print the value of
`experimental_index_url_overrides`
for the users to use.

Whilst at it, add a unit test to check the new logic.

Fixes #2100, since this is the best `rules_python` can do for now.

---------

Co-authored-by: Douglas Thor <dougthor42@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
need: upstream support An issue that needs changes in upstream code type: pip pip/pypi integration
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants