def update_cloud_run_examples()

in scripts/internal/update_example_tables.py [0:0]


def update_cloud_run_examples(examples):
    file_path = "examples/cloud-run/README.md"

    with open(file_path, "r") as f:
        content = f.read()

    # Update Inference Examples
    inference_examples = examples.get("Cloud Run", {}).get("inference", [])
    inference_table = format_table(
        ["Example", "Title"],
        [
            (f"[{os.path.basename(path)}](./{os.path.basename(path)})", title)
            for path, title in sorted(inference_examples, key=lambda x: x[1])
        ],
    )

    inference_pattern = r"(## Inference Examples\n\n)[\s\S]*?(\n\n## Training Examples)"
    inference_replacement = rf"\1{inference_table}\2"
    content = re.sub(inference_pattern, inference_replacement, content, flags=re.DOTALL)

    # Update Training Examples
    training_pattern = r"(## Training Examples\n\n)[\s\S]*"
    training_replacement = r"\1Coming soon!"
    content = re.sub(training_pattern, training_replacement, content, flags=re.DOTALL)

    with open(file_path, "w") as f:
        f.write(content)