-
Notifications
You must be signed in to change notification settings - Fork 21
Add ecommerce_end_to_end template #703
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
sys13
wants to merge
1
commit into
main
Choose a base branch
from
ecommerce-end-to-end-template
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
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,7 @@ | ||
| head_node_type: | ||
| name: head | ||
| instance_type: m5.2xlarge | ||
|
|
||
| worker_node_types: [] | ||
|
|
||
| auto_select_worker_config: true |
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,7 @@ | ||
| head_node_type: | ||
| name: head | ||
| instance_type: n2-standard-8 | ||
|
|
||
| worker_node_types: [] | ||
|
|
||
| auto_select_worker_config: true | ||
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,18 @@ | ||
| # This file is used to exclude files from Anyscale Workspaces snapshots. | ||
| # Use this to prevent large or unnecessary files from being included in your snapshots, | ||
| # which helps reduce snapshot size and creation time. See documentation for more details: | ||
| # https://docs.anyscale.com/platform/workspaces/workspaces-files/#excluding-files-with-anyscaleignore | ||
| # | ||
| # Syntax examples: | ||
| # *.txt # Ignore files with a .txt extension at the same level as `.anyscaleignore`. | ||
| # **/*.txt # Ignore files with a .txt extension in ANY directory. | ||
| # folder/ # Ignore all files under "folder/". The slash at the end is optional. | ||
| # folder/*.txt # Ignore files with a .txt extension under "folder/". | ||
| # path/to/filename.py # Ignore a specific file by providing its relative path. | ||
| # file_[1,2].txt # Ignore file_1.txt and file_2.txt. | ||
|
|
||
| # Exclude Python virtual environments (.venv/) from snapshots. Virtual environments contain | ||
| # all installed Python dependencies, which can be multiple gigabytes in size. These directories | ||
| # are typically recreatable from requirements files and don't need to be included in snapshots. | ||
| # The ** pattern ensures all .venv directories are excluded regardless of location in your project. | ||
| **/.venv/ |
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,5 @@ | ||
| # E-Commerce Recommendation System Demo | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When someone click on the template's card in the console, our frontend automatically display the README.md. i'd suggest generating it from the notebook.ipynb for better UX (people can see directly what they would be running)
|
||
|
|
||
| An end-to-end recommendation system using Ray Data, Ray Train, and Ray Serve on Anyscale. | ||
|
|
||
| The main notebook is [notebook.ipynb](./notebook.ipynb) | ||
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,83 @@ | ||
| """ | ||
| Quick test client for the Ray Serve recommendation endpoint. | ||
|
|
||
| Usage: | ||
| # Start the service first: | ||
| # serve run serve_app:app | ||
| # | ||
| # Then in another terminal: | ||
| python client.py | ||
| """ | ||
|
|
||
| import base64 | ||
| import io | ||
| import json | ||
| import sys | ||
|
|
||
| import requests | ||
| from PIL import Image | ||
|
|
||
| SERVE_URL = "http://localhost:8000" | ||
|
|
||
|
|
||
| def encode_image(path_or_pil) -> str: | ||
| """Return base64-encoded JPEG string from a path or PIL Image.""" | ||
| if isinstance(path_or_pil, str): | ||
| with open(path_or_pil, "rb") as f: | ||
| raw = f.read() | ||
| else: | ||
| buf = io.BytesIO() | ||
| path_or_pil.save(buf, format="JPEG") | ||
| raw = buf.getvalue() | ||
| return base64.b64encode(raw).decode("utf-8") | ||
|
|
||
|
|
||
| def test_health(): | ||
| print("=== Health check ===") | ||
| resp = requests.get(f"{SERVE_URL}/health", timeout=5) | ||
| print(f"Status: {resp.status_code} Body: {resp.json()}") | ||
| print() | ||
|
|
||
|
|
||
| def test_recommend_demo(): | ||
| """Send a real product image and call /recommend.""" | ||
| from utils import get_product_image, PRODUCTS | ||
|
|
||
| print("=== /recommend — demo product image ===") | ||
|
|
||
| # Use the first product (Wireless Headphones) as query image | ||
| product = PRODUCTS[0] | ||
| img_arr = get_product_image(product) | ||
| img_pil = Image.fromarray(img_arr) | ||
|
|
||
| payload = {"image_base64": encode_image(img_pil)} | ||
|
|
||
| try: | ||
| resp = requests.post( | ||
| f"{SERVE_URL}/recommend", | ||
| json=payload, | ||
| timeout=120, | ||
| ) | ||
| resp.raise_for_status() | ||
| result = resp.json() | ||
| except requests.exceptions.ConnectionError: | ||
| print( | ||
| "ERROR: Could not connect. " | ||
| "Make sure `serve run serve_app:app` is running first." | ||
| ) | ||
| sys.exit(1) | ||
|
|
||
| print(f"Caption: {result['caption']!r}") | ||
| print(f"\nTop {len(result['recommendations'])} recommendations:") | ||
| for r in result["recommendations"]: | ||
| print( | ||
| f" {r['rank']}. [{r['category']:18s}] {r['name']:35s} " | ||
| f"sim={r['similarity']:.3f}" | ||
| ) | ||
| print() | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| test_health() | ||
| test_recommend_demo() | ||
| print("✅ All tests passed!") |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+16.1 KB
templates/ecommerce_end_to_end/data/demo_images/Bamboo_Cutting_Board.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+11.4 KB
templates/ecommerce_end_to_end/data/demo_images/Bluetooth_Speaker.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+15.4 KB
templates/ecommerce_end_to_end/data/demo_images/Cast_Iron_Skillet.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+7.64 KB
templates/ecommerce_end_to_end/data/demo_images/Cotton_T-Shirt_3-Pack.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+16.9 KB
templates/ecommerce_end_to_end/data/demo_images/Deep_Learning_Book.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+19.3 KB
templates/ecommerce_end_to_end/data/demo_images/Designing_Data-Intensive_Apps.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+19.3 KB
templates/ecommerce_end_to_end/data/demo_images/Distributed_Systems.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+11.2 KB
templates/ecommerce_end_to_end/data/demo_images/French_Press_Coffee.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+11.6 KB
templates/ecommerce_end_to_end/data/demo_images/Mechanical_Keyboard.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+8.42 KB
templates/ecommerce_end_to_end/data/demo_images/Merino_Wool_Sweater.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+8.16 KB
templates/ecommerce_end_to_end/data/demo_images/Resistance_Bands_Set.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+6.38 KB
templates/ecommerce_end_to_end/data/demo_images/Scented_Soy_Candle.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
Binary file added
BIN
+22.5 KB
templates/ecommerce_end_to_end/data/demo_images/Succulent_Set_6-Pack.jpg
Oops, something went wrong.
Binary file added
BIN
+19.3 KB
templates/ecommerce_end_to_end/data/demo_images/The_Algorithm_Design.jpg
Oops, something went wrong.
Oops, something went wrong.
Binary file added
BIN
+10.2 KB
templates/ecommerce_end_to_end/data/demo_images/Water_Bottle_32oz.jpg
Oops, something went wrong.
Binary file added
BIN
+11.5 KB
templates/ecommerce_end_to_end/data/demo_images/Waterproof_Jacket.jpg
Oops, something went wrong.
Oops, something went wrong.
Binary file added
BIN
+5.14 KB
templates/ecommerce_end_to_end/data/demo_images/Wireless_Headphones.jpg
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
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.
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.
do we need an azure.yaml compute config?