Skip to content

Commit 5821050

Browse files
authored
Fix container not found (#91)
* fix container not found * remove token
1 parent 1897798 commit 5821050

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

audio_and_transcription/whisper_stt/request.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,20 @@
33
44
This script is used to benchmark the inference time and cold boot.
55
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
77
that is running in order to demonstrate the cold boot latency (`beam container list` and `beam container stop`)
88
"""
99

1010
import requests
1111
import time
1212
import subprocess
13+
import json
14+
1315

1416
BEAM_AUTH_TOKEN = "" # Add your Beam Auth Token, you can find it in the dashboard by clicking the 'Call API' button on your app
1517

1618
url = "https://app.beam.cloud/endpoint/whisper/v1"
19+
1720
headers = {
1821
"Connection": "keep-alive",
1922
"Authorization": f"Bearer {BEAM_AUTH_TOKEN}",
@@ -59,16 +62,18 @@
5962

6063
# Run "beam container list" to show all running containers
6164
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,
6368
)
6469
print(result.stdout)
6570

6671
# Run "beam container stop" for each container to demonstrate cold boot latency
67-
lines = result.stdout.split("\n")
72+
containers = json.loads(result.stdout)
6873
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")
7277
container_ids.append(container_id)
7378

7479
for container_id in container_ids:

0 commit comments

Comments
 (0)