Spaces:
Runtime error
Runtime error
Fix: Add assertions to minimal demo
Browse files- test_minimal.py +14 -5
test_minimal.py
CHANGED
|
@@ -11,18 +11,27 @@ IS_SPACES = (
|
|
| 11 |
os.getenv("HF_SPACE_ID") is not None
|
| 12 |
)
|
| 13 |
|
| 14 |
-
# Create a minimal demo
|
| 15 |
with gr.Blocks(title="Test Demo") as demo:
|
| 16 |
-
gr.Markdown("# Test Demo")
|
| 17 |
-
gr.Markdown("If you see this, Gradio is working!")
|
| 18 |
-
|
| 19 |
-
|
|
|
|
| 20 |
|
| 21 |
def echo(text):
|
|
|
|
|
|
|
| 22 |
return f"You said: {text}"
|
| 23 |
|
| 24 |
text_input.submit(echo, inputs=text_input, outputs=text_output)
|
| 25 |
|
|
|
|
| 26 |
print(f"Demo created: {type(demo)}")
|
| 27 |
print(f"IS_SPACES: {IS_SPACES}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
|
|
|
|
| 11 |
os.getenv("HF_SPACE_ID") is not None
|
| 12 |
)
|
| 13 |
|
| 14 |
+
# Create a minimal demo - CRITICAL: demo must be at module level
|
| 15 |
with gr.Blocks(title="Test Demo") as demo:
|
| 16 |
+
gr.Markdown("# ✅ Test Demo - Gradio is Working!")
|
| 17 |
+
gr.Markdown("If you see this message, Gradio is working correctly on Spaces!")
|
| 18 |
+
|
| 19 |
+
text_input = gr.Textbox(label="Test Input", placeholder="Type something here...")
|
| 20 |
+
text_output = gr.Textbox(label="Test Output", interactive=False)
|
| 21 |
|
| 22 |
def echo(text):
|
| 23 |
+
if not text:
|
| 24 |
+
return "Please enter some text"
|
| 25 |
return f"You said: {text}"
|
| 26 |
|
| 27 |
text_input.submit(echo, inputs=text_input, outputs=text_output)
|
| 28 |
|
| 29 |
+
# CRITICAL: Ensure demo is accessible
|
| 30 |
print(f"Demo created: {type(demo)}")
|
| 31 |
print(f"IS_SPACES: {IS_SPACES}")
|
| 32 |
+
print(f"Demo is valid: {isinstance(demo, (gr.Blocks, gr.Interface))}")
|
| 33 |
+
|
| 34 |
+
# Explicitly verify demo exists
|
| 35 |
+
assert demo is not None, "Demo must not be None"
|
| 36 |
+
assert isinstance(demo, (gr.Blocks, gr.Interface)), f"Demo must be Gradio object, got {type(demo)}"
|
| 37 |
|