Created
January 26, 2023 15:57
-
-
Save CodingFu/30ae4b450ed488e2cbc15710c3620c96 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
import datetime | |
import time | |
RUNPOD_API_ID = '0ghslhh025pwkc' | |
RUNPOD_API_KEY = 'IWR8SFXIKW3BXHK5VSADD3IPPXURBDNM9EDC8EX6' | |
SLEEP_INTERVAL = 1 | |
RUNPOD_API_BASE = 'https://api.runpod.ai/v1/' + RUNPOD_API_ID | |
URL = 'https://storage.googleapis.com/elis-prototype/audio-video-content/PBS_News_Hour_Nov_17.m4a' | |
HEADERS = {'Content-Type': 'application/json', 'Authorization': 'Bearer ' + RUNPOD_API_KEY} | |
def invoke_runpod(url: str, mode: str) -> str: | |
url = RUNPOD_API_BASE + '/run' | |
body = {'prompt': url, 'mode': mode} | |
response = requests.post(RUNPOD_API_BASE + '/run', headers=HEADERS, json=body) | |
id = response.json()['id'] | |
return id | |
def check_runpod(id: str): | |
response = requests.get(RUNPOD_API_BASE + '/status/' + id, headers=HEADERS) | |
return response.json()['status'] | |
if __name__ == "__main__": | |
job_id_a = invoke_runpod(URL, 'transcription') | |
job_id_b = invoke_runpod(URL, 'diarization') | |
print("JOB A: {}, JOB B: {}".format(job_id_a, job_id_b)) | |
for i in range(1000): | |
a_status = check_runpod(job_id_a) | |
print("{} JOB A STATUS: {}".format(datetime.datetime.now(), a_status)) | |
b_status = check_runpod(job_id_b) | |
print("{} JOB B STATUS: {}".format(datetime.datetime.now(), b_status)) | |
time.sleep(SLEEP_INTERVAL) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment