Update app.py
Browse files
app.py
CHANGED
|
@@ -4,7 +4,6 @@
|
|
| 4 |
# Date: 2025-03-01
|
| 5 |
|
| 6 |
import time
|
| 7 |
-
import utils
|
| 8 |
import requests
|
| 9 |
import pandas as pd
|
| 10 |
import streamlit as st
|
|
@@ -33,8 +32,8 @@ def get_result(task_id):
|
|
| 33 |
st.title("_Monolith_ is :blue[cool]")
|
| 34 |
|
| 35 |
# Language
|
| 36 |
-
lang = st.selectbox("Language?",
|
| 37 |
-
language =
|
| 38 |
|
| 39 |
# Libraries
|
| 40 |
lib_str = st.text_input("Library?", placeholder="Package A, Package B, ... , Package N", help="if any libraries are needed. Seperate with a comma.")
|
|
@@ -56,20 +55,20 @@ editor_buttons = [{
|
|
| 56 |
"commands": ["submit"],
|
| 57 |
"style": {"bottom": "0.44rem","right": "0.4rem"}
|
| 58 |
}]
|
| 59 |
-
code_prompt =
|
| 60 |
-
response_dict = code_editor(code_prompt, lang=
|
| 61 |
|
| 62 |
if response_dict['type'] == 'submit':
|
| 63 |
code = response_dict['text']
|
| 64 |
my_bar = st.progress(0, text=f"Code Execution starts")
|
| 65 |
with st.spinner('Ok, give me a sec...'):
|
| 66 |
-
response =
|
| 67 |
task_id = response['task_id']
|
| 68 |
st.write(f"Task ID: {task_id}")
|
| 69 |
|
| 70 |
for ts in range(timeout+1):
|
| 71 |
time.sleep(1)
|
| 72 |
-
response =
|
| 73 |
if response['status'] in ['done', 'error', 'timeout']:
|
| 74 |
break
|
| 75 |
my_bar.progress(ts / timeout, text=f"Running ({ts}/{timeout}) s...")
|
|
|
|
| 4 |
# Date: 2025-03-01
|
| 5 |
|
| 6 |
import time
|
|
|
|
| 7 |
import requests
|
| 8 |
import pandas as pd
|
| 9 |
import streamlit as st
|
|
|
|
| 32 |
st.title("_Monolith_ is :blue[cool]")
|
| 33 |
|
| 34 |
# Language
|
| 35 |
+
lang = st.selectbox("Language?", lang_map.keys(), help="the language for submission.")
|
| 36 |
+
language = lang_map[lang][0]
|
| 37 |
|
| 38 |
# Libraries
|
| 39 |
lib_str = st.text_input("Library?", placeholder="Package A, Package B, ... , Package N", help="if any libraries are needed. Seperate with a comma.")
|
|
|
|
| 55 |
"commands": ["submit"],
|
| 56 |
"style": {"bottom": "0.44rem","right": "0.4rem"}
|
| 57 |
}]
|
| 58 |
+
code_prompt = lang_map[lang][2]
|
| 59 |
+
response_dict = code_editor(code_prompt, lang=lang_map[lang][0], height=[15,15], options={"wrap": False}, buttons=editor_buttons)
|
| 60 |
|
| 61 |
if response_dict['type'] == 'submit':
|
| 62 |
code = response_dict['text']
|
| 63 |
my_bar = st.progress(0, text=f"Code Execution starts")
|
| 64 |
with st.spinner('Ok, give me a sec...'):
|
| 65 |
+
response = post_task(language, code, libraries, 30, memory_profile)
|
| 66 |
task_id = response['task_id']
|
| 67 |
st.write(f"Task ID: {task_id}")
|
| 68 |
|
| 69 |
for ts in range(timeout+1):
|
| 70 |
time.sleep(1)
|
| 71 |
+
response = get_result(task_id)
|
| 72 |
if response['status'] in ['done', 'error', 'timeout']:
|
| 73 |
break
|
| 74 |
my_bar.progress(ts / timeout, text=f"Running ({ts}/{timeout}) s...")
|