Skip to content

Commit

Permalink
rename arango envs (#14)
Browse files Browse the repository at this point in the history
* initial commit: rename arango envs

* fix comment
  • Loading branch information
aMahanna authored Dec 9, 2024
1 parent 0c21ff5 commit c5b936b
Show file tree
Hide file tree
Showing 18 changed files with 84 additions and 121 deletions.
16 changes: 6 additions & 10 deletions comps/chathistory/arango/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,11 @@ This README provides setup guides and all the necessary information about the Ch
See `config.py` for default values.

```bash
export ARANGO_HOST=${ARANGO_HOST}
export ARANGO_PORT=${ARANGO_PORT}
export ARANGO_PROTOCOL=${ARANGO_PROTOCOL}
export ARANGO_URL=${ARANGO_URL}
export ARANGO_USERNAME=${ARANGO_USERNAME}
export ARANGO_PASSWORD=${ARANGO_PASSWORD}
export DB_NAME=${DB_NAME}
export COLLECTION_NAME=${COLLECTION_NAME}
export ARANGO_DB_NAME=${ARANGO_DB_NAME}
export ARANGO_COLLECTION_NAME=${ARANGO_COLLECTION_NAME}
```

---
Expand Down Expand Up @@ -44,13 +42,11 @@ docker build -t opea/chathistory-arango-server:latest --build-arg https_proxy=$h
-e http_proxy=$http_proxy \
-e https_proxy=$https_proxy \
-e no_proxy=$no_proxy \
-e ARANGO_HOST=${ARANGO_HOST} \
-e ARANGO_PORT=${ARANGO_PORT} \
-e ARANGO_PROTOCOL=${ARANGO_PROTOCOL} \
-e ARANGO_URL=${ARANGO_URL} \
-e ARANGO_USERNAME=${ARANGO_USERNAME} \
-e ARANGO_PASSWORD=${ARANGO_PASSWORD} \
-e DB_NAME=${DB_NAME} \
-e COLLECTION_NAME=${COLLECTION_NAME} \
-e ARANGO_DB_NAME=${ARANGO_DB_NAME} \
-e ARANGO_COLLECTION_NAME=${ARANGO_COLLECTION_NAME} \
opea/chathistory-arango-server:latest
```

Expand Down
10 changes: 5 additions & 5 deletions comps/chathistory/arango/arango_conn.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@

from arango import ArangoClient as PythonArangoClient
from arango.database import StandardDatabase
from config import ARANGO_HOST, ARANGO_PASSWORD, ARANGO_PORT, ARANGO_PROTOCOL, ARANGO_USERNAME, DB_NAME
from config import ARANGO_URL, ARANGO_PASSWORD, ARANGO_USERNAME, ARANGO_DB_NAME


class ArangoClient:
conn_url = f"{ARANGO_PROTOCOL}://{ARANGO_HOST}:{ARANGO_PORT}/"
conn_url = ARANGO_URL

@staticmethod
def get_db_client() -> StandardDatabase:
Expand All @@ -19,11 +19,11 @@ def get_db_client() -> StandardDatabase:
sys_db = client.db("_system", username=ARANGO_USERNAME, password=ARANGO_PASSWORD, verify=True)

# Create target database if it doesn't exist
if not sys_db.has_database(DB_NAME):
sys_db.create_database(DB_NAME)
if not sys_db.has_database(ARANGO_DB_NAME):
sys_db.create_database(ARANGO_DB_NAME)

# Now connect to the target database
db = client.db(DB_NAME, username=ARANGO_USERNAME, password=ARANGO_PASSWORD, verify=True)
db = client.db(ARANGO_DB_NAME, username=ARANGO_USERNAME, password=ARANGO_PASSWORD, verify=True)

return db

Expand Down
8 changes: 4 additions & 4 deletions comps/chathistory/arango/arango_store.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from typing import Any

from arango_conn import ArangoClient
from config import COLLECTION_NAME
from config import ARANGO_COLLECTION_NAME
from pydantic import BaseModel


Expand All @@ -16,10 +16,10 @@ def __init__(
def initialize_storage(self) -> None:
self.db_client = ArangoClient.get_db_client()

if not self.db_client.has_collection(COLLECTION_NAME):
self.db_client.create_collection(COLLECTION_NAME)
if not self.db_client.has_collection(ARANGO_COLLECTION_NAME):
self.db_client.create_collection(ARANGO_COLLECTION_NAME)

self.collection = self.db_client.collection(COLLECTION_NAME)
self.collection = self.db_client.collection(ARANGO_COLLECTION_NAME)

def save_document(self, document: BaseModel) -> str:
"""Stores a new document into the storage.
Expand Down
10 changes: 4 additions & 6 deletions comps/chathistory/arango/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@

import os

# ARANGO configuration
ARANGO_HOST = os.getenv("ARANGO_HOST", "localhost")
ARANGO_PORT = os.getenv("ARANGO_PORT", 8529)
ARANGO_PROTOCOL = os.getenv("ARANGO_PROTOCOL", "http")
# ArangoDB configuration
ARANGO_URL = os.getenv("ARANGO_URL", "http://localhost:8529")
ARANGO_USERNAME = os.getenv("ARANGO_USERNAME", "root")
ARANGO_PASSWORD = os.getenv("ARANGO_PASSWORD", "test")
DB_NAME = os.getenv("DB_NAME", "OPEA")
COLLECTION_NAME = os.getenv("COLLECTION_NAME", "ChatHistory")
ARANGO_DB_NAME = os.getenv("ARANGO_DB_NAME", "OPEA")
ARANGO_COLLECTION_NAME = os.getenv("ARANGO_COLLECTION_NAME", "ChatHistory")
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,11 @@ services:
http_proxy: ${http_proxy}
https_proxy: ${https_proxy}
no_proxy: ${no_proxy}
ARANGO_HOST: ${ARANGO_HOST}
ARANGO_PORT: ${ARANGO_PORT}
ARANGO_PROTOCOL: ${ARANGO_PROTOCOL}
ARANGO_URL: ${ARANGO_URL}
ARANGO_USERNAME: ${ARANGO_USERNAME}
ARANGO_PASSWORD: ${ARANGO_PASSWORD}
DB_NAME: ${DB_NAME}
COLLECTION_NAME: ${COLLECTION_NAME}
ARANGO_DB_NAME: ${ARANGO_DB_NAME}
ARANGO_COLLECTION_NAME: ${ARANGO_COLLECTION_NAME}
restart: unless-stopped

networks:
Expand Down
16 changes: 6 additions & 10 deletions comps/feedback_management/arango/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,11 @@ This README provides setup guides and all the necessary information about the Fe
See `config.py` for default values.

```bash
export ARANGO_HOST=${ARANGO_HOST}
export ARANGO_PORT=${ARANGO_PORT}
export ARANGO_PROTOCOL=${ARANGO_PROTOCOL}
export ARANGO_URL=${ARANGO_URL}
export ARANGO_USERNAME=${ARANGO_USERNAME}
export ARANGO_PASSWORD=${ARANGO_PASSWORD}
export DB_NAME=${DB_NAME}
export COLLECTION_NAME=${COLLECTION_NAME}
export ARANGO_DB_NAME=${ARANGO_DB_NAME}
export ARANGO_COLLECTION_NAME=${ARANGO_COLLECTION_NAME}
export PYTHONPATH={Path to base of directory}
```

Expand Down Expand Up @@ -46,13 +44,11 @@ docker build -t opea/feedbackmanagement-arango-server:latest --build-arg https_p
-e http_proxy=$http_proxy \
-e https_proxy=$https_proxy \
-e no_proxy=$no_proxy \
-e ARANGO_HOST=${ARANGO_HOST} \
-e ARANGO_PORT=${ARANGO_PORT} \
-e ARANGO_PROTOCOL=${ARANGO_PROTOCOL} \
-e ARANGO_URL=${ARANGO_URL} \
-e ARANGO_USERNAME=${ARANGO_USERNAME} \
-e ARANGO_PASSWORD=${ARANGO_PASSWORD} \
-e DB_NAME=${DB_NAME} \
-e COLLECTION_NAME=${COLLECTION_NAME} \
-e ARANGO_DB_NAME=${ARANGO_DB_NAME} \
-e ARANGO_COLLECTION_NAME=${ARANGO_COLLECTION_NAME} \
opea/feedbackmanagement-arango-server:latest

```
Expand Down
10 changes: 5 additions & 5 deletions comps/feedback_management/arango/arango_conn.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@

from arango import ArangoClient as PythonArangoClient
from arango.database import StandardDatabase
from config import ARANGO_HOST, ARANGO_PASSWORD, ARANGO_PORT, ARANGO_PROTOCOL, ARANGO_USERNAME, DB_NAME
from config import ARANGO_URL, ARANGO_PASSWORD, ARANGO_USERNAME, ARANGO_DB_NAME


class ArangoClient:
conn_url = f"{ARANGO_PROTOCOL}://{ARANGO_HOST}:{ARANGO_PORT}/"
conn_url = ARANGO_URL

@staticmethod
def get_db_client() -> StandardDatabase:
Expand All @@ -19,11 +19,11 @@ def get_db_client() -> StandardDatabase:
sys_db = client.db("_system", username=ARANGO_USERNAME, password=ARANGO_PASSWORD, verify=True)

# Create target database if it doesn't exist
if not sys_db.has_database(DB_NAME):
sys_db.create_database(DB_NAME)
if not sys_db.has_database(ARANGO_DB_NAME):
sys_db.create_database(ARANGO_DB_NAME)

# Now connect to the target database
db = client.db(DB_NAME, username=ARANGO_USERNAME, password=ARANGO_PASSWORD, verify=True)
db = client.db(ARANGO_DB_NAME, username=ARANGO_USERNAME, password=ARANGO_PASSWORD, verify=True)

return db

Expand Down
8 changes: 4 additions & 4 deletions comps/feedback_management/arango/arango_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# SPDX-License-Identifier: Apache-2.0

from arango_conn import ArangoClient
from config import COLLECTION_NAME
from config import ARANGO_COLLECTION_NAME
from pydantic import BaseModel


Expand All @@ -17,10 +17,10 @@ def __init__(
def initialize_storage(self) -> None:
self.db_client = ArangoClient.get_db_client()

if not self.db_client.has_collection(COLLECTION_NAME):
self.db_client.create_collection(COLLECTION_NAME)
if not self.db_client.has_collection(ARANGO_COLLECTION_NAME):
self.db_client.create_collection(ARANGO_COLLECTION_NAME)

self.collection = self.db_client.collection(COLLECTION_NAME)
self.collection = self.db_client.collection(ARANGO_COLLECTION_NAME)

def save_feedback(self, feedback_data: BaseModel) -> str:
"""Stores a new feedback data into the storage.
Expand Down
10 changes: 4 additions & 6 deletions comps/feedback_management/arango/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@

import os

# ARANGO configuration
ARANGO_HOST = os.getenv("ARANGO_HOST", "localhost")
ARANGO_PORT = os.getenv("ARANGO_PORT", 8529)
ARANGO_PROTOCOL = os.getenv("ARANGO_PROTOCOL", "http")
# ArangoDB configuration
ARANGO_URL = os.getenv("ARANGO_URL", "http://localhost:8529")
ARANGO_USERNAME = os.getenv("ARANGO_USERNAME", "root")
ARANGO_PASSWORD = os.getenv("ARANGO_PASSWORD", "test")
DB_NAME = os.getenv("DB_NAME", "OPEA")
COLLECTION_NAME = os.getenv("COLLECTION_NAME", "Feedback")
ARANGO_DB_NAME = os.getenv("ARANGO_DB_NAME", "OPEA")
ARANGO_COLLECTION_NAME = os.getenv("ARANGO_COLLECTION_NAME", "Feedback")
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,11 @@ services:
http_proxy: ${http_proxy}
https_proxy: ${https_proxy}
no_proxy: ${no_proxy}
ARANGO_HOST: ${ARANGO_HOST}
ARANGO_PORT: ${ARANGO_PORT}
ARANGO_PROTOCOL: ${ARANGO_PROTOCOL}
ARANGO_URL: ${ARANGO_URL}
ARANGO_USERNAME: ${ARANGO_USERNAME}
ARANGO_PASSWORD: ${ARANGO_PASSWORD}
DB_NAME: ${DB_NAME}
COLLECTION_NAME: ${COLLECTION_NAME}
ARANGO_DB_NAME: ${ARANGO_DB_NAME}
ARANGO_COLLECTION_NAME: ${ARANGO_COLLECTION_NAME}
restart: unless-stopped

networks:
Expand Down
16 changes: 6 additions & 10 deletions comps/prompt_registry/arango/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,11 @@ This README provides setup guides and all the necessary information about the Pr
See `config.py` for default values.

```bash
export ARANGO_HOST=${ARANGO_HOST}
export ARANGO_PORT=${ARANGO_PORT}
export ARANGO_PROTOCOL=${ARANGO_PROTOCOL}
export ARANGO_URL=${ARANGO_URL}
export ARANGO_USERNAME=${ARANGO_USERNAME}
export ARANGO_PASSWORD=${ARANGO_PASSWORD}
export DB_NAME=${DB_NAME}
export COLLECTION_NAME=${COLLECTION_NAME}
export ARANGO_DB_NAME=${ARANGO_DB_NAME}
export ARANGO_COLLECTION_NAME=${ARANGO_COLLECTION_NAME}
```

---
Expand Down Expand Up @@ -46,13 +44,11 @@ docker build -t opea/promptregistry-arango-server:latest --build-arg https_proxy
-e http_proxy=$http_proxy \
-e https_proxy=$https_proxy \
-e no_proxy=$no_proxy \
-e ARANGO_HOST=${ARANGO_HOST} \
-e ARANGO_PORT=${ARANGO_PORT} \
-e ARANGO_PROTOCOL=${ARANGO_PROTOCOL} \
-e ARANGO_URL=${ARANGO_URL} \
-e ARANGO_USERNAME=${ARANGO_USERNAME} \
-e ARANGO_PASSWORD=${ARANGO_PASSWORD} \
-e DB_NAME=${DB_NAME} \
-e COLLECTION_NAME=${COLLECTION_NAME} \
-e ARANGO_DB_NAME=${ARANGO_DB_NAME} \
-e ARANGO_COLLECTION_NAME=${ARANGO_COLLECTION_NAME} \
opea/promptregistry-arango-server:latest

```
Expand Down
10 changes: 5 additions & 5 deletions comps/prompt_registry/arango/arango_conn.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@

from arango import ArangoClient as PythonArangoClient
from arango.database import StandardDatabase
from config import ARANGO_HOST, ARANGO_PASSWORD, ARANGO_PORT, ARANGO_PROTOCOL, ARANGO_USERNAME, DB_NAME
from config import ARANGO_URL, ARANGO_PASSWORD, ARANGO_USERNAME, ARANGO_DB_NAME


class ArangoClient:
conn_url = f"{ARANGO_PROTOCOL}://{ARANGO_HOST}:{ARANGO_PORT}/"
conn_url = ARANGO_URL

@staticmethod
def get_db_client() -> StandardDatabase:
Expand All @@ -19,11 +19,11 @@ def get_db_client() -> StandardDatabase:
sys_db = client.db("_system", username=ARANGO_USERNAME, password=ARANGO_PASSWORD, verify=True)

# Create target database if it doesn't exist
if not sys_db.has_database(DB_NAME):
sys_db.create_database(DB_NAME)
if not sys_db.has_database(ARANGO_DB_NAME):
sys_db.create_database(ARANGO_DB_NAME)

# Now connect to the target database
db = client.db(DB_NAME, username=ARANGO_USERNAME, password=ARANGO_PASSWORD, verify=True)
db = client.db(ARANGO_DB_NAME, username=ARANGO_USERNAME, password=ARANGO_PASSWORD, verify=True)

return db

Expand Down
9 changes: 4 additions & 5 deletions comps/prompt_registry/arango/arango_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@

from arango.exceptions import IndexGetError
from arango_conn import ArangoClient
from config import COLLECTION_NAME
from config import ARANGO_COLLECTION_NAME
from prompt import PromptCreate
from pydantic import BaseModel

from comps import CustomLogger

Expand All @@ -27,10 +26,10 @@ def __init__(
def initialize_storage(self) -> None:
self.db_client = ArangoClient.get_db_client()

if not self.db_client.has_collection(COLLECTION_NAME):
self.db_client.create_collection(COLLECTION_NAME)
if not self.db_client.has_collection(ARANGO_COLLECTION_NAME):
self.db_client.create_collection(ARANGO_COLLECTION_NAME)

self.collection = self.db_client.collection(COLLECTION_NAME)
self.collection = self.db_client.collection(ARANGO_COLLECTION_NAME)

def save_prompt(self, prompt: PromptCreate):
"""Stores a new prompt into the storage.
Expand Down
10 changes: 4 additions & 6 deletions comps/prompt_registry/arango/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@

import os

# ARANGO configuration
ARANGO_HOST = os.getenv("ARANGO_HOST", "localhost")
ARANGO_PORT = os.getenv("ARANGO_PORT", 8529)
ARANGO_PROTOCOL = os.getenv("ARANGO_PROTOCOL", "http")
# ArangoDB configuration
ARANGO_URL = os.getenv("ARANGO_URL", "http://localhost:8529")
ARANGO_USERNAME = os.getenv("ARANGO_USERNAME", "root")
ARANGO_PASSWORD = os.getenv("ARANGO_PASSWORD", "test")
DB_NAME = os.getenv("DB_NAME", "OPEA")
COLLECTION_NAME = os.getenv("COLLECTION_NAME", "Prompt")
ARANGO_DB_NAME = os.getenv("ARANGO_DB_NAME", "OPEA")
ARANGO_COLLECTION_NAME = os.getenv("ARANGO_COLLECTION_NAME", "Prompt")
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,11 @@ services:
http_proxy: ${http_proxy}
https_proxy: ${https_proxy}
no_proxy: ${no_proxy}
ARANGO_HOST: ${ARANGO_HOST}
ARANGO_PORT: ${ARANGO_PORT}
ARANGO_PROTOCOL: ${ARANGO_PROTOCOL}
ARANGO_URL: ${ARANGO_URL}
ARANGO_USERNAME: ${ARANGO_USERNAME}
ARANGO_PASSWORD: ${ARANGO_PASSWORD}
DB_NAME: ${DB_NAME}
COLLECTION_NAME: ${COLLECTION_NAME}
ARANGO_DB_NAME: ${DB_NAME}
ARANGO_COLLECTION_NAME: ${COLLECTION_NAME}
restart: unless-stopped

networks:
Expand Down
16 changes: 6 additions & 10 deletions tests/chathistory/test_chathistory_arango.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,11 @@ set -x
WORKPATH=$(dirname "$PWD")
ip_address=$(hostname -I | awk '{print $1}')

export ARANGO_HOST=${ip_address}
export ARANGO_PORT=8529
export ARANGO_PROTOCOL=${ARANGO_PROTOCOL:-"http"}
export ARANGO_URL=${ARANGO_URL:-"http://${ip_address}:8529"}
export ARANGO_USERNAME=${ARANGO_USERNAME:-"root"}
export ARANGO_PASSWORD=${ARANGO_PASSWORD:-"test"}
export DB_NAME=${DB_NAME:-"Conversations"}
export COLLECTION_NAME=${COLLECTION_NAME:-"test"}
export ARANGO_DB_NAME=${ARANGO_DB_NAME:-"Conversations"}
export ARANGO_COLLECTION_NAME=${ARANGO_COLLECTION_NAME:-"test"}

function build_docker_images() {
cd $WORKPATH
Expand All @@ -36,13 +34,11 @@ function start_service() {
-e http_proxy=$http_proxy \
-e https_proxy=$https_proxy \
-e no_proxy=$no_proxy \
-e ARANGO_HOST=${ARANGO_HOST} \
-e ARANGO_PORT=${ARANGO_PORT} \
-e ARANGO_PROTOCOL=${ARANGO_PROTOCOL} \
-e ARANGO_URL=${ARANGO_URL} \
-e ARANGO_USERNAME=${ARANGO_USERNAME} \
-e ARANGO_PASSWORD=${ARANGO_PASSWORD} \
-e DB_NAME=${DB_NAME} \
-e COLLECTION_NAME=${COLLECTION_NAME} \
-e ARANGO_DB_NAME=${ARANGO_DB_NAME} \
-e ARANGO_COLLECTION_NAME=${ARANGO_COLLECTION_NAME} \
opea/chathistory-arango-server:comps

sleep 10s
Expand Down
Loading

0 comments on commit c5b936b

Please sign in to comment.