Skip to content

Commit 71b7eee

Browse files
authored
Fix: bugs on local deployment (#7)
* fix cn region local deploy bug * fix bugs in download_s5cmd
1 parent 3e5f9fc commit 71b7eee

File tree

5 files changed

+34
-14
lines changed

5 files changed

+34
-14
lines changed

src/dmaa/constants.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,6 @@
2121
DMAA_DEFAULT_PROFILE_PARH = "~/.dmaa_default_profile"
2222

2323
MODEL_TAG_PATTERN = r'^[a-z0-9]([a-z0-9-_]{0,61}[a-z0-9])?$'
24+
25+
LOCAL_REGION = "local"
2426
# DMAA_USE_NO_PROFILE_CHOICE = "Don't set"

src/dmaa/models/llms/deepseek.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
supported_frameworks=[
5454
fastapi_framework
5555
],
56-
allow_china_region=False,
56+
allow_china_region=True,
5757
huggingface_model_id="deepseek-ai/DeepSeek-R1-Distill-Qwen-32B",
5858
# modelscope_model_id="Qwen/Qwen2.5-32B-Instruct",
5959
require_huggingface_token=False,
@@ -83,7 +83,7 @@
8383
supported_frameworks=[
8484
fastapi_framework
8585
],
86-
allow_china_region=False,
86+
allow_china_region=True,
8787
huggingface_model_id="deepseek-ai/DeepSeek-R1-Distill-Qwen-14B",
8888
# modelscope_model_id="Qwen/Qwen2.5-14B-Instruct",
8989
require_huggingface_token=False,
@@ -114,7 +114,7 @@
114114
supported_frameworks=[
115115
fastapi_framework
116116
],
117-
allow_china_region=False,
117+
allow_china_region=True,
118118
huggingface_model_id="deepseek-ai/DeepSeek-R1-Distill-Qwen-7B",
119119
# modelscope_model_id="Qwen/Qwen2.5-14B-Instruct",
120120
require_huggingface_token=False,
@@ -145,7 +145,7 @@
145145
supported_frameworks=[
146146
fastapi_framework
147147
],
148-
allow_china_region=False,
148+
allow_china_region=True,
149149
huggingface_model_id="deepseek-ai/DeepSeek-R1-Distill-Qwen-1.5B",
150150
# modelscope_model_id="Qwen/Qwen2.5-14B-Instruct",
151151
require_huggingface_token=False,
@@ -242,7 +242,7 @@
242242
supported_frameworks=[
243243
fastapi_framework
244244
],
245-
allow_china_region=False,
245+
allow_china_region=True,
246246
huggingface_model_id="deepseek-ai/DeepSeek-R1-Distill-Llama-8B",
247247
# modelscope_model_id="Qwen/Qwen2.5-14B-Instruct",
248248
require_huggingface_token=False,

src/dmaa/sdk/deploy.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
ENV_STACK_NAME,
1212
MODEL_DEFAULT_TAG,
1313
VERSION,
14+
LOCAL_REGION
1415
)
1516
from dmaa.models import Model
1617
from dmaa.models.utils.constants import FrameworkType, ServiceType,InstanceType
@@ -311,7 +312,7 @@ def deploy_local(
311312
f" --service_type {service_type}"
312313
f" --backend_type {engine_type}"
313314
f" --framework_type {framework_type}"
314-
f" --region 'local'"
315+
f" --region '{LOCAL_REGION}'"
315316
f" --extra_params '{extra_params}'"
316317
)
317318
logger.info(f"pipeline cmd: {pipeline_cmd}")

src/pipeline/deploy/build_and_push_image.py

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -236,17 +236,34 @@ def run(
236236
docker_login_region = docker_login_region or region
237237

238238
if build_image_host:
239-
if check_cn_region(region):
240-
build_image_script = (
239+
build_image_script_cn = (
241240
f"cd {execute_dir}"
242241
f' && docker build --platform linux/amd64 -f {dockerfile_name} -t "{ecr_repo_uri}" .'
243242
)
244-
else:
245-
build_image_script = (
243+
build_image_script_global = (
246244
f"cd {execute_dir}"
247245
f" && aws {ecr_name} get-login-password --region {docker_login_region} | docker login --username AWS --password-stdin {build_image_host}"
248246
f' && docker build --platform linux/amd64 -f {dockerfile_name} -t "{ecr_repo_uri}" .'
249247
)
248+
if check_cn_region(region):
249+
build_image_scripts = [build_image_script_cn]
250+
else:
251+
build_image_scripts = [build_image_script_global,build_image_script_cn]
252+
253+
is_build_success = False
254+
for build_image_script in build_image_scripts:
255+
logger.info(f"building image: {build_image_script}")
256+
try:
257+
assert os.system(build_image_script) == 0
258+
is_build_success = True
259+
break
260+
except Exception as e:
261+
logger.error(f"docker build errorr: {e}")
262+
263+
if not is_build_success:
264+
raise RuntimeError("docker build errorr")
265+
266+
250267
# build_image_script = (
251268
# f"cd {execute_dir}"
252269
# 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(
258275
f' && docker build --platform linux/amd64 -f {dockerfile_name} -t "{ecr_repo_uri}" .'
259276
)
260277

261-
logger.info(f"building image: {build_image_script}")
262-
assert os.system(build_image_script) == 0
278+
logger.info(f"building image: {build_image_script}")
279+
assert os.system(build_image_script) == 0
263280

264281
# push image
265282
# It should not push the image to ecr when service_type is `local`

src/pipeline/pipeline.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import logging
88
from concurrent.futures import as_completed,ProcessPoolExecutor
99
from dmaa.models import Model
10-
from dmaa.constants import MODEL_DEFAULT_TAG
10+
from dmaa.constants import MODEL_DEFAULT_TAG,LOCAL_REGION
1111
from dmaa.models.utils.constants import FrameworkType,ServiceType,InstanceType
1212
from utils.common import str2bool
1313
from dmaa.utils.aws_service_utils import check_cn_region
@@ -217,7 +217,7 @@ def download_s5cmd():
217217
t0 = time.time()
218218
start_time = time.time()
219219
args = parse_args()
220-
if not check_cn_region(args.region):
220+
if not (check_cn_region(args.region) or args.region == LOCAL_REGION):
221221
download_s5cmd()
222222
extra_params = args.extra_params
223223
for k,v in extra_params.items():

0 commit comments

Comments
 (0)