-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathbundles.py
More file actions
72 lines (57 loc) · 2.01 KB
/
Copy pathbundles.py
File metadata and controls
72 lines (57 loc) · 2.01 KB
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import click
from rich.console import Console
from rich.syntax import Syntax
from rich.table import Column, Table
from nucleus.deploy.cli.client import init_client
@click.group("bundles")
def bundles():
"""Bundles is a wrapper around model bundles in Scale Launch"""
@bundles.command("list")
def list_bundles():
"""List all of your Bundles"""
client = init_client()
table = Table(
Column("Bundle Id", overflow="fold", min_width=24),
"Bundle name",
"Location",
"Packaging type",
title="Bundles",
title_justify="left",
)
for model_bundle in client.list_model_bundles():
table.add_row(
model_bundle.bundle_id,
model_bundle.bundle_name,
model_bundle.location,
model_bundle.packaging_type,
)
console = Console()
console.print(table)
@bundles.command("get")
@click.argument("bundle_name")
def get_bundle(bundle_name):
"""Print bundle info"""
client = init_client()
model_bundle = client.get_model_bundle(bundle_name)
console = Console()
console.print(f"bundle_id: {model_bundle.bundle_id}")
console.print(f"bundle_name: {model_bundle.bundle_name}")
console.print(f"location: {model_bundle.location}")
console.print(f"packaging_type: {model_bundle.packaging_type}")
console.print(f"env_params: {model_bundle.env_params}")
console.print(f"requirements: {model_bundle.requirements}")
console.print("metadata:")
for meta_name, meta_value in model_bundle.metadata.items():
# TODO print non-code metadata differently
console.print(f"{meta_name}:", style="yellow")
syntax = Syntax(meta_value, "python")
console.print(syntax)
@bundles.command("delete")
@click.argument("bundle_name")
def delete_bundle(bundle_name):
"""Delete a model bundle"""
client = init_client()
console = Console()
model_bundle = client.get_model_bundle(bundle_name)
res = client.delete_model_bundle(model_bundle)
console.print(res)