Spaces:
Running
Running
Deploy (see actual commits on https://github.com/mlcommons/croissant).
Browse files- views/overview.py +31 -9
views/overview.py
CHANGED
@@ -27,6 +27,21 @@ be displayed on this page. Once you are ready, you can download the dataset by c
|
|
27 |
the export button in the upper right corner."""
|
28 |
|
29 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
def render_overview():
|
31 |
metadata: Metadata = st.session_state[Metadata]
|
32 |
col1, col2 = st.columns([1, 1], gap="medium")
|
@@ -52,15 +67,22 @@ def render_overview():
|
|
52 |
args=(MetadataEvent.DESCRIPTION, metadata, key),
|
53 |
)
|
54 |
st.divider()
|
55 |
-
|
56 |
-
fields =
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
64 |
with col2:
|
65 |
user_started_editing = metadata.record_sets or metadata.distribution
|
66 |
if user_started_editing:
|
|
|
27 |
the export button in the upper right corner."""
|
28 |
|
29 |
|
30 |
+
def _relevant_fields(class_or_instance: type):
|
31 |
+
if isinstance(class_or_instance, type):
|
32 |
+
return [
|
33 |
+
field.name
|
34 |
+
for field in dataclasses.fields(class_or_instance)
|
35 |
+
if field not in _NON_RELEVANT_METADATA
|
36 |
+
]
|
37 |
+
else:
|
38 |
+
return [
|
39 |
+
field
|
40 |
+
for field, value in dataclasses.asdict(class_or_instance).items()
|
41 |
+
if value and field not in _NON_RELEVANT_METADATA
|
42 |
+
]
|
43 |
+
|
44 |
+
|
45 |
def render_overview():
|
46 |
metadata: Metadata = st.session_state[Metadata]
|
47 |
col1, col2 = st.columns([1, 1], gap="medium")
|
|
|
67 |
args=(MetadataEvent.DESCRIPTION, metadata, key),
|
68 |
)
|
69 |
st.divider()
|
70 |
+
col_a, col_b, col_c, col_d = st.columns([1, 1, 1, 1])
|
71 |
+
fields = len(_relevant_fields(metadata))
|
72 |
+
metadata_weight = len(_relevant_fields(Metadata))
|
73 |
+
completion = int(
|
74 |
+
(
|
75 |
+
fields
|
76 |
+
+ (metadata_weight if metadata.distribution else 0)
|
77 |
+
+ (metadata_weight if metadata.record_sets else 0)
|
78 |
+
)
|
79 |
+
* 100
|
80 |
+
/ (3 * metadata_weight)
|
81 |
+
)
|
82 |
+
col_a.metric("Completion", f"{completion}%")
|
83 |
+
col_b.metric("Number of metadata", fields)
|
84 |
+
col_c.metric("Number of resources", len(metadata.distribution))
|
85 |
+
col_d.metric("Number of RecordSets", len(metadata.record_sets))
|
86 |
with col2:
|
87 |
user_started_editing = metadata.record_sets or metadata.distribution
|
88 |
if user_started_editing:
|