rowankwang commited on
Commit
924ef80
·
1 Parent(s): f396b8b

download button

Browse files
Files changed (1) hide show
  1. app.py +12 -3
app.py CHANGED
@@ -17,7 +17,8 @@ def save_data(data):
17
  print(file_path.split(".json")[0])
18
  with open(f"{file_path.split('.json')[0]}_graded.json", 'w') as file:
19
  json.dump(data, file, indent=4)
20
-
 
21
  data = load_data()
22
 
23
  for query in data:
@@ -59,7 +60,7 @@ def display_query():
59
 
60
  st.session_state.graded_queries = sum(query.get('status', None) is not None for query in st.session_state.data)
61
  print(f"Current Query Index: {st.session_state.current_query_index} | Graded Queries: {st.session_state.graded_queries} | Total Queries: {len(st.session_state.data)} | Current Query Status {current_query.get('status', None)}")
62
- col1, col2 = st.columns([5, 1], gap="small")
63
  with col1:
64
  if st.button('Previous'):
65
  if st.session_state.current_query_index > 0:
@@ -67,7 +68,7 @@ def display_query():
67
  st.rerun()
68
  st.progress((st.session_state.current_query_index + 1) / len(st.session_state.data))
69
  with col2:
70
- col1, col2, col3 = st.columns([1, 1, 1], gap = "small")
71
  with col1:
72
  if st.button('Next'):
73
  if st.session_state.current_query_index < len(st.session_state.data) - 1:
@@ -81,6 +82,14 @@ def display_query():
81
  if st.button('Junk'):
82
  current_query['status'] = 'nonsense'
83
  next_query()
 
 
 
 
 
 
 
 
84
 
85
  st.markdown(f"<p>At index {st.session_state.current_query_index + 1}. Graded Queries: {st.session_state.graded_queries}/{len(st.session_state.data)}</p>", unsafe_allow_html=True)
86
 
 
17
  print(file_path.split(".json")[0])
18
  with open(f"{file_path.split('.json')[0]}_graded.json", 'w') as file:
19
  json.dump(data, file, indent=4)
20
+ def download_json(data):
21
+ return json.dumps(data, indent=4)
22
  data = load_data()
23
 
24
  for query in data:
 
60
 
61
  st.session_state.graded_queries = sum(query.get('status', None) is not None for query in st.session_state.data)
62
  print(f"Current Query Index: {st.session_state.current_query_index} | Graded Queries: {st.session_state.graded_queries} | Total Queries: {len(st.session_state.data)} | Current Query Status {current_query.get('status', None)}")
63
+ col1, col2 = st.columns([4, 2], gap="small")
64
  with col1:
65
  if st.button('Previous'):
66
  if st.session_state.current_query_index > 0:
 
68
  st.rerun()
69
  st.progress((st.session_state.current_query_index + 1) / len(st.session_state.data))
70
  with col2:
71
+ col1, col2, col3, col4 = st.columns([1, 1, 1, 1], gap = "small")
72
  with col1:
73
  if st.button('Next'):
74
  if st.session_state.current_query_index < len(st.session_state.data) - 1:
 
82
  if st.button('Junk'):
83
  current_query['status'] = 'nonsense'
84
  next_query()
85
+ with col4:
86
+ # Example button for downloading data
87
+ st.download_button(
88
+ label="Download",
89
+ data=download_json(st.session_state.data),
90
+ file_name="graded_data.json",
91
+ mime="application/json"
92
+ )
93
 
94
  st.markdown(f"<p>At index {st.session_state.current_query_index + 1}. Graded Queries: {st.session_state.graded_queries}/{len(st.session_state.data)}</p>", unsafe_allow_html=True)
95