Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions BUILD.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -631,3 +631,16 @@
tests_path: tests/fintech_quant/
command: bash tests.sh
timeout_in_sec: 1800

# owner: @daniel.arrizza
- name: ecommerce_end_to_end
dir: templates/ecommerce_end_to_end
cluster_env:
image_uri: anyscale/ray:2.55.1-py312
compute_config:
AWS: configs/ecommerce_end_to_end/aws.yaml
GCP: configs/ecommerce_end_to_end/gce.yaml
test:
tests_path: tests/ecommerce_end_to_end/
command: bash tests.sh
timeout_in_sec: 1800
7 changes: 7 additions & 0 deletions configs/ecommerce_end_to_end/aws.yaml
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
7 changes: 7 additions & 0 deletions configs/ecommerce_end_to_end/gce.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
head_node_type:

Copy link
Copy Markdown
Contributor

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?

name: head
instance_type: n2-standard-8

worker_node_types: []

auto_select_worker_config: true
18 changes: 18 additions & 0 deletions templates/ecommerce_end_to_end/.anyscaleignore
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/
5 changes: 5 additions & 0 deletions templates/ecommerce_end_to_end/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# E-Commerce Recommendation System Demo

@Aydin-ab Aydin-ab May 19, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The 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)
steps:

  • remove current README.md
  • run jupyter nbconvert ... to convert notebook.ipynb to README.md
  • rename notebook.ipynb to README.ipynb


An end-to-end recommendation system using Ray Data, Ray Train, and Ray Serve on Anyscale.

The main notebook is [notebook.ipynb](./notebook.ipynb)
83 changes: 83 additions & 0 deletions templates/ecommerce_end_to_end/client.py
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.
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.
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.
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.
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.
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
Loading