File size: 720 Bytes
a557d54
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import streamlit as st
import json
from validate import validate_submission
from huggingface_hub import whoami, create_repo, Repository
import os
from pathlib import Path
from dotenv import load_dotenv

if Path(".env").is_file():
    load_dotenv(".env")

hf_token = os.getenv("HF_TOKEN")

with st.form(key="form"):
    uploaded_file = st.file_uploader("Upload a submission.json file", type=["json"])

    if uploaded_file is not None:
        data = str(uploaded_file.read(), "utf-8")
        json_data = json.loads(data)

    token = st.text_input("API token", type="password")

    submit_button = st.form_submit_button("Submit")

validate_submission(json_data)
user_info = whoami(token)
user_name = user_info["name"]