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

feat: extend conda data source #34681

Open
wants to merge 16 commits into
base: main
Choose a base branch
from

Conversation

trim21
Copy link
Contributor

@trim21 trim21 commented Mar 7, 2025

Changes

add prefix.dev support

add releaseTimestamp support

Context

Documentation (please check one with an [x])

  • I have updated the documentation, or
  • No documentation update is required

How I've tested my work (please select one)

I have verified these changes via:

  • Code inspection only, or
  • Newly added/modified unit tests, or
  • No unit tests but ran on a real repository, or
  • Both unit tests + ran on a real repository

@trim21 trim21 mentioned this pull request Mar 7, 2025
6 tasks
Copy link
Member

@viceice viceice left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rarkins @secustor this looks a little bit like a different datasource 🤔

@@ -43,12 +47,22 @@ export class CondaDatasource extends Datasource {
return null;
}

if (registryUrl.startsWith('https://prefix.dev/')) {
// the registryUrl here will at least contains 3 `/` ,
// therefore channel won't be undefined in any case.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can't be sure, a user could made a mistake. so catch it and add a test.

Copy link
Contributor Author

@trim21 trim21 Mar 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm sure becasue this is in the if(registryUrl.startsWith('https://prefix.dev/')), jf user made a mistake with registryUrl='' it won't go into this code path.

It's impossible that a registryUrl starts with https://prefix.dev/ and it doesn't have 3 /, right?

@trim21
Copy link
Contributor Author

trim21 commented Mar 7, 2025

@rarkins @secustor this looks a little bit like a different datasource 🤔

Sorry, this is the previous conversation about this PR, I should put in the PR description.

short version: prefix.dev is also a conda repo and it has a graphql API, so when the registry URL is prefix.dev we use graphql to query it.

#2213 (comment)

@trim21 trim21 requested a review from viceice March 7, 2025 17:15
Comment on lines 143 to 157
const files = await this.getPrefixPagedResponse(
`
query search($channel: String!, $package: String!, $page: Int = 0) {
data: package(channelName: $channel, name: $package) {
data: variants(limit: 500, page: $page) {
pages
page {
version
createdAt
yankedReason
}
}
}
}
`,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are you not pulling this in the first API call?

Copy link
Contributor Author

@trim21 trim21 Mar 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

like the schema suggest, this is listing all files of a package, so it has different total page count with first api call. One version will contains multiple files (called variants here), and package/version doesn't have createdAt and yankedReason, only package/variant have it, so we need to pull variants and get the yankedReason and createdAt. This is same logic with api.anaconda.

Copy link
Contributor Author

@trim21 trim21 Mar 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's possible to merge these 2 queries but I don't want to spend that mental energy to do it 😅

I think current implementation is much more easy to understand, let's refactor it when it cause trouble.

@trim21 trim21 requested a review from secustor March 8, 2025 19:46
'lookup package from prefix.dev graphql API',
);

const versions = await getPagedResponse(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

prettier will be possible to format graphql if we have gql tag here, but graphql-tag is currently not in our dep tree so I didn't add it.

@trim21
Copy link
Contributor Author

trim21 commented Mar 8, 2025

It wil fetch 500 records of versions and 500 records of files from prefix.dev graphql API.

the files contribute to the releaseDate and isDeprecated, version without it's files will missing this info.

It should be able to fetch all version of most package(I don't know if there is a package has more than 500 versions). But many package have more than 500 files, for example, numpy currently have 2800 files and 500 files will cover from 2.2.3 to 1.26.3. If we only select platform "linux-64" it has 692 records and will cover from 2.2.3 to 1.14.2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants