File size: 2,273 Bytes
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
import streamlit as st

from core.state import Metadata
import mlcroissant as mlc
from utils import needed_field
from views.metadata import handle_metadata_change
from views.metadata import MetadataEvent


def render_overview():
    metadata: Metadata = st.session_state[Metadata]
    col1, col2 = st.columns([1, 1], gap="medium")
    with col1:
        key = "metadata-name"
        st.text_input(
            label=needed_field("Name"),
            key=key,
            value=metadata.name,
            placeholder="Dataset",
            on_change=handle_metadata_change,
            args=(MetadataEvent.NAME, metadata, key),
        )
        key = "metadata-url"
        st.text_input(
            label=needed_field("URL"),
            key=key,
            value=metadata.url,
            placeholder="URL to the dataset.",
            on_change=handle_metadata_change,
            args=(MetadataEvent.URL, metadata, key),
        )
        key = "metadata-description"
        st.text_area(
            label="Description",
            key=key,
            value=metadata.description,
            placeholder="Provide a clear description of the dataset.",
            on_change=handle_metadata_change,
            args=(MetadataEvent.DESCRIPTION, metadata, key),
        )

        st.subheader(f"{len(metadata.distribution)} Files")
        st.subheader(f"{len(metadata.record_sets)} Record Sets")
    with col2:
        user_started_editing = metadata.record_sets or metadata.distribution
        if user_started_editing:
            st.subheader("Croissant File Validation")
            try:
                issues = metadata.to_canonical().issues
                if issues.errors:
                    st.markdown("##### Errors:")
                    for error in issues.errors:
                        st.write(error)
                if issues.warnings:
                    st.markdown("##### Warnings:")
                    for warning in issues.warnings:
                        st.write(warning)
                if not issues.errors and not issues.warnings:
                    st.write("No validation issues detected!")
            except mlc.ValidationError as exception:
                st.markdown("##### Errors:")
                st.write(str(exception))