-
Notifications
You must be signed in to change notification settings - Fork 1
SS-889 App image docker hub autosuggestion #281
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
f78e94b
app image docker hub autosuggestion
j-awada b01d26f
refactor container image code and use in gradio, streamlit, dash and …
j-awada a9ec46f
Merge branch 'develop' into SS-docker-image-autosuggestion
j-awada 50388c8
comment out JS logging
j-awada 2c297b2
Merge branch 'develop' into SS-docker-image-autosuggestion
j-awada ace5174
Merge branch 'develop' into SS-docker-image-autosuggestion
j-awada File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| from typing import List | ||
|
|
||
| import requests | ||
| from django.conf import settings | ||
|
|
||
|
|
||
| def fetch_docker_hub_images_and_tags(query: str) -> List[str]: | ||
| """ | ||
| Fetch Docker images and latest tags matching a query. | ||
| This function fetches images with the highest pull count. | ||
| """ | ||
| image_search_url = f"{settings.DOCKER_HUB_IMAGE_SEARCH}?query={query}" | ||
| try: | ||
| response = requests.get(image_search_url, timeout=3) | ||
| response.raise_for_status() | ||
| results = response.json().get("results", []) | ||
| except requests.RequestException: | ||
| return [] | ||
|
|
||
| # Sort images by pull count | ||
| sorted_results = sorted(results, key=lambda x: x.get("pull_count", 0), reverse=True) | ||
|
|
||
| images = [] | ||
| # Use the top 5 images | ||
| for repo in sorted_results[:5]: | ||
| repo_name = repo["repo_name"] | ||
|
|
||
| # Fetch available tags | ||
| tags_search_url = f"{settings.DOCKER_HUB_TAG_SEARCH}{repo_name}/tags/?page_size=3" | ||
| try: | ||
| tag_response = requests.get(tags_search_url, timeout=2) | ||
| tag_response.raise_for_status() | ||
| tags = [tag["name"] for tag in tag_response.json().get("results", [])] | ||
| except requests.RequestException: | ||
| # Default to latest if tags cannot be fetched | ||
| tags = ["latest"] | ||
|
|
||
| for tag in tags: | ||
| images.append(f"docker.io/{repo_name}:{tag}") | ||
|
|
||
| return images |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.