Abhishek Thakur
commited on
Commit
Β·
c941736
1
Parent(s):
8b606ae
submissions page
Browse files- submit.py β .env.example +0 -0
- __init__.py +1 -0
- backend/__init__.py +0 -0
- backend/db/__init__.py +0 -0
- pages/3_π₯_Submissions.py +72 -2
submit.py β .env.example
RENAMED
|
File without changes
|
__init__.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
__version__ = "0.0.1"
|
backend/__init__.py
ADDED
|
File without changes
|
backend/db/__init__.py
ADDED
|
File without changes
|
pages/3_π₯_Submissions.py
CHANGED
|
@@ -1,5 +1,8 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
-
|
|
|
|
|
|
|
|
|
|
| 3 |
|
| 4 |
SUBMISSION_TEXT = """You can make upto 5 submissions per day.
|
| 5 |
The test data has been divided into public and private splits.
|
|
@@ -8,14 +11,81 @@ Your final score will be based on your private split performance.
|
|
| 8 |
The final rankings will be based on the private split performance.
|
| 9 |
"""
|
| 10 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
|
| 12 |
def app():
|
| 13 |
st.set_page_config(page_title="Submissions", page_icon="π€")
|
| 14 |
st.write("## Submissions")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
st.markdown(SUBMISSION_TEXT)
|
| 16 |
# add submissions history table
|
| 17 |
st.write("### Submissions History")
|
| 18 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
|
| 20 |
|
| 21 |
if __name__ == "__main__":
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
+
from huggingface_hub import HfApi, CommitOperationAdd
|
| 3 |
+
import uuid
|
| 4 |
+
import os
|
| 5 |
+
import pandas as pd
|
| 6 |
|
| 7 |
SUBMISSION_TEXT = """You can make upto 5 submissions per day.
|
| 8 |
The test data has been divided into public and private splits.
|
|
|
|
| 11 |
The final rankings will be based on the private split performance.
|
| 12 |
"""
|
| 13 |
|
| 14 |
+
SUBMISSION_ERROR = """Submission is not in a proper format.
|
| 15 |
+
Please check evaluation instructions for more details."""
|
| 16 |
+
|
| 17 |
+
COMPETITION_ID = os.getenv("COMPETITION_ID", "sample_competition")
|
| 18 |
+
USER_ID = os.getenv("USER_ID", "sample_user")
|
| 19 |
+
DUMMY_DATA_PATH = os.getenv("DUMMY_DATA_PATH", "autoevaluator/benchmark-dummy-data")
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
def verify_submission(submission):
|
| 23 |
+
# verify submission is valid
|
| 24 |
+
return True
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
def fetch_submissions():
|
| 28 |
+
submissions = [
|
| 29 |
+
{
|
| 30 |
+
"submission_id": "72836-23423",
|
| 31 |
+
"score": 0.7,
|
| 32 |
+
"created_at": "2021-01-01T00:00:00Z",
|
| 33 |
+
},
|
| 34 |
+
{
|
| 35 |
+
"submission_id": "23-42332",
|
| 36 |
+
"score": 0.5,
|
| 37 |
+
"created_at": "2021-01-01T00:00:00Z",
|
| 38 |
+
},
|
| 39 |
+
]
|
| 40 |
+
df = pd.DataFrame(submissions)
|
| 41 |
+
return df
|
| 42 |
+
|
| 43 |
|
| 44 |
def app():
|
| 45 |
st.set_page_config(page_title="Submissions", page_icon="π€")
|
| 46 |
st.write("## Submissions")
|
| 47 |
+
uploaded_file = st.sidebar.file_uploader("Choose a file")
|
| 48 |
+
if uploaded_file is not None:
|
| 49 |
+
bytes_data = uploaded_file.getvalue()
|
| 50 |
+
# verify file is valid
|
| 51 |
+
if not verify_submission(bytes_data):
|
| 52 |
+
st.error("Invalid submission")
|
| 53 |
+
st.write(SUBMISSION_ERROR)
|
| 54 |
+
# write a horizontal html line
|
| 55 |
+
st.markdown("<hr/>", unsafe_allow_html=True)
|
| 56 |
+
else:
|
| 57 |
+
# start progress bar
|
| 58 |
+
progress_bar = st.progress(0)
|
| 59 |
+
submission_id = str(uuid.uuid4())
|
| 60 |
+
api = HfApi()
|
| 61 |
+
operations = [
|
| 62 |
+
CommitOperationAdd(
|
| 63 |
+
path_in_repo="submission.csv",
|
| 64 |
+
path_or_fileobj=bytes_data,
|
| 65 |
+
),
|
| 66 |
+
]
|
| 67 |
+
# update progress bar
|
| 68 |
+
progress_bar.progress(0.5)
|
| 69 |
+
api.create_repo(
|
| 70 |
+
repo_id=submission_id,
|
| 71 |
+
private=True,
|
| 72 |
+
repo_type="dataset",
|
| 73 |
+
)
|
| 74 |
+
api.create_commit(
|
| 75 |
+
repo_id=f"{USER_ID}/{submission_id}",
|
| 76 |
+
operations=operations,
|
| 77 |
+
commit_message="add submission.csv",
|
| 78 |
+
repo_type="dataset",
|
| 79 |
+
)
|
| 80 |
+
|
| 81 |
st.markdown(SUBMISSION_TEXT)
|
| 82 |
# add submissions history table
|
| 83 |
st.write("### Submissions History")
|
| 84 |
+
submissions = fetch_submissions()
|
| 85 |
+
if len(submissions) == 0:
|
| 86 |
+
st.write("You have not made any submissions yet.")
|
| 87 |
+
else:
|
| 88 |
+
st.write(submissions)
|
| 89 |
|
| 90 |
|
| 91 |
if __name__ == "__main__":
|