make cluster creation/deletion async by default (#16185)
This commit is contained in:
parent
5de93975c6
commit
8d1d592295
|
@ -109,7 +109,7 @@ class AWSClusterManager:
|
|||
region: str = "us-east-1",
|
||||
external_id: str = None,
|
||||
edit_before_creation: bool = False,
|
||||
do_async: bool = False,
|
||||
do_async: bool = True,
|
||||
) -> None:
|
||||
"""request Lightning AI BYOC compute cluster creation.
|
||||
|
||||
|
@ -192,7 +192,7 @@ class AWSClusterManager:
|
|||
console = Console()
|
||||
console.print(clusters.as_table())
|
||||
|
||||
def delete(self, cluster_id: str, force: bool = False, do_async: bool = False) -> None:
|
||||
def delete(self, cluster_id: str, force: bool = False, do_async: bool = True) -> None:
|
||||
if force:
|
||||
click.echo(
|
||||
"""
|
||||
|
|
|
@ -50,13 +50,13 @@ def create() -> None:
|
|||
help="Edit the cluster specs before submitting them to the API server.",
|
||||
)
|
||||
@click.option(
|
||||
"--async",
|
||||
"do_async",
|
||||
"--sync",
|
||||
"do_sync",
|
||||
type=bool,
|
||||
required=False,
|
||||
default=False,
|
||||
is_flag=True,
|
||||
help="This flag makes the CLI return immediately and lets the cluster creation happen in the background.",
|
||||
help="This flag makes the CLI wait until cluster creation completes.",
|
||||
)
|
||||
def create_cluster(
|
||||
cluster_id: str,
|
||||
|
@ -66,7 +66,7 @@ def create_cluster(
|
|||
provider: str,
|
||||
edit_before_creation: bool,
|
||||
enable_performance: bool,
|
||||
do_async: bool,
|
||||
do_sync: bool,
|
||||
**kwargs: Any,
|
||||
) -> None:
|
||||
"""Create a Lightning AI BYOC compute cluster with your cloud provider credentials."""
|
||||
|
@ -81,7 +81,7 @@ def create_cluster(
|
|||
external_id=external_id,
|
||||
edit_before_creation=edit_before_creation,
|
||||
cost_savings=not enable_performance,
|
||||
do_async=do_async,
|
||||
do_async=not do_sync,
|
||||
)
|
||||
|
||||
|
||||
|
|
|
@ -20,15 +20,15 @@ def delete() -> None:
|
|||
@delete.command("cluster")
|
||||
@click.argument("cluster", type=str)
|
||||
@click.option(
|
||||
"--async",
|
||||
"do_async",
|
||||
"--sync",
|
||||
"do_sync",
|
||||
type=bool,
|
||||
required=False,
|
||||
default=False,
|
||||
is_flag=True,
|
||||
help="This flag makes the CLI return immediately and lets the cluster deletion happen in the background",
|
||||
help="This flag makes the CLI wait until cluster deletion completes.",
|
||||
)
|
||||
def delete_cluster(cluster: str, force: bool = False, do_async: bool = False) -> None:
|
||||
def delete_cluster(cluster: str, force: bool = False, do_sync: bool = False) -> None:
|
||||
"""Delete a Lightning AI BYOC cluster and all associated cloud provider resources.
|
||||
|
||||
Deleting a cluster also deletes all apps that were started on the cluster.
|
||||
|
@ -44,7 +44,7 @@ def delete_cluster(cluster: str, force: bool = False, do_async: bool = False) ->
|
|||
VPC components, etc. are irreversibly deleted and cannot be recovered!
|
||||
"""
|
||||
cluster_manager = AWSClusterManager()
|
||||
cluster_manager.delete(cluster_id=cluster, force=force, do_async=do_async)
|
||||
cluster_manager.delete(cluster_id=cluster, force=force, do_async=not do_sync)
|
||||
|
||||
|
||||
def _find_cluster_for_user(app_name: str, cluster_id: Optional[str]) -> str:
|
||||
|
|
|
@ -88,6 +88,7 @@ def test_create_cluster(create_command: mock.MagicMock):
|
|||
"dummy",
|
||||
"--role-arn",
|
||||
"arn:aws:iam::1234567890:role/lai-byoc",
|
||||
"--sync",
|
||||
],
|
||||
)
|
||||
|
||||
|
@ -124,7 +125,7 @@ def test_list_clusters(list_command: mock.MagicMock):
|
|||
@mock.patch("lightning_app.cli.cmd_clusters.AWSClusterManager.delete")
|
||||
def test_delete_cluster(delete: mock.MagicMock):
|
||||
runner = CliRunner()
|
||||
runner.invoke(delete_cluster, ["test-7"])
|
||||
runner.invoke(delete_cluster, ["test-7", "--sync"])
|
||||
|
||||
delete.assert_called_once_with(cluster_id="test-7", force=False, do_async=False)
|
||||
|
||||
|
|
Loading…
Reference in New Issue