Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -25,6 +25,12 @@ def get_status(credentials, instance_name):
|
|
25 |
status = True if item["status"] == "RUNNING" else False
|
26 |
return status, ip_address
|
27 |
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
def activate_server(credentials, instance_name):
|
29 |
service = googleapiclient.discovery.build('compute', 'v1', credentials=credentials)
|
30 |
request = service.instances().start(project='nus-cisco-corp-lab-wp1', zone='asia-southeast1-c', instance=instance_name)
|
@@ -51,7 +57,8 @@ if not status:
|
|
51 |
submitted = st.form_submit_button("Ignite 🚀")
|
52 |
|
53 |
if submitted and token == os.getenv("EASY_TOKEN"):
|
54 |
-
st.write("Lucky Reactor has been ignited. Please wait a few minutes (3~5) to preceed...")
|
|
|
55 |
response = activate_server(credentials, instance_name)
|
56 |
else:
|
57 |
st.write(f"You can access Lucky Reactor via http://{ip_address}:7860")
|
|
|
25 |
status = True if item["status"] == "RUNNING" else False
|
26 |
return status, ip_address
|
27 |
|
28 |
+
def schedule_server(credentials, instance_name):
|
29 |
+
service = googleapiclient.discovery.build('compute', 'v1', credentials=credentials)
|
30 |
+
request = service.instances().setScheduling(project='nus-cisco-corp-lab-wp1', zone='asia-southeast1-c', instance=instance_name, scheduling_resource={"maxRunDuration": {"seconds": 7200}})
|
31 |
+
response = request.execute()
|
32 |
+
return response
|
33 |
+
|
34 |
def activate_server(credentials, instance_name):
|
35 |
service = googleapiclient.discovery.build('compute', 'v1', credentials=credentials)
|
36 |
request = service.instances().start(project='nus-cisco-corp-lab-wp1', zone='asia-southeast1-c', instance=instance_name)
|
|
|
57 |
submitted = st.form_submit_button("Ignite 🚀")
|
58 |
|
59 |
if submitted and token == os.getenv("EASY_TOKEN"):
|
60 |
+
st.write("Lucky Reactor has been ignited. Please wait a few minutes (3~5) to preceed...")
|
61 |
+
response = schedule_server(credentials, instance_name)
|
62 |
response = activate_server(credentials, instance_name)
|
63 |
else:
|
64 |
st.write(f"You can access Lucky Reactor via http://{ip_address}:7860")
|