From ac82cecdd92fd31353c63a77b8468f9de0d819c2 Mon Sep 17 00:00:00 2001 From: Melanie Buehler Date: Mon, 21 Oct 2024 11:49:55 -0700 Subject: [PATCH 1/6] Combined image and video endpoint Signed-off-by: Melanie Buehler --- .../redis/langchain/multimodal_utils.py | 4 +- .../redis/langchain/prepare_videodoc_redis.py | 68 +++++++++---------- 2 files changed, 36 insertions(+), 36 deletions(-) diff --git a/comps/dataprep/multimodal/redis/langchain/multimodal_utils.py b/comps/dataprep/multimodal/redis/langchain/multimodal_utils.py index f8168b582a..fbee9cf9d9 100644 --- a/comps/dataprep/multimodal/redis/langchain/multimodal_utils.py +++ b/comps/dataprep/multimodal/redis/langchain/multimodal_utils.py @@ -39,8 +39,8 @@ def clear_upload_folder(upload_path): os.rmdir(dir_path) -def generate_video_id(): - """Generates a unique identifier for a video file.""" +def generate_id(): + """Generates a unique identifier for a file.""" return str(uuid.uuid4()) diff --git a/comps/dataprep/multimodal/redis/langchain/prepare_videodoc_redis.py b/comps/dataprep/multimodal/redis/langchain/prepare_videodoc_redis.py index 48051d05cb..9af16512f9 100644 --- a/comps/dataprep/multimodal/redis/langchain/prepare_videodoc_redis.py +++ b/comps/dataprep/multimodal/redis/langchain/prepare_videodoc_redis.py @@ -23,7 +23,7 @@ extract_frames_and_annotations_from_transcripts, extract_frames_and_generate_captions, extract_transcript_from_audio, - generate_video_id, + generate_id, load_json_file, load_whisper_model, write_vtt, @@ -287,7 +287,7 @@ async def ingest_videos_generate_transcripts(files: List[UploadFile] = File(None print(f"Processing video {video_file.filename}") # Assign unique identifier to video - video_id = generate_video_id() + video_id = generate_id() # Create video file name by appending identifier video_name = os.path.splitext(video_file.filename)[0] @@ -349,7 +349,7 @@ async def ingest_videos_generate_transcripts(files: List[UploadFile] = File(None return { "status": 200, "message": "Data preparation succeeded", - "video_id_maps": uploaded_videos_saved_videos_map, + "file_id_maps": uploaded_videos_saved_videos_map, } raise HTTPException(status_code=400, detail="Must provide at least one video (.mp4) file.") @@ -359,58 +359,58 @@ async def ingest_videos_generate_transcripts(files: List[UploadFile] = File(None name="opea_service@prepare_videodoc_redis", endpoint="/v1/generate_captions", host="0.0.0.0", port=6007 ) async def ingest_videos_generate_caption(files: List[UploadFile] = File(None)): - """Upload videos without speech (only background music or no audio), generate captions using lvm microservice and ingest into redis.""" + """Upload images and videos without speech (only background music or no audio), generate captions using lvm microservice and ingest into redis.""" if files: - video_files = [] - uploaded_videos_saved_videos_map = {} + file_paths = [] + uploaded_files_saved_files_map = {} for file in files: - if os.path.splitext(file.filename)[1] == ".mp4": - video_files.append(file) + if os.path.splitext(file.filename)[1] in [".mp4", ".png", ".jpg", ".jpeg", ".gif"]: + file_paths.append(file) else: raise HTTPException( - status_code=400, detail=f"File {file.filename} is not an mp4 file. Please upload mp4 files only." + status_code=400, detail=f"File {file.filename} is not a supported file type. Please upload mp4, png, jpg, jpeg, and gif files only." ) - for video_file in video_files: - print(f"Processing video {video_file.filename}") + for file in file_paths: + print(f"Processing file {file.filename}") - # Assign unique identifier to video - video_id = generate_video_id() + # Assign unique identifier to file + id = generate_id() - # Create video file name by appending identifier - video_name = os.path.splitext(video_file.filename)[0] - video_file_name = f"{video_name}_{video_id}.mp4" - video_dir_name = os.path.splitext(video_file_name)[0] + # Create file name by appending identifier + name, ext = os.path.splitext(file.filename) + file_name = f"{name}_{id}{ext}" + dir_name = os.path.splitext(file_name)[0] - # Save video file in upload_directory - with open(os.path.join(upload_folder, video_file_name), "wb") as f: - shutil.copyfileobj(video_file.file, f) - uploaded_videos_saved_videos_map[video_name] = video_file_name + # Save file in upload_directory + with open(os.path.join(upload_folder, file_name), "wb") as f: + shutil.copyfileobj(file.file, f) + uploaded_files_saved_files_map[name] = file_name # Store frames and caption annotations in a new directory extract_frames_and_generate_captions( - video_id, - os.path.join(upload_folder, video_file_name), + id, + os.path.join(upload_folder, file_name), LVM_ENDPOINT, - os.path.join(upload_folder, video_dir_name), + os.path.join(upload_folder, dir_name), ) # Ingest multimodal data into redis - ingest_multimodal(video_name, os.path.join(upload_folder, video_dir_name), embeddings) + ingest_multimodal(name, os.path.join(upload_folder, dir_name), embeddings) - # Delete temporary video directory containing frames and annotations - # shutil.rmtree(os.path.join(upload_folder, video_dir_name)) + # Delete temporary directory containing frames and annotations + # shutil.rmtree(os.path.join(upload_folder, dir_name)) - print(f"Processed video {video_file.filename}") + print(f"Processed file {file.filename}") return { "status": 200, "message": "Data preparation succeeded", - "video_id_maps": uploaded_videos_saved_videos_map, + "file_id_maps": uploaded_files_saved_files_map, } - raise HTTPException(status_code=400, detail="Must provide at least one video (.mp4) file.") + raise HTTPException(status_code=400, detail="Must provide at least one file.") @register_microservice( @@ -434,7 +434,7 @@ async def ingest_images_generate_caption(files: List[UploadFile] = File(None)): print(f"Processing image {image_file.filename}") # Assign unique identifier to image - image_id = generate_video_id() + image_id = generate_id() # Create image file name by appending identifier image_name, image_ext = os.path.splitext(image_file.filename) @@ -462,7 +462,7 @@ async def ingest_images_generate_caption(files: List[UploadFile] = File(None)): return { "status": 200, "message": "Data preparation succeeded", - "image_id_maps": uploaded_images_saved_images_map, + "file_id_maps": uploaded_images_saved_images_map, } raise HTTPException(status_code=400, detail="Must provide at least one image file.") @@ -508,7 +508,7 @@ async def ingest_videos_with_transcripts(files: List[UploadFile] = File(None)): print(f"Processing video {video_file.filename}") # Assign unique identifier to video - video_id = generate_video_id() + video_id = generate_id() # Create video file name by appending identifier video_name = os.path.splitext(video_file.filename)[0] @@ -553,7 +553,7 @@ async def ingest_videos_with_transcripts(files: List[UploadFile] = File(None)): return { "status": 200, "message": "Data preparation succeeded", - "video_id_maps": uploaded_videos_saved_videos_map, + "file_id_maps": uploaded_videos_saved_videos_map, } raise HTTPException( From 83225e6d25066b858a0047de040663818078dca5 Mon Sep 17 00:00:00 2001 From: Melanie Buehler Date: Mon, 21 Oct 2024 15:50:50 -0700 Subject: [PATCH 2/6] Add test and update README Signed-off-by: Melanie Buehler --- .../multimodal/redis/langchain/README.md | 21 ++++++++--- ...est_dataprep_multimodal_redis_langchain.sh | 37 ++++++++++++++++--- 2 files changed, 48 insertions(+), 10 deletions(-) diff --git a/comps/dataprep/multimodal/redis/langchain/README.md b/comps/dataprep/multimodal/redis/langchain/README.md index 65e4f5d45f..59c6e27591 100644 --- a/comps/dataprep/multimodal/redis/langchain/README.md +++ b/comps/dataprep/multimodal/redis/langchain/README.md @@ -1,6 +1,8 @@ # Dataprep Microservice for Multimodal Data with Redis -This `dataprep` microservice accepts videos (mp4 files) and their transcripts (optional) from the user and ingests them into Redis vectorstore. +This `dataprep` microservice accepts the following from the user and ingests them into a Redis vectorstore: +* Videos (mp4 files) and their transcripts (optional) +* Images (gif, jpg, jpeg, and png files) ## 🚀1. Start Microservice with Python(Option 1) @@ -107,9 +109,9 @@ docker container logs -f dataprep-multimodal-redis ## 🚀4. Consume Microservice -Once this dataprep microservice is started, user can use the below commands to invoke the microservice to convert videos and their transcripts (optional) to embeddings and save to the Redis vector store. +Once this dataprep microservice is started, user can use the below commands to invoke the microservice to convert images and videos and their transcripts (optional) to embeddings and save to the Redis vector store. -This mircroservice has provided 3 different ways for users to ingest videos into Redis vector store corresponding to the 3 use cases. +This microservice has provided 3 different ways for users to ingest files into Redis vector store corresponding to the 3 use cases. ### 4.1 Consume _videos_with_transcripts_ API @@ -169,9 +171,9 @@ curl -X POST \ ### 4.3 Consume _generate_captions_ API -**Use case:** This API should be used when a video does not have meaningful audio or does not have audio. +**Use case:** This API should be used when uploading an image, or when uploading a video that does not have meaningful audio or does not have audio. -In this use case, transcript either does not provide any meaningful information or does not exist. Thus, it is preferred to leverage a LVM microservice to summarize the video frames. +In this use case, there is no meaningful language transcription. Thus, it is preferred to leverage a LVM microservice to summarize the frames. - Single video upload @@ -192,6 +194,15 @@ curl -X POST \ http://localhost:6007/v1/generate_captions ``` +- Single image upload + +```bash +curl -X POST \ + -H "Content-Type: multipart/form-data" \ + -F "files=@./image.jpg" \ + http://localhost:6007/v1/generate_captions +``` + ### 4.4 Consume get_videos API To get names of uploaded videos, use the following command. diff --git a/tests/dataprep/test_dataprep_multimodal_redis_langchain.sh b/tests/dataprep/test_dataprep_multimodal_redis_langchain.sh index a7461a8abb..645f07b4b5 100644 --- a/tests/dataprep/test_dataprep_multimodal_redis_langchain.sh +++ b/tests/dataprep/test_dataprep_multimodal_redis_langchain.sh @@ -14,6 +14,7 @@ INDEX_NAME="dataprep" video_name="WeAreGoingOnBullrun" transcript_fn="${video_name}.vtt" video_fn="${video_name}.mp4" +image_fn="apple.png" function build_docker_images() { cd $WORKPATH @@ -31,14 +32,14 @@ function build_docker_images() { function build_lvm_docker_images() { cd $WORKPATH echo $(pwd) - docker build --no-cache -t opea/lvm-llava:comps -f comps/lvms/llava/dependency/Dockerfile . + docker build --no-cache -t opea/lvm-llava:comps --build-arg https_proxy=$https_proxy --build-arg http_proxy=$http_proxy -f comps/lvms/llava/dependency/Dockerfile . if [ $? -ne 0 ]; then echo "opea/lvm-llava built fail" exit 1 else echo "opea/lvm-llava built successful" fi - docker build --no-cache -t opea/lvm-llava-svc:comps -f comps/lvms/llava/Dockerfile . + docker build --no-cache -t opea/lvm-llava-svc:comps --build-arg https_proxy=$https_proxy --build-arg http_proxy=$http_proxy -f comps/lvms/llava/Dockerfile . if [ $? -ne 0 ]; then echo "opea/lvm-llava-svc built fail" exit 1 @@ -115,7 +116,10 @@ place to watch it is on BlackmagicShine.com. We're right here on the smoking 00:00:45.240 --> 00:00:47.440 tire.""" > ${transcript_fn} - echo "Downloading Video" + #echo "Downloading Image" + wget https://github.com/docarray/docarray/blob/main/tests/toydata/image-data/apple.png?raw=true -O ${image_fn} + + #echo "Downloading Video" wget http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/WeAreGoingOnBullrun.mp4 -O ${video_fn} } @@ -170,8 +174,8 @@ function validate_microservice() { echo "[ $SERVICE_NAME ] Content is as expected." fi - # test v1/generate_captions upload file - echo "Testing generate_captions API" + # test v1/generate_captions upload video file + echo "Testing generate_captions API with video" URL="http://${ip_address}:$dataprep_service_port/v1/generate_captions" HTTP_RESPONSE=$(curl --silent --write-out "HTTPSTATUS:%{http_code}" -X POST -F "files=@./$video_fn" -H 'Content-Type: multipart/form-data' "$URL") @@ -194,7 +198,29 @@ function validate_microservice() { echo "[ $SERVICE_NAME ] Content is as expected." fi + # test v1/generate_captions upload image file + echo "Testing generate_captions API with image" + URL="http://${ip_address}:$dataprep_service_port/v1/generate_captions" + + HTTP_RESPONSE=$(curl --silent --write-out "HTTPSTATUS:%{http_code}" -X POST -F "files=@./$image_fn" -H 'Content-Type: multipart/form-data' "$URL") + HTTP_STATUS=$(echo $HTTP_RESPONSE | tr -d '\n' | sed -e 's/.*HTTPSTATUS://') + RESPONSE_BODY=$(echo $HTTP_RESPONSE | sed -e 's/HTTPSTATUS\:.*//g') + SERVICE_NAME="dataprep - upload - file" + if [ "$HTTP_STATUS" -ne "200" ]; then + echo "[ $SERVICE_NAME ] HTTP status is not 200. Received status was $HTTP_STATUS" + docker logs test-comps-dataprep-multimodal-redis >> ${LOG_PATH}/dataprep_upload_file.log + exit 1 + else + echo "[ $SERVICE_NAME ] HTTP status is 200. Checking content..." + fi + if [[ "$RESPONSE_BODY" != *"Data preparation succeeded"* ]]; then + echo "[ $SERVICE_NAME ] Content does not match the expected result: $RESPONSE_BODY" + docker logs test-comps-dataprep-multimodal-redis >> ${LOG_PATH}/dataprep_upload_file.log + exit 1 + else + echo "[ $SERVICE_NAME ] Content is as expected." + fi # test /v1/dataprep/get_videos echo "Testing get_videos API" @@ -257,6 +283,7 @@ function delete_data() { cd ${LOG_PATH} rm -rf WeAreGoingOnBullrun.vtt rm -rf WeAreGoingOnBullrun.mp4 + rm -rf apple.png sleep 1s } From 3320b4823344726a9b7ecff9835b02ef36dd4424 Mon Sep 17 00:00:00 2001 From: Melanie Buehler Date: Tue, 22 Oct 2024 16:28:45 -0700 Subject: [PATCH 3/6] Fixed test script Signed-off-by: Melanie Buehler --- ...est_dataprep_multimodal_redis_langchain.sh | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/tests/dataprep/test_dataprep_multimodal_redis_langchain.sh b/tests/dataprep/test_dataprep_multimodal_redis_langchain.sh index 645f07b4b5..c800c97a4c 100644 --- a/tests/dataprep/test_dataprep_multimodal_redis_langchain.sh +++ b/tests/dataprep/test_dataprep_multimodal_redis_langchain.sh @@ -19,7 +19,7 @@ image_fn="apple.png" function build_docker_images() { cd $WORKPATH echo $(pwd) - docker build --no-cache -t opea/dataprep-multimodal-redis:comps --build-arg https_proxy=$https_proxy --build-arg http_proxy=$http_proxy -f comps/dataprep/multimodal/redis/langchain/Dockerfile . + docker build --no-cache -t opea/dataprep-multimodal-redis:comps --build-arg https_proxy=$https_proxy --build-arg http_proxy=$http_proxy --build-arg no_proxy=$no_proxy -f comps/dataprep/multimodal/redis/langchain/Dockerfile . if [ $? -ne 0 ]; then echo "opea/dataprep-multimodal-redis built fail" @@ -32,14 +32,14 @@ function build_docker_images() { function build_lvm_docker_images() { cd $WORKPATH echo $(pwd) - docker build --no-cache -t opea/lvm-llava:comps --build-arg https_proxy=$https_proxy --build-arg http_proxy=$http_proxy -f comps/lvms/llava/dependency/Dockerfile . + docker build --no-cache -t opea/lvm-llava:comps --build-arg https_proxy=$https_proxy --build-arg http_proxy=$http_proxy --build-arg no_proxy=$no_proxy -f comps/lvms/llava/dependency/Dockerfile . if [ $? -ne 0 ]; then echo "opea/lvm-llava built fail" exit 1 else echo "opea/lvm-llava built successful" fi - docker build --no-cache -t opea/lvm-llava-svc:comps --build-arg https_proxy=$https_proxy --build-arg http_proxy=$http_proxy -f comps/lvms/llava/Dockerfile . + docker build --no-cache -t opea/lvm-llava-svc:comps --build-arg https_proxy=$https_proxy --build-arg http_proxy=$http_proxy --build-arg no_proxy=$no_proxy -f comps/lvms/llava/Dockerfile . if [ $? -ne 0 ]; then echo "opea/lvm-llava-svc built fail" exit 1 @@ -49,9 +49,9 @@ function build_lvm_docker_images() { } function start_lvm_service() { - unset http_proxy - docker run -d --name="test-comps-lvm-llava" -e http_proxy=$http_proxy -e https_proxy=$https_proxy -p 5029:8399 --ipc=host opea/lvm-llava:comps - docker run -d --name="test-comps-lvm-llava-svc" -e LVM_ENDPOINT=http://$ip_address:5029 -e http_proxy=$http_proxy -e https_proxy=$https_proxy -p ${LVM_PORT}:9399 --ipc=host opea/lvm-llava-svc:comps + # unset http_proxy + docker run -d --name="test-comps-lvm-llava" -e http_proxy=$http_proxy -e https_proxy=$https_proxy -e no_proxy=$no_proxy -p 5029:8399 --ipc=host opea/lvm-llava:comps + docker run -d --name="test-comps-lvm-llava-svc" -e LVM_ENDPOINT=http://$ip_address:5029 -e http_proxy=$http_proxy -e https_proxy=$https_proxy -e no_proxy=$no_proxy -p ${LVM_PORT}:9399 --ipc=host opea/lvm-llava-svc:comps sleep 5m } @@ -69,13 +69,13 @@ function start_service() { # start redis echo "Starting Redis server" REDIS_PORT=6380 - docker run -d --name="test-redis" -e http_proxy=$http_proxy -e https_proxy=$https_proxy -p $REDIS_PORT:6379 -p 8002:8001 --ipc=host redis/redis-stack:7.2.0-v9 + docker run -d --name="test-redis" -e http_proxy=$http_proxy -e https_proxy=$https_proxy -e no_proxy=$no_proxy -p $REDIS_PORT:6379 -p 8002:8001 --ipc=host redis/redis-stack:7.2.0-v9 # start dataprep microservice echo "Starting dataprep microservice" dataprep_service_port=5013 REDIS_URL="redis://${ip_address}:${REDIS_PORT}" - docker run -d --name="test-comps-dataprep-multimodal-redis" -e http_proxy=$http_proxy -e https_proxy=$https_proxy -e REDIS_URL=$REDIS_URL -e INDEX_NAME=$INDEX_NAME -e LVM_ENDPOINT=$LVM_ENDPOINT -p ${dataprep_service_port}:6007 --runtime=runc --ipc=host opea/dataprep-multimodal-redis:comps + docker run -d --name="test-comps-dataprep-multimodal-redis" -e http_proxy=$http_proxy -e https_proxy=$https_proxy -e no_proxy=$no_proxy -e REDIS_URL=$REDIS_URL -e REDIS_HOST=$ip_address -e INDEX_NAME=$INDEX_NAME -e LVM_ENDPOINT=$LVM_ENDPOINT -p ${dataprep_service_port}:6007 --runtime=runc --ipc=host opea/dataprep-multimodal-redis:comps sleep 1m } @@ -116,10 +116,10 @@ place to watch it is on BlackmagicShine.com. We're right here on the smoking 00:00:45.240 --> 00:00:47.440 tire.""" > ${transcript_fn} - #echo "Downloading Image" + echo "Downloading Image" wget https://github.com/docarray/docarray/blob/main/tests/toydata/image-data/apple.png?raw=true -O ${image_fn} - #echo "Downloading Video" + echo "Downloading Video" wget http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/WeAreGoingOnBullrun.mp4 -O ${video_fn} } From 007aba8001372796b135b68eb80cf52ffcca9f96 Mon Sep 17 00:00:00 2001 From: Melanie Buehler Date: Wed, 23 Oct 2024 12:00:52 -0700 Subject: [PATCH 4/6] Remove redundant function Signed-off-by: Melanie Buehler --- .../redis/langchain/prepare_videodoc_redis.py | 55 ------------------- 1 file changed, 55 deletions(-) diff --git a/comps/dataprep/multimodal/redis/langchain/prepare_videodoc_redis.py b/comps/dataprep/multimodal/redis/langchain/prepare_videodoc_redis.py index 9af16512f9..c63be0833b 100644 --- a/comps/dataprep/multimodal/redis/langchain/prepare_videodoc_redis.py +++ b/comps/dataprep/multimodal/redis/langchain/prepare_videodoc_redis.py @@ -413,61 +413,6 @@ async def ingest_videos_generate_caption(files: List[UploadFile] = File(None)): raise HTTPException(status_code=400, detail="Must provide at least one file.") -@register_microservice( - name="opea_service@prepare_videodoc_redis", endpoint="/v1/image_generate_captions", host="0.0.0.0", port=6007 -) -async def ingest_images_generate_caption(files: List[UploadFile] = File(None)): - """Upload images without captions, generate captions using lvm microservice and ingest into redis.""" - - if files: - image_files = [] - uploaded_images_saved_images_map = {} - for file in files: - if os.path.splitext(file.filename)[1] in (".png", ".jpg", ".jpeg", ".gif"): - image_files.append(file) - else: - raise HTTPException( - status_code=400, detail=f"File {file.filename} is not a valid image file type. Please upload .png, .jpg, .jpeg, or .gif files only." - ) - - for image_file in image_files: - print(f"Processing image {image_file.filename}") - - # Assign unique identifier to image - image_id = generate_id() - - # Create image file name by appending identifier - image_name, image_ext = os.path.splitext(image_file.filename) - image_file_name = f"{image_name}_{image_id}{image_ext}" - image_dir_name = os.path.splitext(image_file_name)[0] - - # Save image file in upload_directory - with open(os.path.join(upload_folder, image_file_name), "wb") as f: - shutil.copyfileobj(image_file.file, f) - uploaded_images_saved_images_map[image_name] = image_file_name - - # Store frame and caption annotations in a new directory - extract_frames_and_generate_captions( - image_id, - os.path.join(upload_folder, image_file_name), - LVM_ENDPOINT, - os.path.join(upload_folder, image_dir_name), - ) - - # Ingest multimodal data into redis - ingest_multimodal(image_name, os.path.join(upload_folder, image_dir_name), embeddings) - - print(f"Processed image {image_file.filename}") - - return { - "status": 200, - "message": "Data preparation succeeded", - "file_id_maps": uploaded_images_saved_images_map, - } - - raise HTTPException(status_code=400, detail="Must provide at least one image file.") - - @register_microservice( name="opea_service@prepare_videodoc_redis", endpoint="/v1/videos_with_transcripts", From 313b344616f0afdde26f5da2928a57858eade0b6 Mon Sep 17 00:00:00 2001 From: Melanie Buehler Date: Wed, 23 Oct 2024 21:45:55 -0700 Subject: [PATCH 5/6] Updates test per review feedback Signed-off-by: Melanie Buehler --- ...est_dataprep_multimodal_redis_langchain.sh | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/tests/dataprep/test_dataprep_multimodal_redis_langchain.sh b/tests/dataprep/test_dataprep_multimodal_redis_langchain.sh index c800c97a4c..c2ecc19d2a 100644 --- a/tests/dataprep/test_dataprep_multimodal_redis_langchain.sh +++ b/tests/dataprep/test_dataprep_multimodal_redis_langchain.sh @@ -14,12 +14,13 @@ INDEX_NAME="dataprep" video_name="WeAreGoingOnBullrun" transcript_fn="${video_name}.vtt" video_fn="${video_name}.mp4" -image_fn="apple.png" +image_name="apple" +image_fn="${image_name}.png" function build_docker_images() { cd $WORKPATH echo $(pwd) - docker build --no-cache -t opea/dataprep-multimodal-redis:comps --build-arg https_proxy=$https_proxy --build-arg http_proxy=$http_proxy --build-arg no_proxy=$no_proxy -f comps/dataprep/multimodal/redis/langchain/Dockerfile . + docker build --no-cache -t opea/dataprep-multimodal-redis:comps --build-arg https_proxy=$https_proxy --build-arg http_proxy=$http_proxy -f comps/dataprep/multimodal/redis/langchain/Dockerfile . if [ $? -ne 0 ]; then echo "opea/dataprep-multimodal-redis built fail" @@ -32,14 +33,14 @@ function build_docker_images() { function build_lvm_docker_images() { cd $WORKPATH echo $(pwd) - docker build --no-cache -t opea/lvm-llava:comps --build-arg https_proxy=$https_proxy --build-arg http_proxy=$http_proxy --build-arg no_proxy=$no_proxy -f comps/lvms/llava/dependency/Dockerfile . + docker build --no-cache -t opea/lvm-llava:comps -f comps/lvms/llava/dependency/Dockerfile . if [ $? -ne 0 ]; then echo "opea/lvm-llava built fail" exit 1 else echo "opea/lvm-llava built successful" fi - docker build --no-cache -t opea/lvm-llava-svc:comps --build-arg https_proxy=$https_proxy --build-arg http_proxy=$http_proxy --build-arg no_proxy=$no_proxy -f comps/lvms/llava/Dockerfile . + docker build --no-cache -t opea/lvm-llava-svc:comps -f comps/lvms/llava/Dockerfile . if [ $? -ne 0 ]; then echo "opea/lvm-llava-svc built fail" exit 1 @@ -49,9 +50,9 @@ function build_lvm_docker_images() { } function start_lvm_service() { - # unset http_proxy - docker run -d --name="test-comps-lvm-llava" -e http_proxy=$http_proxy -e https_proxy=$https_proxy -e no_proxy=$no_proxy -p 5029:8399 --ipc=host opea/lvm-llava:comps - docker run -d --name="test-comps-lvm-llava-svc" -e LVM_ENDPOINT=http://$ip_address:5029 -e http_proxy=$http_proxy -e https_proxy=$https_proxy -e no_proxy=$no_proxy -p ${LVM_PORT}:9399 --ipc=host opea/lvm-llava-svc:comps + unset http_proxy + docker run -d --name="test-comps-lvm-llava" -e http_proxy=$http_proxy -e https_proxy=$https_proxy -p 5029:8399 --ipc=host opea/lvm-llava:comps + docker run -d --name="test-comps-lvm-llava-svc" -e LVM_ENDPOINT=http://$ip_address:5029 -e http_proxy=$http_proxy -e https_proxy=$https_proxy -p ${LVM_PORT}:9399 --ipc=host opea/lvm-llava-svc:comps sleep 5m } @@ -69,13 +70,13 @@ function start_service() { # start redis echo "Starting Redis server" REDIS_PORT=6380 - docker run -d --name="test-redis" -e http_proxy=$http_proxy -e https_proxy=$https_proxy -e no_proxy=$no_proxy -p $REDIS_PORT:6379 -p 8002:8001 --ipc=host redis/redis-stack:7.2.0-v9 + docker run -d --name="test-redis" -e http_proxy=$http_proxy -e https_proxy=$https_proxy -p $REDIS_PORT:6379 -p 8002:8001 --ipc=host redis/redis-stack:7.2.0-v9 # start dataprep microservice echo "Starting dataprep microservice" dataprep_service_port=5013 REDIS_URL="redis://${ip_address}:${REDIS_PORT}" - docker run -d --name="test-comps-dataprep-multimodal-redis" -e http_proxy=$http_proxy -e https_proxy=$https_proxy -e no_proxy=$no_proxy -e REDIS_URL=$REDIS_URL -e REDIS_HOST=$ip_address -e INDEX_NAME=$INDEX_NAME -e LVM_ENDPOINT=$LVM_ENDPOINT -p ${dataprep_service_port}:6007 --runtime=runc --ipc=host opea/dataprep-multimodal-redis:comps + docker run -d --name="test-comps-dataprep-multimodal-redis" -e http_proxy=$http_proxy -e https_proxy=$https_proxy -e REDIS_URL=$REDIS_URL -e INDEX_NAME=$INDEX_NAME -e LVM_ENDPOINT=$LVM_ENDPOINT -p ${dataprep_service_port}:6007 --runtime=runc --ipc=host opea/dataprep-multimodal-redis:comps sleep 1m } @@ -237,7 +238,7 @@ function validate_microservice() { else echo "[ $SERVICE_NAME ] HTTP status is 200. Checking content..." fi - if [[ "$RESPONSE_BODY" != *${video_name}* ]]; then + if [[ "$RESPONSE_BODY" != *${video_name}* ] || [ "$RESPONSE_BODY" != *${image_name}* ]]; then echo "[ $SERVICE_NAME ] Content does not match the expected result: $RESPONSE_BODY" docker logs test-comps-dataprep-multimodal-redis >> ${LOG_PATH}/dataprep_file.log exit 1 From f620193d7d335b19110357775ae657817324f812 Mon Sep 17 00:00:00 2001 From: Melanie Buehler Date: Thu, 24 Oct 2024 09:23:57 -0700 Subject: [PATCH 6/6] Fixed test Signed-off-by: Melanie Buehler --- tests/dataprep/test_dataprep_multimodal_redis_langchain.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/dataprep/test_dataprep_multimodal_redis_langchain.sh b/tests/dataprep/test_dataprep_multimodal_redis_langchain.sh index c2ecc19d2a..1440191321 100644 --- a/tests/dataprep/test_dataprep_multimodal_redis_langchain.sh +++ b/tests/dataprep/test_dataprep_multimodal_redis_langchain.sh @@ -238,7 +238,7 @@ function validate_microservice() { else echo "[ $SERVICE_NAME ] HTTP status is 200. Checking content..." fi - if [[ "$RESPONSE_BODY" != *${video_name}* ] || [ "$RESPONSE_BODY" != *${image_name}* ]]; then + if [[ "$RESPONSE_BODY" != *${image_name}* || "$RESPONSE_BODY" != *${video_name}* ]]; then echo "[ $SERVICE_NAME ] Content does not match the expected result: $RESPONSE_BODY" docker logs test-comps-dataprep-multimodal-redis >> ${LOG_PATH}/dataprep_file.log exit 1