Update src/streamlit_app.py
Browse files- src/streamlit_app.py +10 -6
src/streamlit_app.py
CHANGED
|
@@ -12,10 +12,14 @@ from huggingface_hub import login
|
|
| 12 |
|
| 13 |
|
| 14 |
#===
|
| 15 |
-
login()
|
| 16 |
-
|
| 17 |
-
feedback_file = Path("PedroC11/data_pref/") / f"data_{uuid.uuid4()}.json"
|
| 18 |
-
feedback_folder = feedback_file.parent
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
|
| 20 |
# Schedule regular uploads. Remote repo and local folder are created if they don't already exist.
|
| 21 |
scheduler = CommitScheduler(
|
|
@@ -23,7 +27,7 @@ scheduler = CommitScheduler(
|
|
| 23 |
repo_type="dataset",
|
| 24 |
folder_path=feedback_folder,
|
| 25 |
path_in_repo="data",
|
| 26 |
-
every=10,
|
| 27 |
)
|
| 28 |
|
| 29 |
# Define the function that will be called when the user submits its feedback (to be called in Gradio)
|
|
@@ -92,7 +96,7 @@ if st.button("Submit"):
|
|
| 92 |
#====
|
| 93 |
with scheduler.lock:
|
| 94 |
with feedback_file.open("a") as f:
|
| 95 |
-
f.write(json.
|
| 96 |
f.write("\n")
|
| 97 |
#====
|
| 98 |
|
|
|
|
| 12 |
|
| 13 |
|
| 14 |
#===
|
| 15 |
+
#login()
|
| 16 |
+
## Define the file where to save the data. Use UUID to make sure not to overwrite existing data from a previous run.
|
| 17 |
+
#feedback_file = Path("PedroC11/data_pref/") / f"data_{uuid.uuid4()}.json"
|
| 18 |
+
#feedback_folder = feedback_file.parent
|
| 19 |
+
|
| 20 |
+
feedback_folder = Path("data_JSON")
|
| 21 |
+
feedback_folder.mkdir(parents=True, exist_ok=True)
|
| 22 |
+
feedback_file = feedback_folder / f"data_{uuid.uuid4()}.json"
|
| 23 |
|
| 24 |
# Schedule regular uploads. Remote repo and local folder are created if they don't already exist.
|
| 25 |
scheduler = CommitScheduler(
|
|
|
|
| 27 |
repo_type="dataset",
|
| 28 |
folder_path=feedback_folder,
|
| 29 |
path_in_repo="data",
|
| 30 |
+
#every=10,
|
| 31 |
)
|
| 32 |
|
| 33 |
# Define the function that will be called when the user submits its feedback (to be called in Gradio)
|
|
|
|
| 96 |
#====
|
| 97 |
with scheduler.lock:
|
| 98 |
with feedback_file.open("a") as f:
|
| 99 |
+
f.write(json.dump(results))
|
| 100 |
f.write("\n")
|
| 101 |
#====
|
| 102 |
|