loubnabnl HF staff commited on
Commit
2778254
1 Parent(s): bfad8fc

add section for submitting an id for review

Browse files
Files changed (1) hide show
  1. app.py +32 -10
app.py CHANGED
@@ -1,11 +1,17 @@
 
 
 
1
  import folium
2
- import streamlit as st
3
  import pandas as pd
 
 
4
  from streamlit_folium import st_folium
5
- import time
6
- import requests
7
  from utils import legend_macro
 
8
 
 
 
 
9
  st.set_page_config(layout="wide", initial_sidebar_state="collapsed")
10
 
11
  if "sleep_time" not in st.session_state:
@@ -189,13 +195,29 @@ st.markdown(
189
  unsafe_allow_html=True,
190
  )
191
 
192
- # Google Form
193
- # st.markdown(
194
- # """
195
- # <iframe src="https://docs.google.com/forms/d/e/1FAIpQLSfNrFHUScot5jQyRUJmor7kWYgwkkME6WqRgQG_L4Eze4RdHA/viewform?embedded=true" width="640" height="2877" frameborder="0" marginheight="0" marginwidth="0">Loading…</iframe>
196
- # """,
197
- # unsafe_allow_html=True,
198
- # )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
199
 
200
 
201
  # Credits
 
1
+ import os
2
+ import time
3
+ import requests
4
  import folium
 
5
  import pandas as pd
6
+ from datetime import datetime
7
+ import streamlit as st
8
  from streamlit_folium import st_folium
 
 
9
  from utils import legend_macro
10
+ from huggingface_hub import HfApi
11
 
12
+
13
+ TOKEN = os.environ.get("HF_TOKEN", None)
14
+ api = HfApi(token=TOKEN)
15
  st.set_page_config(layout="wide", initial_sidebar_state="collapsed")
16
 
17
  if "sleep_time" not in st.session_state:
 
195
  unsafe_allow_html=True,
196
  )
197
 
198
+ # Submit an id for review
199
+ st.subheader("🔍 Review of requests")
200
+ st.markdown("**If a request should be reviewed or dropped submit its id here/ إذا كان يجب مراجعة أو حذف طلب، أدخل رقمه هنا:**")
201
+ st.markdown("If you intervened to solve the request, please fill this [form](https://docs.google.com/forms/d/e/1FAIpQLSe8D6T__DJDTVGMrIWMT-H-hQ0qDUWVOncKnrSXgv4NbwHCrQ/viewform)")
202
+ st.markdown("[form](https://docs.google.com/forms/d/e/1FAIpQLSe8D6T__DJDTVGMrIWMT-H-hQ0qDUWVOncKnrSXgv4NbwHCrQ/viewform) إذا تدخلت لحل الطلب، يرجى ملء هذا النموذج الرابط")
203
+
204
+ id_to_review = st.number_input("Enter id / أدخل الرقم", min_value=0, max_value=len(df), value=0, step=1)
205
+ reason_for_review = st.text_area("Explain why / أدخل سبب المراجعة")
206
+ if st.button("Submit / أرسل"):
207
+ if reason_for_review == "":
208
+ st.error("Please enter a reason / الرجاء إدخال سبب")
209
+ else:
210
+ filename = f"review_id_{id_to_review}_{datetime.now().strftime('%Y-%m-%d_%H-%M-%S')}.txt"
211
+ with open(filename, "w") as f:
212
+ f.write(f"id: {id_to_review}, explanation: {reason_for_review}\n")
213
+ api.upload_file(
214
+ path_or_fileobj=filename,
215
+ path_in_repo=filename,
216
+ repo_id="nt3awnou/review_requests",
217
+ repo_type="dataset",
218
+ )
219
+ st.success("Submitted at https://huggingface.co/datasets/nt3awnou/review_requests/ تم الإرسال")
220
+
221
 
222
 
223
  # Credits