loubnabnl HF staff commited on
Commit
549a2cc
1 Parent(s): e8f588a

add section for submitting an id for review (#6)

Browse files

- add section for submitting an id for review (27782545139337ae2bad7c0df67a66c0ca9d0951)

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:
@@ -213,13 +219,29 @@ st.markdown(
213
  unsafe_allow_html=True,
214
  )
215
 
216
- # Google Form
217
- # st.markdown(
218
- # """
219
- # <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>
220
- # """,
221
- # unsafe_allow_html=True,
222
- # )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
223
 
224
 
225
  # 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:
 
219
  unsafe_allow_html=True,
220
  )
221
 
222
+ # Submit an id for review
223
+ st.subheader("🔍 Review of requests")
224
+ st.markdown("**If a request should be reviewed or dropped submit its id here/ إذا كان يجب مراجعة أو حذف طلب، أدخل رقمه هنا:**")
225
+ 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)")
226
+ st.markdown("[form](https://docs.google.com/forms/d/e/1FAIpQLSe8D6T__DJDTVGMrIWMT-H-hQ0qDUWVOncKnrSXgv4NbwHCrQ/viewform) إذا تدخلت لحل الطلب، يرجى ملء هذا النموذج الرابط")
227
+
228
+ id_to_review = st.number_input("Enter id / أدخل الرقم", min_value=0, max_value=len(df), value=0, step=1)
229
+ reason_for_review = st.text_area("Explain why / أدخل سبب المراجعة")
230
+ if st.button("Submit / أرسل"):
231
+ if reason_for_review == "":
232
+ st.error("Please enter a reason / الرجاء إدخال سبب")
233
+ else:
234
+ filename = f"review_id_{id_to_review}_{datetime.now().strftime('%Y-%m-%d_%H-%M-%S')}.txt"
235
+ with open(filename, "w") as f:
236
+ f.write(f"id: {id_to_review}, explanation: {reason_for_review}\n")
237
+ api.upload_file(
238
+ path_or_fileobj=filename,
239
+ path_in_repo=filename,
240
+ repo_id="nt3awnou/review_requests",
241
+ repo_type="dataset",
242
+ )
243
+ st.success("Submitted at https://huggingface.co/datasets/nt3awnou/review_requests/ تم الإرسال")
244
+
245
 
246
 
247
  # Credits