diff --git a/README.md b/README.md index a2c1d5f0..2a6899b5 100644 --- a/README.md +++ b/README.md @@ -130,7 +130,6 @@ Diagram below is the overall architecture of middleware, including API Gateway a ├── install.sh -- script to set the webui and extension to specific version ├── javascript -- javascript code for the extension ├── middleware_api -- middleware api denifition and lambda code -├── pre-flight.sh -- version compatibility check & install ├── sagemaker_entrypoint_json.py -- wrapper function for SageMaker ├── scripts -- extension related code for WebUI └── utils.py -- wrapper function for configure options diff --git a/build_scripts/inference/serve.sh b/build_scripts/inference/serve.sh index dcb4d000..6990dae0 100755 --- a/build_scripts/inference/serve.sh +++ b/build_scripts/inference/serve.sh @@ -345,11 +345,11 @@ if [ "$FULL_IMAGE" == "true" ]; then fi fi -endpoint_path="s3://$S3_BUCKET_NAME/$S3_LOCATION/$TAR_FILE" -echo "Checking $endpoint_path files..." -s5cmd ls "$endpoint_path" &> /dev/null -# shellcheck disable=SC2181 -if [ $? -eq 0 ]; then +S3_PATH="s3://$S3_BUCKET_NAME/$S3_LOCATION/$TAR_FILE" +echo "Checking $S3_PATH files..." +# shellcheck disable=SC2086 +output=$(s5cmd ls $S3_PATH 2>&1) +if [[ $? -eq 0 && ! -z "$output" ]]; then if [ "$SERVICE_TYPE" == "sd" ]; then sd_launch_from_s3 exit 1 diff --git a/commit-id.sh b/commit-id.sh index 4cd3fad3..ee76f3be 100755 --- a/commit-id.sh +++ b/commit-id.sh @@ -7,7 +7,7 @@ FIND_TEXT=("INITIAL_SUPPORT_COMMIT_ROOT=" "INITIAL_SUPPORT_COMMIT_CONTROLNET=" " REPLACE_TEXT=("INITIAL_SUPPORT_COMMIT_ROOT=$1" "INITIAL_SUPPORT_COMMIT_CONTROLNET=$2" "INITIAL_SUPPORT_COMMIT_DREAMBOOTH=$3" "INITIAL_SUPPORT_COMMIT_REMBG=$4" "INITIAL_SUPPORT_COMMIT_SAM=$5") # Array of files -FILES=("pre-flight.sh" "pre-flight.bat" "install.sh" "install.bat") +FILES=("install.sh" "install.bat") # helper function to hint the script usage function usage { @@ -35,4 +35,4 @@ do else echo "File $FILE does not exist." fi -done \ No newline at end of file +done diff --git a/infrastructure/package.json b/infrastructure/package.json index b8a656d5..406bb347 100644 --- a/infrastructure/package.json +++ b/infrastructure/package.json @@ -28,28 +28,28 @@ "@types/node": "^20.11.25", "@typescript-eslint/eslint-plugin": "^7.1.1", "@typescript-eslint/parser": "^7.1.1", - "esbuild": "^0.20.1", + "esbuild": "^0.20.2", "eslint": "^8.57.0", "eslint-import-resolver-node": "^0.3.9", "eslint-import-resolver-typescript": "^3.6.1", "eslint-plugin-import": "^2.29.1", "jest": "^29.7.0", "jest-junit": "^16.0.0", - "npm-check-updates": "^16.14.15", - "projen": "^0.80.9", + "npm-check-updates": "^16.14.18", + "projen": "^0.80.20", "ts-jest": "^29.1.2", "ts-node": "^10.9.2", "typescript": "^5.4.2" }, "dependencies": { - "@aws-cdk/aws-lambda-python-alpha": "^2.132.0-alpha.0", - "@aws-sdk/client-dynamodb": "^3.529.1", - "@aws-sdk/client-iam": "^3.529.1", - "@aws-sdk/client-kms": "^3.529.1", - "@aws-sdk/client-s3": "^3.529.1", - "@aws-sdk/client-sns": "^3.529.1", - "aws-cdk": "^2.135.0", - "aws-cdk-lib": "^2.135.0", + "@aws-cdk/aws-lambda-python-alpha": "2.132.0-alpha.0", + "@aws-sdk/client-dynamodb": "^3.554.0", + "@aws-sdk/client-iam": "^3.554.0", + "@aws-sdk/client-kms": "^3.554.0", + "@aws-sdk/client-s3": "^3.554.0", + "@aws-sdk/client-sns": "^3.554.0", + "aws-cdk": "^2.137.0", + "aws-cdk-lib": "^2.137.0", "cdk-bootstrapless-synthesizer": "^2.3.2", "constructs": "^10.3.0" }, diff --git a/pre-flight.bat b/pre-flight.bat deleted file mode 100644 index 22154fc7..00000000 --- a/pre-flight.bat +++ /dev/null @@ -1,130 +0,0 @@ -@echo off -SETLOCAL ENABLEDELAYEDEXPANSION - -set INITIAL_SUPPORT_COMMIT_ROOT=bda2ecdbf58fd33b4ad3036ed5cc13eef02747ae -set INITIAL_SUPPORT_COMMIT_CONTROLNET=efda6ddfd82ebafc6e1150fbb7e1f27163482a82 -set INITIAL_SUPPORT_COMMIT_DREAMBOOTH=c2a5617c587b812b5a408143ddfb18fc49234edf -set INITIAL_SUPPORT_COMMIT_REMBG=3d9eedbbf0d585207f97d5b21e42f32c0042df70 -set INITIAL_SUPPORT_COMMIT_SAM=5df716be8445e0f358f6e8d4b65a87cc611bfe08 -set INITIAL_SUPPORT_COMMIT_TILEDVAE=f9f8073e64f4e682838f255215039ba7884553bf - -set REPO_URL_LIST[0]="https://github.com/Mikubill/sd-webui-controlnet.git" -set REPO_URL_LIST[1]="https://github.com/d8ahazard/sd_dreambooth_extension.git" -set REPO_URL_LIST[2]="https://github.com/AUTOMATIC1111/stable-diffusion-webui-rembg.git" -set REPO_URL_LIST[3]="https://github.com/continue-revolution/sd-webui-segment-anything.git" -set REPO_URL_LIST[4]="https://github.com/pkuliyi2015/multidiffusion-upscaler-for-automatic1111.git" - -set REPO_FOLDER_LIST[0]="sd-webui-controlnet" -set REPO_FOLDER_LIST[1]="sd_dreambooth_extension" -set REPO_FOLDER_LIST[2]="stable-diffusion-webui-rembg" -set REPO_FOLDER_LIST[3]="sd-webui-segment-anything" -set REPO_FOLDER_LIST[4]="multidiffusion-upscaler-for-automatic1111" - - -call :parse_options %* -EXIT /B 0 - - -:show_help -echo Usage: %~nx0 -p/--pre-flight -s/--version-sync -goto :eof - - -:get_supported_commit_list -set repo_url=%1 -set initial_support_commit=%2 -set latest_commit=%3 -echo %initial_support_commit% %latest_commit% - -for /f "tokens=*" %%i in ('git rev-list --topo-order %initial_support_commit%^..%latest_commit%') do echo %%i -goto :eof - -:get_latest_commit_id -set repo_url=%1 -for /f "tokens=1" %%i in ('git ls-remote "%repo_url%" HEAD ^| findstr /b "[0-9a-f]"') do set latest_commit_id=%%i -echo latest commit: %latest_commit_id% -goto :eof - -:pre_flight_check -cd ../.. -echo Start pre-flight check for WebUI... -call :get_latest_commit_id "https://github.com/AUTOMATIC1111/stable-diffusion-webui.git" -set LATEST_ROOT_COMMIT=%latest_commit_id% -echo Supported commits for WebUI: -call :get_supported_commit_list "https://github.com/AUTOMATIC1111/stable-diffusion-webui.git" "%INITIAL_SUPPORT_COMMIT_ROOT%" "%LATEST_ROOT_COMMIT%" -@REM set SUPPORTED_ROOT_COMMITS=%supported_commit_list% -for /f "tokens=*" %%i in ('git rev-parse HEAD') do set CUR_ROOT_COMMIT=%%i -echo Current commit id for WebUI: %CUR_ROOT_COMMIT% - -echo Pre-flight checks complete. - -goto :eof - -:version_sync -echo Start version sync for WebUI, make sure the extension folder is empty... -cd ../../ -set extension_folder=%1 -if not exist %extension_folder%\ ( - echo The extension folder does not exist: %extension_folder% - echo Please create it and run the script again. - goto :eof -) - -echo Syncing WebUI... - -for %%n in (0, 1) do ( - set repo_folder=!REPO_FOLDER_LIST[%%n]! - set repo_url=!REPO_URL_LIST[%%n]! - echo repo_url !repo_url! - call :get_latest_commit_id !repo_url! - set latest_commit=!latest_commit_id! - - if not exist "%extension_folder%\!repo_folder!" ( - echo Cloning !repo_url! into !repo_folder!... - git clone !repo_url! "%extension_folder%\!repo_folder!" - cd "%extension_folder%\!repo_folder!" - git checkout !latest_commit! - cd %cd% - ) else ( - echo Updating !repo_folder! to the latest commit... - cd "%extension_folder%\!repo_folder!" - git fetch origin - git checkout !latest_commit! - cd %cd% - ) -) - -echo Version sync complete. - -goto :eof - -:parse_options -set options=%* -if not "%options%" == "" ( - for %%o in (%options%) do ( - if "%%o" == "-p" ( - call :pre_flight_check - exit /b - ) else if "%%o" == "--pre-flight" ( - call :pre_flight_check - exit /b - ) else if "%%o" == "-s" ( - call :version_sync "extensions" - exit /b - ) else if "%%o" == "--version-sync" ( - call :version_sync "extensions" - exit /b - ) else if "%%o" == "-h" ( - call :show_help - exit /b - ) else if "%%o" == "--help" ( - call :show_help - exit /b - ) else ( - echo Unknown option: %%o - ) - ) -) else ( - call :show_help -) -goto :eof \ No newline at end of file diff --git a/pre-flight.sh b/pre-flight.sh deleted file mode 100755 index 0f489d44..00000000 --- a/pre-flight.sh +++ /dev/null @@ -1,243 +0,0 @@ -#!/bin/bash - -# Usage: ./pre-flight_check.sh -p to do the pre-flight check for WebUI -s to auto sync the repo and plugin to compatible commit id - -INITIAL_SUPPORT_COMMIT_ROOT=bda2ecdbf58fd33b4ad3036ed5cc13eef02747ae -INITIAL_SUPPORT_COMMIT_CONTROLNET=e67e017731aad05796b9615dc6eadce911298ea1 -INITIAL_SUPPORT_COMMIT_DREAMBOOTH=c2a5617c587b812b5a408143ddfb18fc49234edf -INITIAL_SUPPORT_COMMIT_REMBG=3d9eedbbf0d585207f97d5b21e42f32c0042df70 -INITIAL_SUPPORT_COMMIT_SAM=c555c6d9c4e1d14b018e4d2a92acd47765536585 -INITIAL_SUPPORT_COMMIT_TILEDVAE=f9f8073e64f4e682838f255215039ba7884553bf - -# built the initial support commit list from option or default value if not provided -INITIAL_SUPPORT_COMMIT_LIST=( - "${initial_support_commit_controlnet:-7c674f83}" - "${initial_support_commit_dreambooth:-926ae204}" -) - -# Fixed repo URLs list -REPO_URL_LIST=( - "https://github.com/Mikubill/sd-webui-controlnet.git" - "https://github.com/d8ahazard/sd_dreambooth_extension.git" - "https://github.com/AUTOMATIC1111/stable-diffusion-webui-rembg.git" - "https://github.com/continue-revolution/sd-webui-segment-anything.git" - "https://github.com/pkuliyi2015/multidiffusion-upscaler-for-automatic1111.git" -) - -REPO_FOLDER_LIST=( - "sd-webui-controlnet" - "sd_dreambooth_extension" - "stable-diffusion-webui-rembg" - "sd-webui-segment-anything" - "multidiffusion-upscaler-for-automatic1111" -) - -show_help() { - echo "Usage: $(basename "$0") [options] - -h/--help: to show this help;\n - -p/--pre-flight: to check version compatibility;\n - -s/--version-sync: to sync the repo and plugin to compatible commit id;\n - -f/--force: to force skip the folder check when sync the version"; -} - -# Function to get supported commit list -get_supported_commit_list() { - repo_url="$1" - initial_support_commit="$2" - latest_commit="$3" - # echo "the repo url is $repo_url and the initial support commit is $initial_support_commit and the latest commit is $latest_commit and current folder is $(pwd)" - # list all the commit ids start from the initial support commit to the latest commit - commit_ids=$(git rev-list --topo-order $initial_support_commit^..$latest_commit) - echo "$commit_ids" -} - - -# Function to get current commit id of existing repo -get_latest_commit_id() { - repo_url="$1" - git ls-remote "$repo_url" HEAD | cut -f1 -} - -pre_flight_check() { - echo -e "Start pre-flight check for WebUI..." - # check if root folder support - LATEST_ROOT_COMMIT=$(get_latest_commit_id "https://github.com/AUTOMATIC1111/stable-diffusion-webui.git") - # echo -e "Latest commit id for WebUI: \n$LATEST_ROOT_COMMIT" - SUPPORTED_ROOT_COMMITS=$(cd ../../ && get_supported_commit_list "https://github.com/AUTOMATIC1111/stable-diffusion-webui.git" "$INITIAL_SUPPORT_COMMIT_ROOT" "$LATEST_ROOT_COMMIT") - # echo -e "Supported commit ids for WebUI: \n$SUPPORTED_ROOT_COMMITS" - - # get current commit id for repo - CUR_ROOT_COMMIT=$(cd ../../ && git rev-parse HEAD) - echo -e "Current commit id for WebUI: $CUR_ROOT_COMMIT" - if [ -n "$LATEST_ROOT_COMMIT" ]; then - if ! echo "$SUPPORTED_ROOT_COMMITS" | grep -q "$CUR_ROOT_COMMIT"; then - # warn with red color - echo "Warning: WebUI's latest commit is not in the minimum supported commit list." - echo -e "\033[31mPreflight check for WebUI is failed.\033[0m" - echo -e "===========================================================================" - echo - else - echo "WebUI's latest commit is in the minimum supported commit list." - echo -e "\033[34mPreflight check for WebUI is successful.\033[0m" - echo -e "===========================================================================" - echo - fi - fi - - # Get the parent directory of the script - SCRIPT_DIR=$(dirname "$(readlink -f "$0")") - PARENT_DIR=$(dirname "$SCRIPT_DIR") - - # Set the repo paths based on the parent directory - for repo_folder in "${REPO_FOLDER_LIST[@]}"; do - # set index to increment - index=$((index+1)) - # check if the repo folder exists - if [ -d "${PARENT_DIR}/${repo_folder}/.git" ]; then - echo -e "Repo ${repo_folder} exists in the parent directory of the script." - # cd to the repo folder - cd "${PARENT_DIR}/${repo_folder}" - # get the current commit id for the repo - LATEST_COMMIT=$(get_latest_commit_id "${REPO_URL_LIST[$index-1]}") - # echo -e "Latest commit id for Repo ${repo_folder}: \n$LATEST_COMMIT" - # use such index to set the repo url - SUPPORTED_COMMITS=$(get_supported_commit_list "${REPO_URL_LIST[$index-1]}" "${INITIAL_SUPPORT_COMMIT_LIST[$index-1]}" "$LATEST_COMMIT") - # echo -e "Supported commit ids for Repo ${repo_folder} are \n$SUPPORTED_COMMITS" - CUR_COMMIT=$(git rev-parse HEAD) - # check if the latest commit id is in the scope of the supported commit list, warn the user if not, and hint success if yes - if [ -n "$LATEST_COMMIT" ]; then - if ! echo "$SUPPORTED_COMMITS" | grep -q "$CUR_COMMIT"; then - # warn with red color - echo "Warning: Repo ${repo_folder}'s latest commit is not in the minimum supported commit list." - echo -e "\033[31mPreflight check for Repo ${repo_folder} is failed.\033[0m" - echo -e "===========================================================================" - echo - else - echo "Repo ${repo_folder}'s latest commit is in the minimum supported commit list." - echo -e "\033[34mPreflight check for Repo ${repo_folder} is successful.\033[0m" - echo -e "===========================================================================" - echo - fi - fi - # back to the parent directory - cd "$PARENT_DIR" - fi - done -} - -version_sync() { - echo -e "Start version sync for WebUI, make sure the extension folder is empty..." - - # check if the extension folder is empty and force option is not included - if [ "$(ls -A ../../extensions)" ] && [ "$1" != "-f" ] && [ "$1" != "--force" ]; then - echo "The extension folder is not empty, continue to sync the version will overwrite the existing files." - # confirm to proceed - read -p "Do you want to proceed? (y/n) " -n 1 -r - echo - if [[ ! $REPLY =~ ^[Yy]$ ]]; then - echo "Exiting..." - exit 1 - fi - fi - - cd ../../ - # Reset to specific commit - git checkout master - git pull - git reset --hard ${INITIAL_SUPPORT_COMMIT_ROOT} - - # Go to "extensions" directory - cd extensions - - # Clone stable-diffusion-aws-extension if not exist - if [ ! -d "stable-diffusion-aws-extension" ]; then - git clone https://github.com/awslabs/stable-diffusion-aws-extension.git - fi - # Checkout aigc branch - cd stable-diffusion-aws-extension - cd .. - - # Clone sd-webui-controlnet if not exist - if [ ! -d "sd-webui-controlnet" ]; then - git clone https://github.com/Mikubill/sd-webui-controlnet.git - fi - # Go to sd-webui-controlnet directory and reset to specific commit - cd sd-webui-controlnet - git checkout main - git pull - git reset --hard ${INITIAL_SUPPORT_COMMIT_CONTROLNET} - cd .. - - # Clone sd_dreambooth_extension if not exist - if [ ! -d "sd_dreambooth_extension" ]; then - git clone https://github.com/d8ahazard/sd_dreambooth_extension.git - fi - # Go to sd_dreambooth_extension directory and reset to specific commit - cd sd_dreambooth_extension - git checkout main - git pull - git reset --hard ${INITIAL_SUPPORT_COMMIT_DREAMBOOTH} - cd .. - - # Clone stable-diffusion-webui-rembg - git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui-rembg.git - - # Go to stable-diffusion-webui-rembg directory and reset to specific commit - cd stable-diffusion-webui-rembg - git reset --hard ${INITIAL_SUPPORT_COMMIT_REMBG} - cd .. - - # Clone sd-webui-segment-anything - git clone https://github.com/continue-revolution/sd-webui-segment-anything.git - - # Go to sd-webui-segment-anything directory and reset to specific commit - cd sd-webui-segment-anything - git reset --hard ${INITIAL_SUPPORT_COMMIT_SAM} - cd .. - - # Go to multidiffusion-upscaler-for-automatic1111 directory and reset to specific commit - cd multidiffusion-upscaler-for-automatic1111 - git reset --hard ${INITIAL_SUPPORT_COMMIT_TILEDVAE} - cd .. -} - -# Parse options with help of getopt -TEMP=$(getopt -o x:y:hpsf -l initial_support_commit_controlnet:,initial_support_commit_dreambooth:,help,pre-flight,version-sync,force -n "$(basename "$0")" -- "$@") -eval set -- "$TEMP" - -while true; do - case "$1" in - -x|--initial_support_commit_controlnet) - initial_support_commit_controlnet="$2" - shift 2 - ;; - -y|--initial_support_commit_dreambooth) - initial_support_commit_dreambooth="$2" - shift 2 - ;; - -p|--pre-flight) - pre_flight_check - exit - ;; - -s|--version-sync) - version_sync - exit - ;; - -f|--force) - version_sync -f - exit - ;; - -h|--help) - show_help - exit - ;; - --) - shift - break - ;; - *) - echo "Internal error!" - exit 1 - ;; - esac -done \ No newline at end of file diff --git a/test/test_13_local_only/test_01_mutli_gpus.py b/test/test_10_local_only/test_01_mutli_gpus.py similarity index 90% rename from test/test_13_local_only/test_01_mutli_gpus.py rename to test/test_10_local_only/test_01_mutli_gpus.py index f50ffbc1..71bdbf01 100644 --- a/test/test_13_local_only/test_01_mutli_gpus.py +++ b/test/test_10_local_only/test_01_mutli_gpus.py @@ -24,11 +24,8 @@ def task_to_run(inference_id): } api = Api(config) - resp = api.start_inference_job(job_id=inference_id, headers=headers) + api.start_inference_job(job_id=inference_id, headers=headers) logger.info(f"start_inference_job: {inference_id}") - # assert resp.status_code == 200, resp.dumps() - # assert 'img_presigned_urls' in resp.json()['data'], resp.dumps() - # assert len(resp.json()['data']['img_presigned_urls']) > 0, resp.dumps() @pytest.mark.skipif(not config.is_local, reason="local test only") diff --git a/test/test_10_api_clean/old_test_98_endpoint_cool_down.py b/test/test_11_api_clean/old_test_98_endpoint_cool_down.py similarity index 100% rename from test/test_10_api_clean/old_test_98_endpoint_cool_down.py rename to test/test_11_api_clean/old_test_98_endpoint_cool_down.py diff --git a/test/test_10_api_clean/test_01_clean_endpoint.py b/test/test_11_api_clean/test_01_clean_endpoint.py similarity index 100% rename from test/test_10_api_clean/test_01_clean_endpoint.py rename to test/test_11_api_clean/test_01_clean_endpoint.py diff --git a/test/test_10_api_clean/test_02_clean_dataset.py b/test/test_11_api_clean/test_02_clean_dataset.py similarity index 100% rename from test/test_10_api_clean/test_02_clean_dataset.py rename to test/test_11_api_clean/test_02_clean_dataset.py diff --git a/test/test_10_api_clean/test_03_clean_checkpoints.py b/test/test_11_api_clean/test_03_clean_checkpoints.py similarity index 100% rename from test/test_10_api_clean/test_03_clean_checkpoints.py rename to test/test_11_api_clean/test_03_clean_checkpoints.py diff --git a/test/test_10_api_clean/test_04_clean_roles.py b/test/test_11_api_clean/test_04_clean_roles.py similarity index 100% rename from test/test_10_api_clean/test_04_clean_roles.py rename to test/test_11_api_clean/test_04_clean_roles.py diff --git a/test/test_10_api_clean/test_05_clean_inferences.py b/test/test_11_api_clean/test_05_clean_inferences.py similarity index 100% rename from test/test_10_api_clean/test_05_clean_inferences.py rename to test/test_11_api_clean/test_05_clean_inferences.py diff --git a/test/test_10_api_clean/test_06_clean_trainings.py b/test/test_11_api_clean/test_06_clean_trainings.py similarity index 100% rename from test/test_10_api_clean/test_06_clean_trainings.py rename to test/test_11_api_clean/test_06_clean_trainings.py diff --git a/test/test_11_client_check/bak_test_02_comfy_client_check.py b/test/test_12_client_check/bak_test_02_comfy_client_check.py similarity index 100% rename from test/test_11_client_check/bak_test_02_comfy_client_check.py rename to test/test_12_client_check/bak_test_02_comfy_client_check.py diff --git a/test/test_11_client_check/test_01_webui_client_check.py b/test/test_12_client_check/test_01_webui_client_check.py similarity index 100% rename from test/test_11_client_check/test_01_webui_client_check.py rename to test/test_12_client_check/test_01_webui_client_check.py diff --git a/test/test_12_client_clean/test_01_webui_client_clean.py b/test/test_13_client_clean/test_01_webui_client_clean.py similarity index 100% rename from test/test_12_client_clean/test_01_webui_client_clean.py rename to test/test_13_client_clean/test_01_webui_client_clean.py diff --git a/test/test_12_client_clean/test_02_comfy_client_clean.py b/test/test_13_client_clean/test_02_comfy_client_clean.py similarity index 100% rename from test/test_12_client_clean/test_02_comfy_client_clean.py rename to test/test_13_client_clean/test_02_comfy_client_clean.py