File size: 1,630 Bytes
091d271
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e044b5c
091d271
 
 
 
 
 
 
 
 
 
 
e044b5c
091d271
 
 
 
 
 
 
 
968d704
 
6324289
 
 
968d704
3d5b6a8
 
968d704
091d271
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import gradio as gr
import time
import random
import os


# Function to simulate the status of the app
def check_app_status():
    # Simulate different app statuses
    status_options = [
        "The app is building. Please wait a few moments...",
        "The app is restarting. Hold on...",
        "The endpoint is starting up. It might take a few minutes...",
        "Payment is needed for inferences. Please complete payment to continue.",
        "The endpoint is scaled to zero due to inactivity. Starting it now...",
       
    ]
    
    # Simulate a real condition check (for demonstration, we randomly select one status)
    current_status = random.choice(status_options)
    
    # If the endpoint is scaled to zero, simulate the time it takes to start
    if current_status == "The endpoint is scaled to zero due to inactivity. Starting it now...":
        time.sleep(5)  # Simulate the time it takes to start the endpoint
    
    # Simulate some delay for other operations (like checking the status)
    time.sleep(2)
    return "App start up failure, please check back in a day or two"
    return current_status


# Function to simulate the button click event in Gradio UI
def get_status():
    return check_app_status()

# Create the Gradio interface
def create_failed_gradio_ui(status_info):
    with gr.Blocks() as interface:
        gr.Markdown(f"## Inference Endpoint Status")
        gr.Markdown(f"### Status Code: {status_info['status_code']}")
        gr.Markdown(f"### Message: {status_info['message']}")
        gr.JSON(status_info["response_data"], label="Response Data")
    return interface