-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpython-client-recipe-index.py
More file actions
63 lines (46 loc) · 2.46 KB
/
python-client-recipe-index.py
File metadata and controls
63 lines (46 loc) · 2.46 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
from __future__ import annotations
import json
from pathlib import Path
REPO_ROOT = Path(__file__).resolve().parents[2]
def load_json(relative_path: str) -> dict:
return json.loads((REPO_ROOT / relative_path).read_text(encoding="utf-8"))
recipe_index = load_json("examples/client/recipe-index.json")
if recipe_index["directory"] != "examples/client":
raise ValueError("recipe-index directory drifted")
if len(recipe_index["groups"]) != 8:
raise ValueError("recipe-index group count drifted")
if len(recipe_index["task_entrypoints"]) != 18:
raise ValueError("recipe-index task count drifted")
python_group = next(group for group in recipe_index["groups"] if group["id"] == "python-consumers")
package_group = next(group for group in recipe_index["groups"] if group["id"] == "package-runtime")
source_group = next(group for group in recipe_index["groups"] if group["id"] == "source-level-types")
python_navigation_task = next(
entry for entry in recipe_index["task_entrypoints"] if entry["id"] == "python-recipe-navigation"
)
package_navigation_task = next(
entry for entry in recipe_index["task_entrypoints"] if entry["id"] == "package-recipe-navigation"
)
source_navigation_task = next(
entry for entry in recipe_index["task_entrypoints"] if entry["id"] == "source-recipe-navigation"
)
if python_navigation_task["recommended"] != "python-client-recipe-index.py":
raise ValueError("python navigator task drifted")
if "docs/python-consumption.md" not in python_navigation_task["docs"]:
raise ValueError("python navigator docs drifted")
if "python" not in python_navigation_task["runtimes"]:
raise ValueError("python navigator runtimes drifted")
if source_navigation_task["recommended"] != "ts-client-recipe-index.ts":
raise ValueError("source navigator task drifted")
summary = {
"version": recipe_index["version"],
"groupCount": len(recipe_index["groups"]),
"taskCount": len(recipe_index["task_entrypoints"]),
"pythonRecommendedStart": python_group["recommended_start"],
"sourceRecommendedStart": source_group["recommended_start"],
"packageRecommendedStart": package_group["recommended_start"],
"pythonNavigatorRecommended": python_navigation_task["recommended"],
"pythonNavigatorAlternativeCount": len(python_navigation_task["alternatives"]),
"sourceNavigatorRecommended": source_navigation_task["recommended"],
"packageNavigatorRecommended": package_navigation_task["recommended"],
}
print(json.dumps(summary, indent=2))