Update
Browse files
app.py
CHANGED
|
@@ -25,27 +25,12 @@ def post_task(lang, code, libs=None, timeout=30, memory_profile=False):
|
|
| 25 |
response = requests.post(url, json=data)
|
| 26 |
return response.json()
|
| 27 |
|
| 28 |
-
def get_result(task_id):
|
| 29 |
-
url = f'https://monolith.cool/results/{task_id}'
|
| 30 |
-
response = requests.get(url)
|
| 31 |
-
return response.json()
|
| 32 |
-
|
| 33 |
-
def get_status():
|
| 34 |
-
url = 'https://monolith.cool/status'
|
| 35 |
-
response = requests.get(url)
|
| 36 |
-
return response.json()
|
| 37 |
-
|
| 38 |
# Title
|
| 39 |
st.title("_Monolith_ is :blue[Cool] :sunglasses:")
|
| 40 |
st.markdown("[](https://github.com/Elfsong/Monolith)")
|
| 41 |
st.write("Please feel free to have a try. Should you have any question, contact mingzhe@nus.edu.sg")
|
| 42 |
st.write("[UPDATE] Hosting the service is costly, so I’ve enabled the spot instance feature. DM me if you need access.")
|
| 43 |
|
| 44 |
-
# Status
|
| 45 |
-
monolith_status = get_status()
|
| 46 |
-
worker_status = ''.join(['🟢' if worker_status else '🟡' for worker_status in monolith_status['worker_status']])
|
| 47 |
-
st.write(f"{worker_status}")
|
| 48 |
-
|
| 49 |
# Language
|
| 50 |
lang = st.selectbox("Language?", lang_map.keys(), help="the language for submission.")
|
| 51 |
editor_language = lang_map[lang][0]
|
|
@@ -76,19 +61,11 @@ response_dict = code_editor(code_prompt, lang=editor_language, height=[15,15], o
|
|
| 76 |
|
| 77 |
if response_dict['type'] == 'submit':
|
| 78 |
code = response_dict['text']
|
| 79 |
-
|
| 80 |
with st.spinner('Ok, give me a sec...'):
|
| 81 |
response = post_task(monolith_language, code, libraries, timeout, profiling)
|
| 82 |
task_id = response['task_id']
|
| 83 |
st.write(f"Task ID: {task_id}")
|
| 84 |
-
|
| 85 |
-
for ts in range(timeout+1):
|
| 86 |
-
time.sleep(1)
|
| 87 |
-
response = get_result(task_id)
|
| 88 |
-
if response['status'] in ['done', 'error', 'timeout']:
|
| 89 |
-
my_bar.progress(ts / timeout, text=f"{response['status']} ({ts}/{timeout}) s...")
|
| 90 |
-
break
|
| 91 |
-
my_bar.progress(ts / timeout, text=f"Running ({ts}/{timeout}) s...")
|
| 92 |
|
| 93 |
if response['output_dict'] and 'stdout' in response['output_dict']:
|
| 94 |
st.success(response['output_dict']['stdout'])
|
|
|
|
| 25 |
response = requests.post(url, json=data)
|
| 26 |
return response.json()
|
| 27 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
# Title
|
| 29 |
st.title("_Monolith_ is :blue[Cool] :sunglasses:")
|
| 30 |
st.markdown("[](https://github.com/Elfsong/Monolith)")
|
| 31 |
st.write("Please feel free to have a try. Should you have any question, contact mingzhe@nus.edu.sg")
|
| 32 |
st.write("[UPDATE] Hosting the service is costly, so I’ve enabled the spot instance feature. DM me if you need access.")
|
| 33 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 34 |
# Language
|
| 35 |
lang = st.selectbox("Language?", lang_map.keys(), help="the language for submission.")
|
| 36 |
editor_language = lang_map[lang][0]
|
|
|
|
| 61 |
|
| 62 |
if response_dict['type'] == 'submit':
|
| 63 |
code = response_dict['text']
|
| 64 |
+
|
| 65 |
with st.spinner('Ok, give me a sec...'):
|
| 66 |
response = post_task(monolith_language, code, libraries, timeout, profiling)
|
| 67 |
task_id = response['task_id']
|
| 68 |
st.write(f"Task ID: {task_id}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 69 |
|
| 70 |
if response['output_dict'] and 'stdout' in response['output_dict']:
|
| 71 |
st.success(response['output_dict']['stdout'])
|