Skip to content

[model] Allow Random Model Names for Artifact Hub Registrant #722

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

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

Tanishq1604
Copy link

@Tanishq1604 Tanishq1604 commented Apr 15, 2025

Description
This PR fixes an issue #14282 where ArtifactHub registrant required model names to match package names exactly, while GitHub allowed arbitrary model names. The solution extracts package names from ArtifactHub URLs when possible, making the experience consistent between registrants.

Implementation

Modified the ArtifactHub package manager to:

  1. Parse query parameters from ArtifactHub URLs
  2. Extract the ts_query_web parameter which contains the actual package name
  3. Use this extracted name when searching for packages
  4. Fall back to the original model name if no package name can be extracted
REC-20250415221556.mp4

Notes for Reviewers

This change makes ArtifactHub work like GitHub when it comes to model registration. Users can now provide arbitrary model names when using ArtifactHub registrant rather than requiring the model name to exactly match the ArtifactHub package name.

  • Yes, I signed my commits.

Copy link

welcome bot commented Apr 15, 2025

Yay, your first pull request! 👍 A contributor will be by to give feedback soon. In the meantime, you can find updates in the #github-notifications channel in the community Slack.
Be sure to double-check that you have signed your commits. Here are instructions for making signing an implicit activity while performing a commit.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Hello @Tanishq1604, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

Summary of Changes

This pull request addresses issue #14282, where the ArtifactHub registrant required model names to exactly match package names, unlike GitHub. To resolve this, I've modified the ArtifactHub package manager to extract package names from ArtifactHub URLs, specifically the ts_query_web parameter. If this parameter is found, it's used as the package name; otherwise, the original model name is used. This change ensures a consistent experience between ArtifactHub and GitHub when registering models.

Highlights

  • Bug Fix: Fixes issue #14282, which required exact matching of model and package names in ArtifactHub.
  • Feature Enhancement: Allows arbitrary model names for ArtifactHub registrant, consistent with GitHub.
  • Code Modification: Modified the ArtifactHub package manager to extract package names from URLs.

Changelog

  • generators/artifacthub/package_manager.go
    • Added net/url import to handle URL parsing.
    • Modified GetPackage function to extract package name from ts_query_web parameter in the URL.
    • Implemented fallback to the original model name if the package name cannot be extracted from the URL.
    • Updated GetAhPackagesWithName to use the extracted or original package name for searching.
    • Updated error message to reflect the extracted or original package name.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.


A name mismatch, a coding plight,
ArtifactHub's rigidity, not quite right.
But a parsed URL,
A fix, not a squall,
Consistency shines, a welcome light.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This PR enhances the ArtifactHub package manager by allowing arbitrary model names, aligning its behavior with GitHub. The implementation is clear and addresses the issue effectively. The demo video is also a great addition for reviewers to understand the changes.

Merge Readiness

The code changes are well-structured and address the issue described in the pull request. I recommend merging this pull request after addressing the comments provided.

Comment on lines +20 to +28
parsedURL, err := url.Parse(ahpm.SourceURL)
if err == nil {
// Extract the ts_query_web parameter if it exists
queryParams := parsedURL.Query()
if tsQueryWeb := queryParams.Get("ts_query_web"); tsQueryWeb != "" {
searchName = tsQueryWeb
}
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

Consider adding a more robust error handling mechanism here. Currently, if url.Parse fails, the code silently continues using the original package name. It might be beneficial to log the error or provide a more explicit fallback mechanism. What do you think about adding a log here?

Comment on lines 35 to +36
if len(pkgs) == 0 {
return nil, ErrNoPackageFound(ahpm.PackageName, "Artifacthub")
return nil, ErrNoPackageFound(searchName, "Artifacthub")
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

Consider adding the original package name to the error message for better context. This would help users understand if the issue is with the extracted name or the original name. For example, the error message could be updated to: ErrNoPackageFound(searchName, ahpm.PackageName, "Artifacthub")

return nil, ErrNoPackageFound(searchName, ahpm.PackageName, "Artifacthub")

Copy link
Contributor

@amitamrutiya amitamrutiya left a comment

Choose a reason for hiding this comment

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

@Tanishq1604 are we doing same thing for github. If yes then try to use same handler for that, if no then try to do what we are doing for github.

Demo of your solution will be helpful.

@leecalcote
Copy link
Member

Lint failures...

@hortison
Copy link
Member

No activity here... PR abandoned?

@riyaa14
Copy link
Contributor

riyaa14 commented Apr 21, 2025

@Tanishq1604 are we doing same thing for github. If yes then try to use same handler for that, if no then try to do what we are doing for github.

@amitamrutiya

  • for GitHub, the sourceURL points to a single Github repo, contents and name is taken from that repository.
  • for Artifact Hub, the sourceURL has link to a search query for a particular model name. A sorting logic helps find the most suitable package and we use that one to get contents. The processes are very different.

To make Artifact Hub process same as GitHub one, there are too concerns:

  1. All Artifact Hub SourceURLs in meshery integrations sheet would have to be updated
  2. There might be some important reason why we are sorting and fetching the most relevant package, instead of using a single repository.

considering the points above, I suggest we shouldn't be doing it, what do you think?

Copy link
Contributor

@riyaa14 riyaa14 left a comment

Choose a reason for hiding this comment

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

LGTM

@Tanishq1604
Copy link
Author

@amitamrutiya for now i have done for the artifact hub i am taking the name from the artifact hub url's query
to make it like the github one would raises concern just like what @riyaa14 said.

@amitamrutiya
Copy link
Contributor

@Jougan-0 are we good to go here?

@amitamrutiya amitamrutiya requested a review from Jougan-0 April 23, 2025 05:46
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.

6 participants