#!/usr/bin/env python3 """ Component testing to identify schema validation issues """ import os import ssl # SSL fixes try: import certifi os.environ['SSL_CERT_FILE'] = certifi.where() os.environ['REQUESTS_CA_BUNDLE'] = certifi.where() except ImportError: pass ssl._create_default_https_context = ssl._create_unverified_context os.environ['PYTHONHTTPSVERIFY'] = '0' import gradio as gr def test_basic_components(): """Test 1: Basic components only""" with gr.Blocks(title="Test 1: Basic") as demo: gr.HTML("

Test 1: Basic Components

") vehicle_input = gr.Radio(choices=["Robot", "Drone"], value="Robot") text_input = gr.Textbox(value="test") button = gr.Button("Test") output = gr.Textbox() button.click(lambda v, t: f"{v}: {t}", [vehicle_input, text_input], output) return demo def test_with_slider(): """Test 2: Add Slider component""" with gr.Blocks(title="Test 2: With Slider") as demo: gr.HTML("

Test 2: With Slider

") vehicle_input = gr.Radio(choices=["Robot", "Drone"], value="Robot") text_input = gr.Textbox(value="test") slider_input = gr.Slider(0, 100, value=50) button = gr.Button("Test") output = gr.Textbox() button.click(lambda v, t, s: f"{v}: {t}, {s}", [vehicle_input, text_input, slider_input], output) return demo def test_with_json(): """Test 3: Add JSON component""" with gr.Blocks(title="Test 3: With JSON") as demo: gr.HTML("

Test 3: With JSON

") vehicle_input = gr.Radio(choices=["Robot", "Drone"], value="Robot") text_input = gr.Textbox(value="test") button = gr.Button("Test") output = gr.Textbox() json_output = gr.JSON() def test_func(v, t): return f"{v}: {t}", {"vehicle": v, "text": t} button.click(test_func, [vehicle_input, text_input], [output, json_output]) return demo def test_with_image(): """Test 4: Add Image component""" with gr.Blocks(title="Test 4: With Image") as demo: gr.HTML("

Test 4: With Image

") vehicle_input = gr.Radio(choices=["Robot", "Drone"], value="Robot") text_input = gr.Textbox(value="test") button = gr.Button("Test") output = gr.Textbox() image_output = gr.Image() button.click(lambda v, t: (f"{v}: {t}", None), [vehicle_input, text_input], [output, image_output]) return demo def test_with_file(): """Test 5: Add File component""" with gr.Blocks(title="Test 5: With File") as demo: gr.HTML("

Test 5: With File

") vehicle_input = gr.Radio(choices=["Robot", "Drone"], value="Robot") text_input = gr.Textbox(value="test") button = gr.Button("Test") output = gr.Textbox() file_output = gr.File() button.click(lambda v, t: (f"{v}: {t}", None), [vehicle_input, text_input], [output, file_output]) return demo if __name__ == "__main__": tests = [ ("Basic Components", test_basic_components), ("With Slider", test_with_slider), ("With JSON", test_with_json), ("With Image", test_with_image), ("With File", test_with_file) ] for i, (name, test_func) in enumerate(tests, 1): print(f"\n{'='*50}") print(f"Testing {i}: {name}") print(f"{'='*50}") try: demo = test_func() print(f"✅ {name} - Demo created successfully") # Try to launch briefly to trigger schema validation try: demo.launch( server_port=7860 + i, share=False, prevent_thread_lock=True, quiet=True ) print(f"✅ {name} - Launched successfully") demo.close() except Exception as e: print(f"❌ {name} - Launch failed: {e}") if "bool" in str(e) and "iterable" in str(e): print(f"🎯 FOUND IT! {name} causes the schema error!") break except Exception as e: print(f"❌ {name} - Creation failed: {e}") if "bool" in str(e) and "iterable" in str(e): print(f"🎯 FOUND IT! {name} causes the schema error!") break print("\n" + "="*50) print("Component testing complete!")