Timothyxxx commited on
Commit
7faa846
β€’
1 Parent(s): f6f97d8

Add feature stamp

Browse files
Files changed (1) hide show
  1. app.py +5 -4
app.py CHANGED
@@ -1,6 +1,6 @@
1
  import json
2
  import os
3
-
4
  import pandas as pd
5
  import streamlit as st
6
  import argparse
@@ -198,13 +198,14 @@ elif selected_language == 'Python':
198
  else:
199
  raise ValueError(f'{selected_language} language is not supported.')
200
  try:
 
201
  os.makedirs('tmp_for_vis/', exist_ok=True)
202
  with st.spinner("Executing program ..."):
203
- exec_answer = executor.nsql_exec(binder_program, db)
204
  # todo: Make it more pretty!
205
  # todo: Do we need vis for Python?
206
  if selected_language == 'SQL':
207
- with open("tmp_for_vis/tmp_for_vis_steps.txt", "r") as f:
208
  steps = json.load(f)
209
  st.markdown("#### Steps & Intermediate results")
210
  for i, step in enumerate(steps):
@@ -212,7 +213,7 @@ try:
212
  st.text("↓")
213
  with st.spinner('...'):
214
  time.sleep(1)
215
- with open("tmp_for_vis/result_step_{}.txt".format(i), "r") as f:
216
  result_in_this_step = json.load(f)
217
  if isinstance(result_in_this_step, Dict):
218
  st.dataframe(pd.DataFrame(pd.DataFrame(result_in_this_step["rows"], columns=result_in_this_step["header"])))
 
1
  import json
2
  import os
3
+ import uuid
4
  import pandas as pd
5
  import streamlit as st
6
  import argparse
 
198
  else:
199
  raise ValueError(f'{selected_language} language is not supported.')
200
  try:
201
+ stamp = '{}'.format(uuid.uuid4())
202
  os.makedirs('tmp_for_vis/', exist_ok=True)
203
  with st.spinner("Executing program ..."):
204
+ exec_answer = executor.nsql_exec(stamp, binder_program, db)
205
  # todo: Make it more pretty!
206
  # todo: Do we need vis for Python?
207
  if selected_language == 'SQL':
208
+ with open("tmp_for_vis/{}_tmp_for_vis_steps.txt".format(stamp), "r") as f:
209
  steps = json.load(f)
210
  st.markdown("#### Steps & Intermediate results")
211
  for i, step in enumerate(steps):
 
213
  st.text("↓")
214
  with st.spinner('...'):
215
  time.sleep(1)
216
+ with open("tmp_for_vis/{}_result_step_{}.txt".format(stamp, i), "r") as f:
217
  result_in_this_step = json.load(f)
218
  if isinstance(result_in_this_step, Dict):
219
  st.dataframe(pd.DataFrame(pd.DataFrame(result_in_this_step["rows"], columns=result_in_this_step["header"])))