diff --git a/src/dmaa/constants.py b/src/dmaa/constants.py index 31fc3319..35208dd8 100644 --- a/src/dmaa/constants.py +++ b/src/dmaa/constants.py @@ -21,4 +21,6 @@ DMAA_DEFAULT_PROFILE_PARH = "~/.dmaa_default_profile" MODEL_TAG_PATTERN = r'^[a-z0-9]([a-z0-9-_]{0,61}[a-z0-9])?$' + +LOCAL_REGION = "local" # DMAA_USE_NO_PROFILE_CHOICE = "Don't set" diff --git a/src/dmaa/models/llms/deepseek.py b/src/dmaa/models/llms/deepseek.py index 784c33a4..047c8fb4 100644 --- a/src/dmaa/models/llms/deepseek.py +++ b/src/dmaa/models/llms/deepseek.py @@ -53,7 +53,7 @@ supported_frameworks=[ fastapi_framework ], - allow_china_region=False, + allow_china_region=True, huggingface_model_id="deepseek-ai/DeepSeek-R1-Distill-Qwen-32B", # modelscope_model_id="Qwen/Qwen2.5-32B-Instruct", require_huggingface_token=False, @@ -83,7 +83,7 @@ supported_frameworks=[ fastapi_framework ], - allow_china_region=False, + allow_china_region=True, huggingface_model_id="deepseek-ai/DeepSeek-R1-Distill-Qwen-14B", # modelscope_model_id="Qwen/Qwen2.5-14B-Instruct", require_huggingface_token=False, @@ -114,7 +114,7 @@ supported_frameworks=[ fastapi_framework ], - allow_china_region=False, + allow_china_region=True, huggingface_model_id="deepseek-ai/DeepSeek-R1-Distill-Qwen-7B", # modelscope_model_id="Qwen/Qwen2.5-14B-Instruct", require_huggingface_token=False, @@ -145,7 +145,7 @@ supported_frameworks=[ fastapi_framework ], - allow_china_region=False, + allow_china_region=True, huggingface_model_id="deepseek-ai/DeepSeek-R1-Distill-Qwen-1.5B", # modelscope_model_id="Qwen/Qwen2.5-14B-Instruct", require_huggingface_token=False, @@ -242,7 +242,7 @@ supported_frameworks=[ fastapi_framework ], - allow_china_region=False, + allow_china_region=True, huggingface_model_id="deepseek-ai/DeepSeek-R1-Distill-Llama-8B", # modelscope_model_id="Qwen/Qwen2.5-14B-Instruct", require_huggingface_token=False, diff --git a/src/dmaa/sdk/deploy.py b/src/dmaa/sdk/deploy.py index 2c446378..a38bd0a2 100644 --- a/src/dmaa/sdk/deploy.py +++ b/src/dmaa/sdk/deploy.py @@ -11,6 +11,7 @@ ENV_STACK_NAME, MODEL_DEFAULT_TAG, VERSION, + LOCAL_REGION ) from dmaa.models import Model from dmaa.models.utils.constants import FrameworkType, ServiceType,InstanceType @@ -311,7 +312,7 @@ def deploy_local( f" --service_type {service_type}" f" --backend_type {engine_type}" f" --framework_type {framework_type}" - f" --region 'local'" + f" --region '{LOCAL_REGION}'" f" --extra_params '{extra_params}'" ) logger.info(f"pipeline cmd: {pipeline_cmd}") diff --git a/src/pipeline/deploy/build_and_push_image.py b/src/pipeline/deploy/build_and_push_image.py index 0df89969..cf3f24a8 100644 --- a/src/pipeline/deploy/build_and_push_image.py +++ b/src/pipeline/deploy/build_and_push_image.py @@ -236,17 +236,34 @@ def run( docker_login_region = docker_login_region or region if build_image_host: - if check_cn_region(region): - build_image_script = ( + build_image_script_cn = ( f"cd {execute_dir}" f' && docker build --platform linux/amd64 -f {dockerfile_name} -t "{ecr_repo_uri}" .' ) - else: - build_image_script = ( + build_image_script_global = ( f"cd {execute_dir}" f" && aws {ecr_name} get-login-password --region {docker_login_region} | docker login --username AWS --password-stdin {build_image_host}" f' && docker build --platform linux/amd64 -f {dockerfile_name} -t "{ecr_repo_uri}" .' ) + if check_cn_region(region): + build_image_scripts = [build_image_script_cn] + else: + build_image_scripts = [build_image_script_global,build_image_script_cn] + + is_build_success = False + for build_image_script in build_image_scripts: + logger.info(f"building image: {build_image_script}") + try: + assert os.system(build_image_script) == 0 + is_build_success = True + break + except Exception as e: + logger.error(f"docker build errorr: {e}") + + if not is_build_success: + raise RuntimeError("docker build errorr") + + # build_image_script = ( # f"cd {execute_dir}" # f" && aws {ecr_name} get-login-password --region {docker_login_region} | docker login --username AWS --password-stdin {build_image_host}" @@ -258,8 +275,8 @@ def run( f' && docker build --platform linux/amd64 -f {dockerfile_name} -t "{ecr_repo_uri}" .' ) - logger.info(f"building image: {build_image_script}") - assert os.system(build_image_script) == 0 + logger.info(f"building image: {build_image_script}") + assert os.system(build_image_script) == 0 # push image # It should not push the image to ecr when service_type is `local` diff --git a/src/pipeline/pipeline.py b/src/pipeline/pipeline.py index 0735071e..9c227cb6 100644 --- a/src/pipeline/pipeline.py +++ b/src/pipeline/pipeline.py @@ -7,7 +7,7 @@ import logging from concurrent.futures import as_completed,ProcessPoolExecutor from dmaa.models import Model -from dmaa.constants import MODEL_DEFAULT_TAG +from dmaa.constants import MODEL_DEFAULT_TAG,LOCAL_REGION from dmaa.models.utils.constants import FrameworkType,ServiceType,InstanceType from utils.common import str2bool from dmaa.utils.aws_service_utils import check_cn_region @@ -217,7 +217,7 @@ def download_s5cmd(): t0 = time.time() start_time = time.time() args = parse_args() - if not check_cn_region(args.region): + if not (check_cn_region(args.region) or args.region == LOCAL_REGION): download_s5cmd() extra_params = args.extra_params for k,v in extra_params.items():