Sebastian Gehrmann commited on
Commit
bac5a97
1 Parent(s): d822486

frame for context

Browse files
Files changed (1) hide show
  1. datacards/context.py +45 -4
datacards/context.py CHANGED
@@ -1,13 +1,54 @@
1
  import streamlit as st
2
 
3
- from .streamlit_utils import make_text_input
 
 
 
 
 
 
4
 
5
- N_FIELDS = 1
 
 
6
 
 
7
 
8
  def context_page():
9
- return None
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
 
11
 
12
  def context_summary():
13
- return None
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import streamlit as st
2
 
3
+ from .streamlit_utils import (
4
+ make_multiselect,
5
+ make_selectbox,
6
+ make_text_area,
7
+ make_text_input,
8
+ make_radio,
9
+ )
10
 
11
+ N_FIELDS_SOCIAL_IMPACT = 9
12
+ N_FIELDS_UNDERSERVED_COMMUNITIES = 8
13
+ N_FIELDS_BIASES= 3
14
 
15
+ N_FIELDS = N_FIELDS_SOCIAL_IMPACT + N_FIELDS_UNDERSERVED_COMMUNITIES + N_FIELDS_BIASES
16
 
17
  def context_page():
18
+ st.session_state.card_dict["context"] = st.session_state.card_dict.get(
19
+ "context", {}
20
+ )
21
+ with st.expander("Social Impact of the Dataset", expanded=False):
22
+ key_pref = ["context", "social-impact"]
23
+ st.session_state.card_dict["context"]["social-impact"] = st.session_state.card_dict[
24
+ "context"
25
+ ].get("social-impact", {})
26
+
27
+ with st.expander("Impact on Under-Served Communities", expanded=False):
28
+ key_pref = ["context", "underserved"]
29
+ st.session_state.card_dict["context"]["underserved"] = st.session_state.card_dict[
30
+ "context"
31
+ ].get("underserved", {})
32
+
33
+ with st.expander("Discussion of Biases", expanded=False):
34
+ key_pref = ["context", "biases"]
35
+ st.session_state.card_dict["context"]["biases"] = st.session_state.card_dict[
36
+ "context"
37
+ ].get("biases", {})
38
 
39
 
40
  def context_summary():
41
+ total_filled = sum(
42
+ [len(dct) for dct in st.session_state.card_dict.get("context", {}).values()]
43
+ )
44
+ with st.expander(
45
+ f"Dataset Overview Completion - {total_filled} of {N_FIELDS}", expanded=False
46
+ ):
47
+ completion_markdown = ""
48
+ completion_markdown += (
49
+ f"- **Overall competion:**\n - {total_filled} of {N_FIELDS} fields\n"
50
+ )
51
+ completion_markdown += f"- **Sub-section - Social Impact of the Dataset:**\n - {len(st.session_state.card_dict.get('context', {}).get('social-impact', {}))} of {N_FIELDS_SOCIAL_IMPACT} fields\n"
52
+ completion_markdown += f"- **Sub-section - Impact on Under-Served Communities:**\n - {len(st.session_state.card_dict.get('context', {}).get('underserved', {}))} of {N_FIELDS_UNDERSERVED_COMMUNITIES} fields\n"
53
+ completion_markdown += f"- **Sub-section - Discussion of Biases:**\n - {len(st.session_state.card_dict.get('context', {}).get('biases', {}))} of {N_FIELDS_BIASES} fields\n"
54
+ st.markdown(completion_markdown)