Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -64,11 +64,19 @@ st.title("Lucky Reactor Panel")
|
|
64 |
|
65 |
instance_name = "lucky-reactor"
|
66 |
credentials = auth()
|
67 |
-
status, ip_address = get_status(credentials, instance_name)
|
68 |
|
69 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
70 |
|
71 |
-
|
|
|
|
|
|
|
72 |
with st.form("activate_form"):
|
73 |
token = st.text_input("Token (FYI: The reactor costs USD $10 per hour to operate)")
|
74 |
submitted = st.form_submit_button("Ignite ๐")
|
@@ -79,11 +87,7 @@ if not status:
|
|
79 |
response = activate_server(credentials, instance_name)
|
80 |
else:
|
81 |
st.write(f"You can access Lucky Reactor via http://{ip_address}:7860")
|
82 |
-
|
83 |
-
max_run_duration = info['scheduling']['maxRunDuration']['seconds']
|
84 |
-
last_start_timestamp = info['lastStartTimestamp']
|
85 |
-
max_remaining_time = get_time_remaining(last_start_timestamp, max_run_duration)
|
86 |
-
st.write(f'Max Remaining Seconds: {max_remaining_time} s')
|
87 |
|
88 |
with st.form("deactivate_form"):
|
89 |
token = st.text_input("Token")
|
|
|
64 |
|
65 |
instance_name = "lucky-reactor"
|
66 |
credentials = auth()
|
|
|
67 |
|
68 |
+
# Get instance info
|
69 |
+
instance_info = get_server(credentials, instance_name)
|
70 |
+
status = instance_info['status']
|
71 |
+
ip_address = instance_info['networkInterfaces'][0]['accessConfigs'][0]['natIP']
|
72 |
+
max_run_duration = instance_info['scheduling']['maxRunDuration']['seconds']
|
73 |
+
last_start_timestamp = instance_info['lastStartTimestamp']
|
74 |
+
max_remaining_time = get_time_remaining(last_start_timestamp, max_run_duration)
|
75 |
|
76 |
+
# UI
|
77 |
+
st.image("cover.jpg", caption="Lucky Reactor is currently " + ("running ๐" if status == 'RUNNING' else "sleeping ๐ด") + ".")
|
78 |
+
|
79 |
+
if status != 'RUNNING':
|
80 |
with st.form("activate_form"):
|
81 |
token = st.text_input("Token (FYI: The reactor costs USD $10 per hour to operate)")
|
82 |
submitted = st.form_submit_button("Ignite ๐")
|
|
|
87 |
response = activate_server(credentials, instance_name)
|
88 |
else:
|
89 |
st.write(f"You can access Lucky Reactor via http://{ip_address}:7860")
|
90 |
+
st.write(f'Lucky Reactor can still run: {max_remaining_time} s. You can terminate it in advance.')
|
|
|
|
|
|
|
|
|
91 |
|
92 |
with st.form("deactivate_form"):
|
93 |
token = st.text_input("Token")
|