|
3 | 3 |
|
4 | 4 | This script is used to benchmark the inference time and cold boot. |
5 | 5 |
|
6 | | -Requests are sent in batches. In between batches, we use the Beam CLI to kill the container |
| 6 | +Requests are sent in batches. In between batches, we use the Beam CLI to kill the container |
7 | 7 | that is running in order to demonstrate the cold boot latency (`beam container list` and `beam container stop`) |
8 | 8 | """ |
9 | 9 |
|
10 | 10 | import requests |
11 | 11 | import time |
12 | 12 | import subprocess |
| 13 | +import json |
| 14 | + |
13 | 15 |
|
14 | 16 | BEAM_AUTH_TOKEN = "" # Add your Beam Auth Token, you can find it in the dashboard by clicking the 'Call API' button on your app |
15 | 17 |
|
16 | 18 | url = "https://app.beam.cloud/endpoint/whisper/v1" |
| 19 | + |
17 | 20 | headers = { |
18 | 21 | "Connection": "keep-alive", |
19 | 22 | "Authorization": f"Bearer {BEAM_AUTH_TOKEN}", |
|
59 | 62 |
|
60 | 63 | # Run "beam container list" to show all running containers |
61 | 64 | result = subprocess.run( |
62 | | - ["beam", "container", "list"], capture_output=True, text=True |
| 65 | + ["beam", "container", "list", "--format", "json"], |
| 66 | + capture_output=True, |
| 67 | + text=True, |
63 | 68 | ) |
64 | 69 | print(result.stdout) |
65 | 70 |
|
66 | 71 | # Run "beam container stop" for each container to demonstrate cold boot latency |
67 | | - lines = result.stdout.split("\n") |
| 72 | + containers = json.loads(result.stdout) |
68 | 73 | container_ids = [] |
69 | | - for line in lines: |
70 | | - if "RUNNING" in line: |
71 | | - container_id = line.split()[0] |
| 74 | + for container in containers: |
| 75 | + if container.get("status") == "RUNNING": |
| 76 | + container_id = container.get("container_id") |
72 | 77 | container_ids.append(container_id) |
73 | 78 |
|
74 | 79 | for container_id in container_ids: |
|
0 commit comments