Skip to content

Commit

Permalink
Change neo4j Bolt default PORT from 7687 to $NEO4J_PORT2 (opea-projec…
Browse files Browse the repository at this point in the history
…t#1292)

* Change neo4j Bolt default PORT from 7687 to

-configured the port in neo4j compose.yaml to use variable value
-made all corresponding changes in neo4j  dataprep and retriever components and test scripts to use env variable instead of default port value.

Signed-off-by: rbrugaro <[email protected]>

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* missing positional arg in milvus dataprep

Signed-off-by: rbrugaro <[email protected]>

* remove redundance in stop_docker

Signed-off-by: rbrugaro <[email protected]>

* resolve retriever to neo4j connectivity issue bad URL

Signed-off-by: rbrugaro <[email protected]>

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* set neo4j ports to neo4j defaults and fix environment variables in READMEs

Signed-off-by: rbrugaro <[email protected]>

---------

Signed-off-by: rbrugaro <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Liang Lv <[email protected]>
  • Loading branch information
3 people authored Feb 20, 2025
1 parent a4f6af1 commit 135ef91
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 22 deletions.
20 changes: 14 additions & 6 deletions comps/dataprep/src/README_neo4j_llamaindex.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,30 @@ export host_ip=${your_hostname IP} # local IP
export no_proxy=$no_proxy,${host_ip} # important to add {host_ip} for containers communication
export http_proxy=${your_http_proxy}
export https_proxy=${your_http_proxy}
export NEO4J_URI=${your_neo4j_url}
export NEO4J_USERNAME=${your_neo4j_username}
export NEO4J_PASSWORD=${your_neo4j_password} # should match what was used in NEO4J_AUTH when running the neo4j-apoc
export PYTHONPATH=${path_to_comps}
export OPENAI_KEY=${your_openai_api_key} # optional, when not provided will use open models TGI/TEI
export HUGGINGFACEHUB_API_TOKEN=${your_hf_token}
export DATA_PATH=${host_path_to_volume_mnt}

# set additional environment settings
export EMBEDDING_MODEL_ID="BAAI/bge-base-en-v1.5"
export EMBED_MODEL=${EMBEDDING_MODEL_ID}
export OPENAI_EMBEDDING_MODEL="text-embedding-3-small"
export LLM_MODEL_ID="meta-llama/Meta-Llama-3-8B-Instruct"
export LLM_MODEL_ID="meta-llama/Meta-Llama-3.1-8B-Instruct"
export MAX_INPUT_TOKENS=4096
export MAX_TOTAL_TOKENS=8192
export OPENAI_LLM_MODEL="gpt-4o"
export TEI_EMBEDDING_ENDPOINT="http://${host_ip}:6006"
export TGI_LLM_ENDPOINT="http://${host_ip}:6005"
export NEO4J_URL="bolt://${host_ip}:7687"
export NEO4J_USERNAME=neo4j
export TEI_EMBEDDER_PORT=11633
export TEI_EMBEDDING_ENDPOINT="http://${host_ip}:${TEI_EMBEDDER_PORT}"
export LLM_ENDPOINT_PORT=11634
export TGI_LLM_ENDPOINT="http://${host_ip}:${LLM_ENDPOINT_PORT}"
export NEO4J_AUTH="${NEO4J_USERNAME}/${NEO4J_PASSWORD}"
export NEO4J_PORT1=7474 # 11631
export NEO4J_PORT2=7687 # 11632
export NEO4J_URI="bolt://${host_ip}:${NEO4J_PORT2}"
export NEO4J_URL="bolt://${host_ip}:${NEO4J_PORT2}"
export DATAPREP_SERVICE_ENDPOINT="http://${host_ip}:6004/v1/dataprep"
export LOGFLAG=True
```
Expand Down
3 changes: 2 additions & 1 deletion comps/dataprep/src/integrations/neo4j_llamaindex.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,9 @@
from llama_index.core.schema import BaseNode, TransformComponent

host_ip = os.getenv("host_ip")
NEO4J_PORT2 = os.getenv("NEO4J_PORT2")
# Neo4J configuration
NEO4J_URL = os.getenv("NEO4J_URL", f"bolt://{host_ip}:7687")
NEO4J_URL = os.getenv("NEO4J_URL", f"bolt://{host_ip}:{NEO4J_PORT2}")
NEO4J_USERNAME = os.getenv("NEO4J_USERNAME", "neo4j")
NEO4J_PASSWORD = os.getenv("NEO4J_PASSWORD", "neo4jtest")

Expand Down
1 change: 1 addition & 0 deletions comps/retrievers/deployment/docker_compose/compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ services:
EMBEDDING_MODEL_ID: ${EMBEDDING_MODEL_ID}
LLM_MODEL_ID: ${LLM_MODEL_ID}
NEO4J_URI: ${NEO4J_URI}
NEO4J_URL: ${NEO4J_URI}
NEO4J_USERNAME: ${NEO4J_USERNAME}
NEO4J_PASSWORD: ${NEO4J_PASSWORD}
VDMS_USE_CLIP: 0
Expand Down
18 changes: 14 additions & 4 deletions comps/retrievers/src/README_neo4j.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,22 +44,32 @@ export host_ip=${your_hostname IP} # local IP
export no_proxy=$no_proxy,${host_ip} # important to add {host_ip} for containers communication
export http_proxy=${your_http_proxy}
export https_proxy=${your_http_proxy}
export NEO4J_URI=${your_neo4j_url}
export NEO4J_USERNAME=${your_neo4j_username}
export NEO4J_PASSWORD=${your_neo4j_password}
export PYTHONPATH=${path_to_comps}
export OPENAI_KEY=${your_openai_api_key} # optional, when not provided will use smaller models TGI/TEI
export HUGGINGFACEHUB_API_TOKEN=${your_hf_token}
export DATA_PATH=${host_path_to_volume_mnt}

# set additional environment settings
export EMBEDDING_MODEL_ID="BAAI/bge-base-en-v1.5"
export OPENAI_EMBEDDING_MODEL="text-embedding-3-small"
export LLM_MODEL_ID="meta-llama/Meta-Llama-3-8B-Instruct"
export LLM_MODEL_ID="meta-llama/Meta-Llama-3.1-8B-Instruct"
export MAX_INPUT_TOKENS=4096
export MAX_TOTAL_TOKENS=8192
export OPENAI_LLM_MODEL="gpt-4o"
export TEI_EMBEDDER_PORT=11633
export TEI_EMBEDDING_ENDPOINT="http://${host_ip}:${TEI_EMBEDDER_PORT}"
export LLM_ENDPOINT_PORT=11634
export TGI_LLM_ENDPOINT="http://${host_ip}:${LLM_ENDPOINT_PORT}"
export TEI_EMBEDDING_ENDPOINT="http://${host_ip}:6006"
export TGI_LLM_ENDPOINT="http://${host_ip}:6005"
export NEO4J_URL="bolt://${host_ip}:7687"
export NEO4J_USERNAME=neo4j
export NEO4J_PORT1=7474 # 11631
export NEO4J_PORT2=7687 # 11632
export NEO4J_URI="bolt://${host_ip}:${NEO4J_PORT2}"
export NEO4J_URL="bolt://${host_ip}:${NEO4J_PORT2}"
export DATAPREP_SERVICE_ENDPOINT="http://${host_ip}:6004/v1/dataprep"
export RETRIEVER_PORT=11635
export LOGFLAG=True
```

Expand Down
3 changes: 2 additions & 1 deletion comps/retrievers/src/integrations/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ def get_boolean_env_var(var_name, default_value=False):
#######################################################
# Neo4j #
#######################################################
NEO4J_URL = os.getenv("NEO4J_URI", "bolt://localhost:7687")
NEO4J_PORT2 = os.getenv("NEO4J_PORT2", "11632")
NEO4J_URL = os.getenv("NEO4J_URI", f"bolt://localhost:{NEO4J_PORT2}")
NEO4J_USERNAME = os.getenv("NEO4J_USERNAME", "neo4j")
NEO4J_PASSWORD = os.getenv("NEO4J_PASSWORD", "test")
host_ip = os.getenv("host_ip")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ services:
- "${NEO4J_PORT1:-7474}:7474"
- "${NEO4J_PORT2:-7687}:7687"
volumes:
- /$HOME/neo4j/logs:/logs
- /$HOME/neo4j/config:/config
- /$HOME/neo4j/data:/data
- /$HOME/neo4j/plugins:/plugins
- ./data/neo4j/logs:/logs
- ./data/neo4j/config:/config
- ./data/neo4j/data:/data
- ./data/neo4j/plugins:/plugins
ipc: host
environment:
- no_proxy=${no_proxy}
Expand All @@ -24,6 +24,7 @@ services:
- NEO4J_apoc_import_file_enabled=true
- NEO4J_apoc_import_file_use__neo4j__config=true
- NEO4J_dbms_security_procedures_unrestricted=apoc.\*
- NEO4J_server_bolt_advertised__address=localhost:${NEO4J_PORT2}
restart: always
healthcheck:
test: wget http://localhost:7474 || exit 1
Expand Down
6 changes: 4 additions & 2 deletions tests/dataprep/test_dataprep_neo4j_on_intel_hpu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@ function build_docker_images() {
function start_service() {
service_name="neo4j-apoc tei-embedding-serving tgi-gaudi-server dataprep-neo4j-llamaindex"
export host_ip=${ip_address}
export NEO4J_PORT1=7474 # 11631
export NEO4J_PORT2=7687 # 11632
export NEO4J_AUTH="neo4j/neo4jtest"
export NEO4J_URL="bolt://${ip_address}:7687"
export NEO4J_URL="bolt://${ip_address}:${NEO4J_PORT2}"
export NEO4J_USERNAME="neo4j"
export NEO4J_PASSWORD="neo4jtest"
export NEO4J_apoc_export_file_enabled=true
Expand Down Expand Up @@ -95,7 +97,7 @@ function validate_service() {
function validate_microservice() {
# validate neo4j-apoc
validate_service \
"${ip_address}:7474" \
"${ip_address}:${NEO4J_PORT1}" \
"200 OK" \
"neo4j-apoc" \
"neo4j-apoc" \
Expand Down
11 changes: 7 additions & 4 deletions tests/retrievers/test_retrievers_neo4j_on_intel_hpu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,10 @@ function start_service() {
export LLM_MODEL_ID="meta-llama/Meta-Llama-3.1-8B-Instruct"
export TGI_LLM_ENDPOINT="http://${host_ip}:${LLM_ENDPOINT_PORT}"
export DATAPREP_SERVICE_ENDPOINT="http://${host_ip}:6004"
export NEO4J_URI="bolt://${host_ip}:7687"
export NEO4J_PORT1=7474 # 11631
export NEO4J_PORT2=7687 # 11632
export NEO4J_URI="bolt://${host_ip}:${NEO4J_PORT2}"
export NEO4J_URL="bolt://${host_ip}:${NEO4J_PORT2}"
export NEO4J_USERNAME="neo4j"
export NEO4J_PASSWORD="neo4jtest"
export no_proxy="localhost,127.0.0.1,"${host_ip}
Expand All @@ -64,8 +67,8 @@ function start_service() {
# Not testing openai code path since not able to provide key for cicd
docker run -d --name="test-comps-retrievers-neo4j-llama-index-dataprep" -p 6004:5000 -v ./data:/data --ipc=host -e TGI_LLM_ENDPOINT=$TGI_LLM_ENDPOINT \
-e TEI_EMBEDDING_ENDPOINT=$TEI_EMBEDDING_ENDPOINT -e EMBEDDING_MODEL_ID=$EMBEDDING_MODEL_ID -e LLM_MODEL_ID=$LLM_MODEL_ID -e host_ip=$host_ip -e no_proxy=$no_proxy \
-e http_proxy=$http_proxy -e https_proxy=$https_proxy -e NEO4J_URL="bolt://${host_ip}:7687" -e NEO4J_USERNAME="neo4j" \
-e NEO4J_PASSWORD="neo4jtest" -e HF_TOKEN=$HF_TOKEN -e MAX_INPUT_TOKENS=$MAX_INPUT_TOKENS -e LOGFLAG=True \
-e http_proxy=$http_proxy -e https_proxy=$https_proxy -e NEO4J_URL="bolt://${host_ip}:${NEO4J_PORT2}" -e NEO4J_USERNAME="neo4j" \
-e NEO4J_PASSWORD="neo4jtest" -e NEO4J_PORT1=$NEO4J_PORT1 -e NEO4J_PORT2=$NEO4J_PORT2 -e HF_TOKEN=$HF_TOKEN -e MAX_INPUT_TOKENS=$MAX_INPUT_TOKENS -e LOGFLAG=True \
-e DATAPREP_COMPONENT_NAME="OPEA_DATAPREP_NEO4J_LLAMAINDEX" opea/dataprep-neo4j-llamaindex:comps

sleep 1m
Expand Down Expand Up @@ -117,7 +120,7 @@ function validate_service() {
function validate_microservice() {
# validate neo4j-apoc
validate_service \
"${host_ip}:7474" \
"${host_ip}:${NEO4J_PORT1}" \
"200 OK" \
"neo4j-apoc" \
"neo4j-apoc" \
Expand Down

0 comments on commit 135ef91

Please sign in to comment.