Spaces:
Runtime error
Runtime error
#!/usr/bin/env python3 | |
""" | |
Gradio Compatibility Test | |
======================== | |
Quick test to verify Gradio interface compatibility. | |
""" | |
import gradio as gr | |
import numpy as np | |
def test_interface(): | |
"""Test basic Gradio interface creation.""" | |
def simple_predict(text): | |
return f"Processed: {text}" | |
# Test interface creation with modern Gradio | |
with gr.Blocks(title="Test Interface") as interface: | |
gr.Markdown("# Test Interface") | |
with gr.Row(): | |
text_input = gr.Textbox(label="Input") | |
output = gr.Textbox(label="Output") | |
btn = gr.Button("Process") | |
# Test examples | |
gr.Examples( | |
examples=[["Test 1"], ["Test 2"]], | |
inputs=[text_input], | |
outputs=[output], | |
fn=simple_predict | |
) | |
# Test event handlers | |
btn.click( | |
fn=simple_predict, | |
inputs=[text_input], | |
outputs=[output], | |
show_progress="minimal" | |
) | |
print("β Gradio interface test passed!") | |
return interface | |
if __name__ == "__main__": | |
print("π§ͺ Testing Gradio compatibility...") | |
try: | |
interface = test_interface() | |
print("π All Gradio features working correctly!") | |
# Don't launch, just test creation | |
print("π Interface created successfully with:") | |
print(" β’ Modern Blocks API") | |
print(" β’ Updated event handlers") | |
print(" β’ Compatible Examples component") | |
print(" β’ Proper show_progress values") | |
except Exception as e: | |
print(f"β Gradio compatibility test failed: {e}") | |
exit(1) | |