|
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() |