Skip to content

Commit

Permalink
refactor translation ci test (#438)
Browse files Browse the repository at this point in the history
Signed-off-by: chensuyue <suyue.chen@intel.com>
  • Loading branch information
chensuyue authored Jul 23, 2024
1 parent bb42307 commit b7975e7
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 24 deletions.
4 changes: 2 additions & 2 deletions Translation/docker/gaudi/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ Then run the command `docker images`, you will have the following four Docker Im

### Setup Environment Variables

Since the `docker_compose.yaml` will consume some environment variables, you need to setup them in advance as below.
Since the `compose.yaml` will consume some environment variables, you need to setup them in advance as below.

```bash
export http_proxy=${your_http_proxy}
Expand All @@ -65,7 +65,7 @@ Note: Please replace with `host_ip` with you external IP address, do not use loc
### Start Microservice Docker Containers

```bash
docker compose -f docker_compose.yaml up -d
docker compose up -d
```

### Validate Microservices
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions Translation/docker/xeon/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ Then run the command `docker images`, you will have the following Docker Images:

### Setup Environment Variables

Since the `docker_compose.yaml` will consume some environment variables, you need to setup them in advance as below.
Since the `compose.yaml` will consume some environment variables, you need to set up them in advance as below.

```bash
export http_proxy=${your_http_proxy}
Expand All @@ -72,7 +72,7 @@ Note: Please replace with `host_ip` with you external IP address, do not use loc
### Start Microservice Docker Containers

```bash
docker compose -f docker_compose.yaml up -d
docker compose up -d
```

### Validate Microservices
Expand Down
File renamed without changes.
21 changes: 13 additions & 8 deletions Translation/tests/test_translation_on_gaudi.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,18 @@ function start_services() {
export LLM_SERVICE_HOST_IP=${ip_address}
export BACKEND_SERVICE_ENDPOINT="http://${ip_address}:8888/v1/translation"

if [[ "$IMAGE_REPO" != "" ]]; then
# Replace the container name with a test-specific name
echo "using image repository $IMAGE_REPO and image tag $IMAGE_TAG"
sed -i "s#image: opea/translation:latest#image: opea/translation:${IMAGE_TAG}#g" compose.yaml
sed -i "s#image: opea/translation-ui:latest#image: opea/translation-ui:${IMAGE_TAG}#g" compose.yaml
sed -i "s#image: opea/*#image: ${IMAGE_REPO}opea/#g" compose.yaml
echo "cat compose.yaml"
cat compose.yaml
fi

# Start Docker Containers
# TODO: Replace the container name with a test-specific name
docker compose -f docker_compose.yaml up -d
docker compose up -d

sleep 2m # Waits 2 minutes
}
Expand Down Expand Up @@ -130,18 +139,14 @@ function validate_frontend() {

function stop_docker() {
cd $WORKPATH/docker/gaudi
container_list=$(cat docker_compose.yaml | grep container_name | cut -d':' -f2)
for container_name in $container_list; do
cid=$(docker ps -aq --filter "name=$container_name")
if [[ ! -z "$cid" ]]; then docker stop $cid && docker rm $cid && sleep 1s; fi
done
docker compose down
}

function main() {

stop_docker

build_docker_images
if [[ "$IMAGE_REPO" == "" ]]; then build_docker_images; fi
start_services

validate_microservices
Expand Down
38 changes: 26 additions & 12 deletions Translation/tests/test_translation_on_xeon.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,20 @@ WORKPATH=$(dirname "$PWD")
LOG_PATH="$WORKPATH/tests"
ip_address=$(hostname -I | awk '{print $1}')

function build_docker_images() {
cd $WORKPATH
git clone https://github.com/opea-project/GenAIComps.git
cd GenAIComps
docker build --no-cache -t opea/llm-tgi:latest --build-arg https_proxy=$https_proxy --build-arg http_proxy=$http_proxy -f comps/llms/text-generation/tgi/Dockerfile .

cd $WORKPATH/docker
docker build --no-cache -t opea/translation:latest --build-arg https_proxy=$https_proxy --build-arg http_proxy=$http_proxy -f Dockerfile .

cd $WORKPATH/docker/ui
docker build --no-cache -t opea/translation-ui:latest --build-arg https_proxy=$https_proxy --build-arg http_proxy=$http_proxy -f docker/Dockerfile .
docker images
}

function start_services() {
cd $WORKPATH/docker/xeon

Expand All @@ -18,15 +32,18 @@ function start_services() {
export LLM_SERVICE_HOST_IP=${ip_address}
export BACKEND_SERVICE_ENDPOINT="http://${ip_address}:8888/v1/translation"

# Replace the container name with a test-specific name
echo "using image repository $IMAGE_REPO and image tag $IMAGE_TAG"
sed -i "s#image: opea/translation:latest#image: opea/translation:${IMAGE_TAG}#g" docker_compose.yaml
sed -i "s#image: opea/translation-ui:latest#image: opea/translation-ui:${IMAGE_TAG}#g" docker_compose.yaml
sed -i "s#image: opea/*#image: ${IMAGE_REPO}opea/#g" docker_compose.yaml
if [[ "$IMAGE_REPO" != "" ]]; then
# Replace the container name with a test-specific name
echo "using image repository $IMAGE_REPO and image tag $IMAGE_TAG"
sed -i "s#image: opea/translation:latest#image: opea/translation:${IMAGE_TAG}#g" compose.yaml
sed -i "s#image: opea/translation-ui:latest#image: opea/translation-ui:${IMAGE_TAG}#g" compose.yaml
sed -i "s#image: opea/*#image: ${IMAGE_REPO}opea/#g" compose.yaml
echo "cat compose.yaml"
cat compose.yaml
fi

# Start Docker Containers
# TODO: Replace the container name with a test-specific name
docker compose -f docker_compose.yaml up -d
docker compose up -d

sleep 2m # Waits 2 minutes
}
Expand Down Expand Up @@ -117,17 +134,14 @@ function validate_frontend() {

function stop_docker() {
cd $WORKPATH/docker/xeon
container_list=$(cat docker_compose.yaml | grep container_name | cut -d':' -f2)
for container_name in $container_list; do
cid=$(docker ps -aq --filter "name=$container_name")
if [[ ! -z "$cid" ]]; then docker stop $cid && docker rm $cid && sleep 1s; fi
done
docker compose down
}

function main() {

stop_docker

if [[ "$IMAGE_REPO" == "" ]]; then build_docker_images; fi
start_services

validate_microservices
Expand Down

0 comments on commit b7975e7

Please sign in to comment.