Skip to content

Commit

Permalink
Feedback management microservice refactor (#1057)
Browse files Browse the repository at this point in the history
Signed-off-by: lvliang-intel <liang1.lv@intel.com>
  • Loading branch information
lvliang-intel authored Jan 9, 2025
1 parent 962e097 commit ec66b91
Show file tree
Hide file tree
Showing 15 changed files with 22 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
services:
feedbackmanagement:
build:
dockerfile: comps/feedback_management/mongo/Dockerfile
dockerfile: comps/feedback_management/src/Dockerfile
image: ${REGISTRY:-opea}/feedbackmanagement:${TAG:-latest}
2 changes: 1 addition & 1 deletion comps/feedback_management/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ The Feedback Management microservice able to support various database backends f

### Feedback Management with MongoDB

For more detail, please refer to this [README](./mongo/README.md)
For more detail, please refer to this [README](./src/README.md)
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ COPY comps /home/user/comps
COPY requirements.txt /home/user/

RUN pip install --no-cache-dir --upgrade pip setuptools && \
pip install --no-cache-dir -r /home/user/comps/feedback_management/mongo/requirements.txt && \
pip install --no-cache-dir -r /home/user/comps/feedback_management/src/requirements.txt && \
pip install --no-cache-dir -r /home/user/requirements.txt

ENV PYTHONPATH=$PYTHONPATH:/home/user

WORKDIR /home/user/comps/feedback_management/mongo
WORKDIR /home/user/comps/feedback_management/src

ENTRYPOINT ["python", "feedback.py"]
ENTRYPOINT ["python", "opea_feedback_microservice.py"]
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export COLLECTION_NAME=${COLLECTION_NAME}

```bash
cd ~/GenAIComps
docker build -t opea/feedbackmanagement-mongo-server:latest --build-arg https_proxy=$https_proxy --build-arg http_proxy=$http_proxy -f comps/feedback_management/mongo/Dockerfile .
docker build -t opea/feedbackmanagement:latest --build-arg https_proxy=$https_proxy --build-arg http_proxy=$http_proxy -f comps/feedback_management/src/Dockerfile .
```

### Run Docker with CLI
Expand All @@ -37,7 +37,7 @@ docker build -t opea/feedbackmanagement-mongo-server:latest --build-arg https_pr
- Run Feedback Management microservice

```bash
docker run -d --name="feedbackmanagement-mongo-server" -p 6016:6016 -e http_proxy=$http_proxy -e https_proxy=$https_proxy -e no_proxy=$no_proxy -e MONGO_HOST=${MONGO_HOST} -e MONGO_PORT=${MONGO_PORT} -e DB_NAME=${DB_NAME} -e COLLECTION_NAME=${COLLECTION_NAME} opea/feedbackmanagement-mongo-server:latest
docker run -d --name="feedbackmanagement-mongo-server" -p 6016:6016 -e http_proxy=$http_proxy -e https_proxy=$https_proxy -e no_proxy=$no_proxy -e MONGO_HOST=${MONGO_HOST} -e MONGO_PORT=${MONGO_PORT} -e DB_NAME=${DB_NAME} -e COLLECTION_NAME=${COLLECTION_NAME} opea/feedbackmanagement:latest
```

---
Expand Down
2 changes: 2 additions & 0 deletions comps/feedback_management/src/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Copyright (C) 2024 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

import bson.errors as BsonError
from bson.objectid import ObjectId
from config import COLLECTION_NAME
from mongo_conn import MongoClient
from integrations.mongo.config import COLLECTION_NAME
from integrations.mongo.mongo_conn import MongoClient


class FeedbackStore:
Expand All @@ -15,8 +15,9 @@ def __init__(
):
self.user = user

def initialize_storage(self) -> None:
self.db_client = MongoClient.get_db_client()
def initialize_storage(self, db_type="mongo") -> None:
if db_type == "mongo":
self.db_client = MongoClient.get_db_client()
self.collection = self.db_client[COLLECTION_NAME]

async def save_feedback(self, feedback_data) -> str:
Expand Down
2 changes: 2 additions & 0 deletions comps/feedback_management/src/integrations/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Copyright (C) 2024 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
2 changes: 2 additions & 0 deletions comps/feedback_management/src/integrations/mongo/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Copyright (C) 2024 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
from typing import Any

import motor.motor_asyncio as motor
from config import DB_NAME, MONGO_HOST, MONGO_PORT

from .config import DB_NAME, MONGO_HOST, MONGO_PORT


class MongoClient:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from typing import Annotated, Optional

from fastapi import HTTPException
from mongo_store import FeedbackStore
from feedback_store import FeedbackStore
from pydantic import BaseModel, Field

from comps import CustomLogger
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ function build_docker_images() {
echo $(pwd)
docker run -d -p 27017:27017 --name=test-comps-mongo mongo:latest

docker build --no-cache -t opea/feedbackmanagement-mongo-server:comps --build-arg https_proxy=$https_proxy --build-arg http_proxy=$http_proxy -f comps/feedback_management/mongo/Dockerfile .
docker build --no-cache -t opea/feedbackmanagement-mongo-server:comps --build-arg https_proxy=$https_proxy --build-arg http_proxy=$http_proxy -f comps/feedback_management/src/Dockerfile .
if [ $? -ne 0 ]; then
echo "opea/feedbackmanagement-mongo-server built fail"
exit 1
Expand Down

0 comments on commit ec66b91

Please sign in to comment.