Skip to content
This repository was archived by the owner on Sep 20, 2025. It is now read-only.

Commit dd601c0

Browse files
committed
refactor: smart bootstrap
1 parent 5bc7a6a commit dd601c0

19 files changed

+189
-39
lines changed

src/emd/cli.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
app.add_typer(
2424
bootstrap.app,
2525
name="bootstrap",
26-
help="Initialize AWS resources for model deployment",
26+
help="[Optional] Manually initialize AWS resources (auto-handled by deploy)",
2727
)
2828
app.add_typer(
2929
deploy.app,

src/emd/commands/bootstrap.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from emd.constants import ENV_STACK_NAME,ENV_BUCKET_NAME_PREFIX
55
from typing_extensions import Annotated
66
from emd.sdk.bootstrap import create_env_stack,get_bucket_name
7-
from emd.utils.decorators import catch_aws_credential_errors, load_aws_profile
7+
from emd.utils.decorators import catch_aws_credential_errors, load_aws_profile, show_update_notification
88
from emd.utils.logger_utils import make_layout
99
from emd.utils.aws_service_utils import get_current_region
1010

@@ -15,17 +15,25 @@
1515
layout = make_layout()
1616

1717
@app.callback(invoke_without_command=True)
18+
@show_update_notification
1819
@catch_aws_credential_errors
1920
@load_aws_profile
2021
def bootstrap(
2122
skip_confirm: Annotated[
2223
Optional[bool], typer.Option("--skip-confirm", help="Skip confirmation")
2324
] = False,
2425
):
26+
"""
27+
Manually initialize AWS resources for model deployment.
28+
29+
Note: This command is optional. Running 'emd deploy' will automatically
30+
set up infrastructure when needed.
31+
"""
32+
console.print("[dim]ℹ️ Note: 'emd deploy' now automatically sets up infrastructure when needed.[/dim]")
33+
console.print()
2534

2635
region = get_current_region()
27-
typer.echo("AWS environment is properly configured.")
28-
layout["main"].update("[bold red]Initalizing environment...[/bold red]")
36+
layout["main"].update("[bold red]Initializing environment...[/bold red]")
2937
try:
3038
bucket_name = get_bucket_name(
3139
bucket_prefix=ENV_BUCKET_NAME_PREFIX,

src/emd/commands/config.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from rich.console import Console
33
import boto3
44
from typing import Annotated
5-
from emd.utils.decorators import catch_aws_credential_errors
5+
from emd.utils.decorators import catch_aws_credential_errors, show_update_notification
66

77
from emd.patch_questionary.select_with_help import select_with_help,Choice
88
from emd.utils.profile_manager import profile_manager
@@ -17,6 +17,7 @@
1717

1818

1919
@app.command(help="Set the default profile name for deployment")
20+
@show_update_notification
2021
@catch_aws_credential_errors
2122
def set_default_profile_name(
2223
name: Annotated[
@@ -57,6 +58,7 @@ def set_default_profile_name(
5758

5859

5960
@app.command(help="Show current default profile")
61+
@show_update_notification
6062
@catch_aws_credential_errors
6163
def show_default_profile_name():
6264
name = profile_manager.load_profile_name_from_local()
@@ -67,6 +69,7 @@ def show_default_profile_name():
6769

6870

6971
@app.command(help="Remove the default profile")
72+
@show_update_notification
7073
@catch_aws_credential_errors
7174
def remove_default_profile_name():
7275
name = profile_manager.remove_profile_name_from_local()

src/emd/commands/deploy.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@
2525
from emd.utils.aws_service_utils import check_cn_region
2626
import questionary
2727
from emd.utils.accelerator_utils import get_gpu_num,check_cuda_exists,check_neuron_exists
28-
from emd.utils.decorators import catch_aws_credential_errors,check_emd_env_exist,load_aws_profile
28+
from emd.utils.decorators import catch_aws_credential_errors,check_emd_env_exist,load_aws_profile,show_update_notification
29+
from emd.utils.smart_bootstrap import smart_bootstrap_manager
2930
from emd.utils.logger_utils import make_layout
3031
from emd.utils.exceptions import ModelNotSupported,ServiceNotSupported,InstanceNotSupported
3132
from prompt_toolkit import prompt
@@ -203,6 +204,7 @@ def get_prompt_message():
203204

204205
#@app.callback(invoke_without_command=True)(invoke_without_command=True)
205206
@app.callback(invoke_without_command=True)
207+
@show_update_notification
206208
@catch_aws_credential_errors
207209
@check_emd_env_exist
208210
@load_aws_profile
@@ -245,13 +247,20 @@ def deploy(
245247
local_gpus:Annotated[
246248
str, typer.Option("--local-gpus", help="Local gpu ids to deploy the model (e.g. `0,1,2`), only working with local deployment mode.")
247249
] = None,
250+
disable_auto_bootstrap: Annotated[
251+
Optional[bool], typer.Option("--disable-auto-bootstrap", help="Disable automatic bootstrap when infrastructure version mismatch is detected")
252+
] = False,
248253
):
249254
if only_allow_local_deploy:
250255
allow_local_deploy = True
251256
region = LOCAL_REGION
252257
else:
253258
region = get_current_region()
254259

260+
# SMART BOOTSTRAP CHECK - Auto bootstrap if infrastructure version mismatch
261+
if region != LOCAL_REGION and not disable_auto_bootstrap: # Skip for local deployments or if disabled
262+
smart_bootstrap_manager.auto_bootstrap_if_needed(region)
263+
255264
if dockerfile_local_path:
256265
response = sdk_deploy(
257266
model_id='custom-docker',

src/emd/commands/destroy.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from emd.constants import MODEL_DEFAULT_TAG
66
from typing_extensions import Annotated
77
from emd.sdk.destroy import destroy as sdk_destroy
8-
from emd.utils.decorators import catch_aws_credential_errors,check_emd_env_exist,load_aws_profile
8+
from emd.utils.decorators import catch_aws_credential_errors,check_emd_env_exist,load_aws_profile,show_update_notification
99
from emd.utils.logger_utils import make_layout
1010
from emd.revision import convert_version_name_to_stack_name
1111

@@ -16,6 +16,7 @@
1616

1717
#@app.callback(invoke_without_command=True)(invoke_without_command=True)
1818
@app.callback(invoke_without_command=True)
19+
@show_update_notification
1920
@catch_aws_credential_errors
2021
@check_emd_env_exist
2122
@load_aws_profile

src/emd/commands/invoke/invoke.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from emd.models import Model
99
from emd.models.utils.constants import ModelType
1010
from emd.utils.logger_utils import make_layout
11-
from emd.utils.decorators import catch_aws_credential_errors,check_emd_env_exist,load_aws_profile
11+
from emd.utils.decorators import catch_aws_credential_errors,check_emd_env_exist,load_aws_profile,show_update_notification
1212

1313
app = typer.Typer(pretty_exceptions_enable=False)
1414
console = Console()
@@ -121,6 +121,7 @@ def vlm_invoke(model_id,model_tag):
121121

122122

123123
@app.callback(invoke_without_command=True)
124+
@show_update_notification
124125
@catch_aws_credential_errors
125126
@check_emd_env_exist
126127
@load_aws_profile

src/emd/commands/models.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,15 @@
33

44
import typer
55
from emd.models import Model
6-
from emd.utils.decorators import catch_aws_credential_errors
6+
from emd.utils.decorators import catch_aws_credential_errors, show_update_notification
77
from rich.console import Console
88
from typing_extensions import Annotated
99

1010
app = typer.Typer(pretty_exceptions_enable=False)
1111
console = Console()
1212

1313
@app.callback(invoke_without_command=True)
14+
@show_update_notification
1415
@catch_aws_credential_errors
1516
def list_supported_models(
1617
model_id: Annotated[

src/emd/commands/status.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from emd.constants import MODEL_DEFAULT_TAG
55
from emd.sdk.status import get_model_status
66
from emd.utils.aws_service_utils import get_account_id
7-
from emd.utils.decorators import catch_aws_credential_errors, check_emd_env_exist, load_aws_profile
7+
from emd.utils.decorators import catch_aws_credential_errors, check_emd_env_exist, load_aws_profile, show_update_notification
88
from emd.utils.logger_utils import make_layout
99
from rich.console import Console
1010
from rich.table import Table
@@ -15,6 +15,7 @@
1515

1616

1717
@app.callback(invoke_without_command=True)
18+
@show_update_notification
1819
@catch_aws_credential_errors
1920
@check_emd_env_exist
2021
@load_aws_profile

src/emd/commands/version.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
from emd.revision import VERSION, COMMIT_HASH
22
import typer
33
from emd.utils.logger_utils import make_layout
4+
from emd.utils.decorators import show_update_notification
45

56
app = typer.Typer(pretty_exceptions_enable=False)
67
layout = make_layout()
78

89

910
#@app.callback(invoke_without_command=True)(invoke_without_command=True)
1011
@app.callback(invoke_without_command=True)
12+
@show_update_notification
1113
def version():
1214
print(f"emd {VERSION} (build {COMMIT_HASH})")

src/emd/models/embeddings/bge_vl.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,7 @@
2727
local_instance,
2828
],
2929
supported_services=[
30-
sagemaker_service,
31-
ecs_service,
32-
local_service
30+
ecs_service
3331
],
3432
supported_frameworks=[
3533
fastapi_framework

0 commit comments

Comments
 (0)