diff --git a/README.md b/README.md index c9be77e..b4c42e4 100644 --- a/README.md +++ b/README.md @@ -91,20 +91,23 @@ The dataset was taken from the the following Kaggle links. - [Large Dataset](https://www.kaggle.com/datasets/paramaggarwal/fashion-product-images-dataset) - [Smaller Dataset](https://www.kaggle.com/datasets/paramaggarwal/fashion-product-images-small) +A formatted version is available for use with this demo at: + ## Running the App with docker-compose Before running the app, install [Docker Desktop](https://www.docker.com/products/docker-desktop/). -#### Using Redis Cloud (recommended) +#### Using Redis Cloud 1. [Get your Redis Cloud Database](https://app.redislabs.com/) (if needed). -2. Export Redis Endpoint Environment Variables: - ```bash - $ export REDIS_HOST=your-redis-host - $ export REDIS_PORT=your-redis-port - $ export REDIS_PASSOWRD=your-redis-password - ``` +2. `touch .env` and update with cloud values + +```bash +REDIS_HOST=your-redis-host +REDIS_PORT=your-redis-port +REDIS_PASSOWRD=your-redis-password +``` 3. Run the App: ```bash @@ -113,11 +116,22 @@ Before running the app, install [Docker Desktop](https://www.docker.com/products > The benefit of this approach is that the db will persist beyond application runs. So you can make updates and re run the app without having to provision the dataset or create another search index. -#### Using Redis Docker +#### Running the app locally using docker + +1. `touch .env` and update with local values + +```bash +REDIS_HOST=redis +REDIS_PORT=6379 +``` + +2. Run compose command ```bash $ docker compose -f docker-local-redis.yml up ``` +Note: you can add `--build` and `--force-recreate` if caching old images. + ## Running without docker-compose ### Run frontend diff --git a/backend/productsearch/config.py b/backend/productsearch/config.py index cc94b9b..0b0546b 100644 --- a/backend/productsearch/config.py +++ b/backend/productsearch/config.py @@ -16,6 +16,7 @@ API_DOCS = "/api/docs" OPENAPI_DOCS = "/api/openapi.json" INDEX_NAME = "products" + REDIS_HOST = os.environ.get("REDIS_HOST", "redis-vector-db") REDIS_PORT = os.environ.get("REDIS_PORT", 6379) REDIS_DB = os.environ.get("REDIS_DB", 0) diff --git a/backend/productsearch/db/load.py b/backend/productsearch/db/load.py index 983191e..c58fbed 100644 --- a/backend/productsearch/db/load.py +++ b/backend/productsearch/db/load.py @@ -1,14 +1,13 @@ #!/usr/bin/env python3 import asyncio import json -import requests import os from typing import List import numpy as np -from redisvl.index import AsyncSearchIndex - +import requests from productsearch import config +from redisvl.index import AsyncSearchIndex def read_from_s3(): diff --git a/docker-local-redis.yml b/docker-local-redis.yml index f0ebad6..bb790c5 100644 --- a/docker-local-redis.yml +++ b/docker-local-redis.yml @@ -19,14 +19,10 @@ services: - "6379:6379" - "8001:8001" volumes: - - redis-vector-db:/data + - ./data:/app/data healthcheck: test: ["CMD", "redis-cli", "-h", "localhost", "-p", "6379", "ping"] interval: 2s timeout: 1m30s retries: 5 - start_period: 5s - - -volumes: - redis-vector-db: \ No newline at end of file + start_period: 5s \ No newline at end of file