-
Notifications
You must be signed in to change notification settings - Fork 3.3k
/
lightning_cli_delete.py
58 lines (47 loc) · 2.03 KB
/
lightning_cli_delete.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import click
from lightning_app.cli.cmd_clusters import AWSClusterManager
from lightning_app.cli.cmd_ssh_keys import _SSHKeyManager
@click.group("delete")
def delete() -> None:
"""Delete Lightning AI self-managed resources (clusters, etc…)"""
pass
@delete.command("cluster")
@click.argument("cluster", type=str)
@click.option(
"--force",
"force",
type=bool,
required=False,
default=False,
is_flag=True,
help="""Delete a BYOC cluster from Lightning AI. This does NOT delete any resources created by the cluster,
it just removes the entry from Lightning AI.
WARNING: You should NOT use this under normal circumstances.""",
)
@click.option(
"--wait",
"wait",
type=bool,
required=False,
default=False,
is_flag=True,
help="Enabling this flag makes the CLI wait until the cluster is deleted.",
)
def delete_cluster(cluster: str, force: bool = False, wait: bool = False) -> None:
"""Delete a Lightning AI BYOC compute cluster and all associated cloud provider resources.
Deleting a run also deletes all Runs and Experiments that were started on the cluster.
Deletion permanently removes not only the record of all runs on a cluster, but all associated experiments,
artifacts, metrics, logs, etc.
WARNING: This process may take a few minutes to complete, but once started it CANNOT be rolled back.
Deletion permanently removes not only the BYOC cluster from being managed by Lightning AI, but tears down
every BYOC resource Lightning AI managed (for that cluster id) in the host cloud.
All object stores, container registries, logs, compute nodes, volumes, etc. are deleted and cannot be recovered.
"""
cluster_manager = AWSClusterManager()
cluster_manager.delete(cluster_id=cluster, force=force, wait=wait)
@delete.command("ssh-key")
@click.argument("key_id")
def remove_ssh_key(key_id: str) -> None:
"""Delete a ssh-key from your Lightning AI account."""
ssh_key_manager = _SSHKeyManager()
ssh_key_manager.remove_key(key_id=key_id)