-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
fix(pypi): lookup simple api first #31771
Conversation
Co-authored-by: Sebastian Poxhofer <[email protected]>
Co-authored-by: Rhys Arkins <[email protected]>
lib/modules/datasource/pypi/index.ts
Outdated
if (simpleDependencies === null) { | ||
// Both Simple and API lookups failed | ||
throw err; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this throw an error or return null?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll delete it for now, since I check for either of the values being null below. Let me know if this was actually expected behaviour.
I just realized also that this PR unfortunately doesn't follow the approach in the rubygems datasource (see https://github.com/renovatebot/renovate/tree/main/lib/modules/datasource/rubygems) as was suggested in #26483 In short:
In other words, the goal was to avoid hitting the JSON API every time. |
I think that's covered by this test, it tests a 403 return value:
|
I meant a reproduction repo, not a unit test |
Something like this? https://github.com/samgiz/renovate-26383-reproducer |
Is the assumption here that the simple api is more expensive to call than the json api? That might be true, but not by a lot, and I'm not sure such an optimization is worth the extra complexity in the code. This is a bit anecdotal since I only have one datapoint, but I just ran this:
while logging the content-length of the json and simple endpoint responses, and got 9239 for simple and 14560 for json. I'm not very convinced that it's worth adding the cache for an optimisation of such size, unless I'm misunderstanding what it does. Though you likely have better judgement about this than I do. It also seems like a lot of work to implement the cache, and I'm mostly just interested in the torch pypi repository working correctly with renovate. Would it make sense to reopen #26386 instead? |
Thanks for your patience and helping me understand it better. Based on your last suggestion I have implemented #32024 Please let me know if you think that solves the problem. BTW I needed to make some config changes to the reproducer to get it to work: https://github.com/renovate-reproductions/26383/blob/master/renovate.json |
That does solve my problem, thank you! |
Closing now that #32024 has been merged. |
Changes
This rewrites the getReleases function of pypi datasources:
First, the simple (pypi) api is queried, then the pypijson api is retried to enrich the metadata.
Previously the simple api was only used if pypijson returned 404.
The unit tests stayed mostly the same, but the simple api routes needed to be mocked. Also added testcases to check that both simple and json pypi apis are used, dependency resolution succeeds if json api is unavailable, and dependencies from the two endpoints get merged correctly.
Context
Building on top of #26505.
Closes #26483.
As pypijson is used additionally, #26383 is resolved as well.
Documentation (please check one with an [x])
How I've tested my work (please select one)
I have verified these changes via: