in scripts/internal/update_example_tables.py [0:0]
def update_vertex_ai_examples(examples):
file_path = "examples/vertex-ai/README.md"
with open(file_path, "r") as f:
content = f.read()
new_content = []
for line in content.split("\n"):
if line.startswith("## Notebooks"):
new_content.append(line)
break
new_content.append(line)
for example_type in ["Training", "Inference", "Evaluation"]:
examples_list = examples.get("Vertex AI", {}).get(example_type.lower(), [])
new_content.append(f"\n### {example_type} Examples\n")
if examples_list:
table = format_table(
["Example", "Title"],
[
(
f"[notebooks/{os.path.basename(path)}](./notebooks/{os.path.basename(path)})",
title,
)
for path, title in sorted(examples_list, key=lambda x: x[1])
],
)
new_content.append(table)
else:
new_content.append("Coming soon!")
# Handle Pipelines section
new_content.append("\n## Pipelines\n")
pipeline_examples = examples.get("Vertex AI", {}).get("pipeline", [])
if pipeline_examples:
table = format_table(
["Example", "Title"],
[
(
f"[pipelines/{os.path.basename(path)}](./pipelines/{os.path.basename(path)})",
title,
)
for path, title in sorted(pipeline_examples, key=lambda x: x[1])
],
)
new_content.append(table)
else:
new_content.append("Coming soon!")
with open(file_path, "w") as f:
f.write("\n".join(new_content).strip())