diff --git a/.github/workflows/docker/compose/feedback_management-compose.yaml b/.github/workflows/docker/compose/feedback_management-compose.yaml index 0a3cfce66a..29fa00d73b 100644 --- a/.github/workflows/docker/compose/feedback_management-compose.yaml +++ b/.github/workflows/docker/compose/feedback_management-compose.yaml @@ -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} diff --git a/comps/feedback_management/README.md b/comps/feedback_management/README.md index 2e68aa413c..044b31d668 100644 --- a/comps/feedback_management/README.md +++ b/comps/feedback_management/README.md @@ -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) diff --git a/comps/feedback_management/mongo/docker-compose-user-feedback-mongo.yaml b/comps/feedback_management/deployment/docker_compose/compose_feedback_mongo.yaml similarity index 100% rename from comps/feedback_management/mongo/docker-compose-user-feedback-mongo.yaml rename to comps/feedback_management/deployment/docker_compose/compose_feedback_mongo.yaml diff --git a/comps/feedback_management/deployment/kubernetes/README.md b/comps/feedback_management/deployment/kubernetes/README.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/comps/feedback_management/mongo/Dockerfile b/comps/feedback_management/src/Dockerfile similarity index 82% rename from comps/feedback_management/mongo/Dockerfile rename to comps/feedback_management/src/Dockerfile index 1880a5009a..cc5641e2bc 100644 --- a/comps/feedback_management/mongo/Dockerfile +++ b/comps/feedback_management/src/Dockerfile @@ -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"] diff --git a/comps/feedback_management/mongo/README.md b/comps/feedback_management/src/README.md similarity index 94% rename from comps/feedback_management/mongo/README.md rename to comps/feedback_management/src/README.md index 347575c2be..349a6098c3 100644 --- a/comps/feedback_management/mongo/README.md +++ b/comps/feedback_management/src/README.md @@ -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 @@ -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 ``` --- diff --git a/comps/feedback_management/src/__init__.py b/comps/feedback_management/src/__init__.py new file mode 100644 index 0000000000..916f3a44b2 --- /dev/null +++ b/comps/feedback_management/src/__init__.py @@ -0,0 +1,2 @@ +# Copyright (C) 2024 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 diff --git a/comps/feedback_management/mongo/mongo_store.py b/comps/feedback_management/src/feedback_store.py similarity index 94% rename from comps/feedback_management/mongo/mongo_store.py rename to comps/feedback_management/src/feedback_store.py index 49cfeaf4a2..92b33b4eff 100644 --- a/comps/feedback_management/mongo/mongo_store.py +++ b/comps/feedback_management/src/feedback_store.py @@ -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: @@ -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: diff --git a/comps/feedback_management/src/integrations/__init__.py b/comps/feedback_management/src/integrations/__init__.py new file mode 100644 index 0000000000..916f3a44b2 --- /dev/null +++ b/comps/feedback_management/src/integrations/__init__.py @@ -0,0 +1,2 @@ +# Copyright (C) 2024 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 diff --git a/comps/feedback_management/src/integrations/mongo/__init__.py b/comps/feedback_management/src/integrations/mongo/__init__.py new file mode 100644 index 0000000000..916f3a44b2 --- /dev/null +++ b/comps/feedback_management/src/integrations/mongo/__init__.py @@ -0,0 +1,2 @@ +# Copyright (C) 2024 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 diff --git a/comps/feedback_management/mongo/config.py b/comps/feedback_management/src/integrations/mongo/config.py similarity index 100% rename from comps/feedback_management/mongo/config.py rename to comps/feedback_management/src/integrations/mongo/config.py diff --git a/comps/feedback_management/mongo/mongo_conn.py b/comps/feedback_management/src/integrations/mongo/mongo_conn.py similarity index 90% rename from comps/feedback_management/mongo/mongo_conn.py rename to comps/feedback_management/src/integrations/mongo/mongo_conn.py index 52e4c8e130..48cd19a1af 100644 --- a/comps/feedback_management/mongo/mongo_conn.py +++ b/comps/feedback_management/src/integrations/mongo/mongo_conn.py @@ -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: diff --git a/comps/feedback_management/mongo/feedback.py b/comps/feedback_management/src/opea_feedback_microservice.py similarity index 99% rename from comps/feedback_management/mongo/feedback.py rename to comps/feedback_management/src/opea_feedback_microservice.py index 062f18c81d..2f9b020f26 100644 --- a/comps/feedback_management/mongo/feedback.py +++ b/comps/feedback_management/src/opea_feedback_microservice.py @@ -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 diff --git a/comps/feedback_management/mongo/requirements.txt b/comps/feedback_management/src/requirements.txt similarity index 100% rename from comps/feedback_management/mongo/requirements.txt rename to comps/feedback_management/src/requirements.txt diff --git a/tests/feedback_management/test_feedback_management_mongo.sh b/tests/feedback_management/test_feedback_management_mongo.sh index afb5508bd9..ffe352b590 100644 --- a/tests/feedback_management/test_feedback_management_mongo.sh +++ b/tests/feedback_management/test_feedback_management_mongo.sh @@ -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