File size: 1,427 Bytes
3e5274f
baaf55c
3e5274f
 
baaf55c
 
 
3e5274f
baaf55c
 
 
3e5274f
baaf55c
 
 
3e5274f
baaf55c
 
 
3e5274f
baaf55c
 
 
 
 
 
 
 
 
 
 
3e5274f
 
baaf55c
 
 
3e5274f
 
baaf55c
 
 
 
3e5274f
 
baaf55c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import gradio as gr
import subprocess
import runpodctl

def start_pod(pod_name):
    result = subprocess.run(["runpodctl", "start", pod_name], capture_output=True, text=True)
    return result.stdout

def stop_pod(pod_name):
    result = subprocess.run(["runpodctl", "stop", pod_name], capture_output=True, text=True)
    return result.stdout

def delete_pod(pod_name):
    result = subprocess.run(["runpodctl", "delete", pod_name], capture_output=True, text=True)
    return result.stdout

def create_pod(pod_name):
    result = subprocess.run(["runpodctl", "create", pod_name], capture_output=True, text=True)
    return result.stdout

def run_app(action, pod_name):
    if action == "start":
        output = start_pod(pod_name)
    elif action == "stop":
        output = stop_pod(pod_name)
    elif action == "delete":
        output = delete_pod(pod_name)
    elif action == "create":
        output = create_pod(pod_name)
    else:
        output = "Unknown action. Please select a valid action."
    return output

action_options = gr.inputs.Radio(["start", "stop", "delete", "create"], label="Choose action")
pod_name_input = gr.inputs.Textbox(label="Enter pod name")

iface = gr.Interface(
    fn=run_app,
    inputs=[action_options, pod_name_input],
    outputs="text",
    title="Pod Management",
    description="Enter the pod name and choose an action to perform on the pod.",
    theme="default"
)
iface.launch()