-
Notifications
You must be signed in to change notification settings - Fork 1
/
make-deployments-table.py
executable file
·67 lines (48 loc) · 2.09 KB
/
make-deployments-table.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
59
60
61
62
63
64
65
66
67
#!/usr/bin/env python3
from datetime import datetime
from textwrap import dedent
import yaml
MD_FILENAME = "DEPLOYMENTS.md"
def stringify_nodeselector(selector: dict[str, str]):
# separate with markdown linebreak
return " * ".join([f"{k}={v}" for k, v in selector.items()])
def get_deployments(filename):
# filename: yaml filename
with open(filename) as f:
values = yaml.safe_load(f)
deployments = values["deployments"]
return {depl["name"]: stringify_nodeselector(depl["nodeSelector"]) for depl in deployments}
def main():
gcp_deployments = get_deployments(filename="chart/values.yaml")
az_deployments = get_deployments(filename="chart/values-azure.yaml")
md_table = [
["Model ID", "GCP", "Azure", "Node Selector (GCP)", "Node Selector (Azure)"],
]
deployment_info = {}
for model_id in gcp_deployments | az_deployments:
deployment_info.setdefault(
model_id,
{"GCP": "❌", "Azure": "❌", "Node Selector (GCP)": "", "Node Selector (Azure)": ""},
)
if info := az_deployments.get(model_id):
deployment_info[model_id]["Azure"] = "✅"
deployment_info[model_id]["Node Selector (Azure)"] = info
if info := gcp_deployments.get(model_id):
deployment_info[model_id]["GCP"] = "✅"
deployment_info[model_id]["Node Selector (GCP)"] = info
for model_id, info in deployment_info.items():
md_table.append([model_id, info["GCP"], info["Azure"], info["Node Selector (GCP)"], info["Node Selector (Azure)"]])
with open(MD_FILENAME, "w") as f:
f.write(dedent(f"""\
# Deployments Table
Generated by {__file__.rsplit("/", maxsplit=1)[-1]} on {datetime.now().strftime("%Y-%m-%d %H:%M:%S")}.
"""))
header = "| " + " | ".join(md_table[0]) + " |\n"
f.write(header)
sep = "| " + " | ".join(["---"] * len(md_table[0])) + " |\n"
f.write(sep)
for row in md_table[1:]:
f.write("| " + " | ".join(row) + " |\n")
print("Wrote", MD_FILENAME)
if __name__ == "__main__":
main()