File size: 3,011 Bytes
041af8a
 
 
cb5b71d
 
bbea1cc
dc92053
cb5b71d
 
041af8a
cb5b71d
 
 
 
 
bbea1cc
5a782ad
 
 
 
bbea1cc
 
cb5b71d
 
 
 
 
 
 
 
dc92053
 
 
cb5b71d
 
 
 
 
 
041af8a
 
0c5b67f
 
041af8a
 
 
 
dc92053
 
 
041af8a
 
0c5b67f
041af8a
 
 
 
 
0c5b67f
 
 
 
 
 
 
 
 
 
 
 
041af8a
0c5b67f
041af8a
 
0c5b67f
041af8a
cb5b71d
 
 
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
import logging

import requests
import streamlit as st

from core.constants import OAUTH_CLIENT_ID
from core.query_params import set_project
from core.state import CurrentProject
from core.state import Metadata
import mlcroissant as mlc
from views.load import render_load
from views.previous_files import render_previous_files


def render_splash():
    if OAUTH_CLIENT_ID:
        st.info(
            "**Disclaimer**: Do not put sensitive information or datasets here. The"
            " storage on Hugging Face Spaces is ephemeral. If you want to host your own"
            " version locally, build the app from [the GitHub"
            " repository](https://github.com/mlcommons/croissant/tree/main/editor)."
        )
    col1, col2 = st.columns([1, 1], gap="large")
    with col1:
        with st.expander("**Load an existing Croissant JSON-LD file**", expanded=True):
            render_load()
        with st.expander("**Create from scratch**", expanded=True):

            def create_new_croissant():
                st.session_state[Metadata] = Metadata()
                project = CurrentProject.create_new()
                st.session_state[CurrentProject] = project
                set_project(project)

            st.button(
                "Create",
                on_click=create_new_croissant,
                type="primary",
            )
        with st.expander("**Try out an example!**", expanded=True):

            def create_example(dataset: str):
                url = f"https://raw.githubusercontent.com/mlcommons/croissant/main/datasets/{dataset.lower()}/metadata.json"
                try:
                    json = requests.get(url).json()
                    metadata = mlc.Metadata.from_json(mlc.Issues(), json, None)
                    st.session_state[Metadata] = Metadata.from_canonical(metadata)
                    project = CurrentProject.create_new()
                    st.session_state[CurrentProject] = project
                    set_project(project)
                except Exception as exception:
                    logging.error(exception)
                    st.error(
                        "Sorry, it seems that the example is broken... Can you please"
                        " [open an issue on"
                        " GitHub](https://github.com/mlcommons/croissant/issues/new)?"
                    )

            dataset = st.selectbox(
                label="Dataset",
                options=[
                    "Titanic",
                    "FLORES-200",
                    "GPT-3",
                    "COCO2014",
                    "PASS",
                    "MovieLens",
                    "Bigcode-The-Stack",
                ],
            )
            st.button(
                f"{dataset} dataset",
                on_click=create_example,
                type="primary",
                args=(dataset,),
            )
    with col2:
        with st.expander("**Past projects**", expanded=True):
            render_previous_files()