yetessam commited on
Commit
091d271
·
verified ·
1 Parent(s): d93dbdd

Create failed_check.py

Browse files
Files changed (1) hide show
  1. checks/failed_check.py +53 -0
checks/failed_check.py ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import time
3
+ import random
4
+ import os
5
+
6
+
7
+ # Function to simulate the status of the app
8
+ def check_app_status():
9
+ # Simulate different app statuses
10
+ status_options = [
11
+ "The app is building. Please wait a few moments...",
12
+ "The app is restarting. Hold on...",
13
+ "The endpoint is starting up. It might take a few minutes...",
14
+ "Payment is needed for inferences. Please complete payment to continue.",
15
+ "The endpoint is scaled to zero due to inactivity. Starting it now...",
16
+ "The app is ready and operational!"
17
+ ]
18
+
19
+ # Simulate a real condition check (for demonstration, we randomly select one status)
20
+ current_status = random.choice(status_options)
21
+
22
+ # If the endpoint is scaled to zero, simulate the time it takes to start
23
+ if current_status == "The endpoint is scaled to zero due to inactivity. Starting it now...":
24
+ time.sleep(5) # Simulate the time it takes to start the endpoint
25
+
26
+ # Simulate some delay for other operations (like checking the status)
27
+ time.sleep(2)
28
+
29
+ return current_status
30
+
31
+
32
+ # Function to simulate the button click event in Gradio UI
33
+ def get_status():
34
+ return check_app_status()
35
+
36
+
37
+ # Create the Gradio interface
38
+ def create_failed_gradio_ui():
39
+ # Define the Gradio interface
40
+ interface = gr.Interface(
41
+ fn=get_status, # The function to call to get the status
42
+ inputs=[], # No inputs; it's just a status display
43
+ outputs="text", # Output will be a simple text message
44
+ live=True, # Updates automatically when clicked
45
+ title="App Status Dashboard", # Title of the Gradio UI
46
+ description="This Gradio UI displays the current status of the app. It indicates various reasons why the app might not be working, including endpoint scaling or payment issues.",
47
+ )
48
+
49
+ # Launch the UI
50
+ interface.launch()
51
+
52
+
53
+