marcenacp commited on
Commit
8a5a6d8
·
1 Parent(s): c17d68e

Reapply "Deploy (see actual commits on https://github.com/mlcommons/croissant)."

Browse files

This reverts commit c17d68e2b1592c044819f021e0e97117db042fb9.

Files changed (8) hide show
  1. core/constants.py +2 -1
  2. core/state.py +21 -3
  3. events/rai.py +111 -0
  4. requirements.txt +1 -1
  5. views/load.py +1 -1
  6. views/metadata.py +0 -43
  7. views/rai.py +249 -0
  8. views/wizard.py +4 -0
core/constants.py CHANGED
@@ -34,7 +34,8 @@ OVERVIEW = "Overview"
34
  METADATA = "Metadata"
35
  RESOURCES = "Resources"
36
  RECORD_SETS = "Record Sets"
37
- TABS = [OVERVIEW, METADATA, RESOURCES, RECORD_SETS]
 
38
 
39
  NAMES_INFO = (
40
  "Names are used as identifiers. They are unique and cannot contain special"
 
34
  METADATA = "Metadata"
35
  RESOURCES = "Resources"
36
  RECORD_SETS = "Record Sets"
37
+ RAI = "Extension: Responsible AI"
38
+ TABS = [OVERVIEW, METADATA, RESOURCES, RECORD_SETS, RAI]
39
 
40
  NAMES_INFO = (
41
  "Names are used as identifiers. They are unique and cannot contain special"
core/state.py CHANGED
@@ -190,11 +190,29 @@ class Metadata(Node):
190
  description: str | None = None
191
  cite_as: str | None = None
192
  creators: list[mlc.Person] = dataclasses.field(default_factory=list)
193
- data_biases: str | None = None
194
- data_collection: str | None = None
195
  date_published: datetime.datetime | None = None
196
  license: str | None = ""
197
- personal_sensitive_information: str | None = None
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
198
  url: str = ""
199
  distribution: list[FileObject | FileSet] = dataclasses.field(default_factory=list)
200
  record_sets: list[RecordSet] = dataclasses.field(default_factory=list)
 
190
  description: str | None = None
191
  cite_as: str | None = None
192
  creators: list[mlc.Person] = dataclasses.field(default_factory=list)
 
 
193
  date_published: datetime.datetime | None = None
194
  license: str | None = ""
195
+ # RAI extension attributes
196
+ data_collection: str | None = None
197
+ data_collection_type: str | None = None
198
+ data_collection_missing_data: str | None = None
199
+ data_collection_raw_data: str | None = None
200
+ data_collection_timeframe: datetime.datetime | None = None
201
+ data_imputation_protocol: str | None = None
202
+ data_preprocessing_protocol: list[str] = None
203
+ data_manipulation_protocol: str | None = None
204
+ data_annotation_protocol: str | None = None
205
+ data_annotation_platform: str | None = None
206
+ data_annotation_analysis: str | None = None
207
+ annotation_per_item: str | None = None
208
+ annotator_demographics: str | None = None
209
+ machine_annotation_tools: str | None = None
210
+ data_biases: list[str] = None
211
+ data_use_cases: list[str] = None
212
+ data_limitations: list[str] = None
213
+ data_social_impact: str | None = None
214
+ personal_sensitive_information: list[str] = None
215
+ data_release_maintenance_plan: str | None = None
216
  url: str = ""
217
  distribution: list[FileObject | FileSet] = dataclasses.field(default_factory=list)
218
  record_sets: list[RecordSet] = dataclasses.field(default_factory=list)
events/rai.py ADDED
@@ -0,0 +1,111 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import datetime
2
+ import enum
3
+
4
+ import streamlit as st
5
+
6
+ from core.names import find_unique_name
7
+ from core.state import Metadata
8
+ import mlcroissant as mlc
9
+
10
+
11
+ class RaiEvent(enum.Enum):
12
+ """Event that triggers a Rai change."""
13
+
14
+ RAI_DATA_COLLECTION = "RAI_DATA_COLLECTION"
15
+ RAI_DATA_COLLECTION_TYPE = "RAI_DATA_COLLECTION_TYPE"
16
+ RAI_DATA_COLLECTION_MISSING_DATA = "RAI_DATA_COLLECTION_MISSING_DATA"
17
+ RAI_DATA_COLLECTION_RAW = "RAI_DATA_COLLECTION_RAW"
18
+ RAI_DATA_COLLECTION_TIMEFRAME = "RAI_DATA_COLLECTION_TIMEFRAME"
19
+ RAI_DATA_IMPUTATION_PROTOCOL = "RAI_DATA_IMPUTATION_PROTOCOL"
20
+ RAI_DATA_PREPROCESSING_PROTOCOL = " RAI_DATA_PREPROCESSING_PROTOCOL"
21
+ RAI_DATA_MANIPULATION_PROTOCOL = "RAI_DATA_MANIPULATION_PROTOCOL"
22
+ RAI_DATA_ANNOTATION_PROTOCOL = "RAI_DATA_ANNOTATION_PROTOCOL"
23
+ RAI_DATA_ANNOTATION_PLATFORM = "RAI_DATA_ANNOTATION_PLATFORM"
24
+ RAI_DATA_ANNOTATION_ANALYSIS = "RAI_DATA_ANNOTATION_ANALYSIS"
25
+ RAI_DATA_ANNOTATION_PER_ITEM = "RAI_DATA_ANNOTATION_PERI_TEM"
26
+ RAI_DATA_ANNOTATION_DEMOGRAPHICS = "RAI_DATA_ANNOTATION_DEMOGRAPHICS"
27
+ RAI_DATA_ANNOTATION_TOOLS = "RAI_DATA_ANNOTATION_TOOLS"
28
+ RAI_DATA_USE_CASES = "RAI_DATA_USECASES"
29
+ RAI_DATA_BIAS = "RAI_DATA_BIAS"
30
+ RAI_DATA_LIMITATION = "RAI_DATA_LIMITATION"
31
+ RAI_DATA_SOCIAL_IMPACT = "RAI_DATA_SOCIAL_IMPACT"
32
+ RAI_SENSITIVE = "RAI_SENSITIVE"
33
+ RAI_MAINTENANCE = "RAI_MAINTENANCE"
34
+
35
+
36
+ def handle_rai_change(event: RaiEvent, metadata: Metadata, key: str, index: int = 0):
37
+ ## If widget is 1-to-many we first get the index to proper update them
38
+ if event == RaiEvent.RAI_DATA_COLLECTION:
39
+ metadata.data_collection = st.session_state[key]
40
+ if event == RaiEvent.RAI_DATA_COLLECTION_TYPE:
41
+ metadata.data_collection_type = st.session_state[key]
42
+ if event == RaiEvent.RAI_DATA_COLLECTION_MISSING_DATA:
43
+ metadata.data_collection_missing_data = st.session_state[key]
44
+ if event == RaiEvent.RAI_DATA_COLLECTION_RAW:
45
+ metadata.data_collection_raw_data = st.session_state[key]
46
+ if event == RaiEvent.RAI_DATA_COLLECTION_TIMEFRAME:
47
+ # To do
48
+ raise NotImplementedError(
49
+ "Data collectiom timeframe range still not implemented"
50
+ )
51
+ pass
52
+ if event == RaiEvent.RAI_DATA_IMPUTATION_PROTOCOL:
53
+ metadata.data_imputation_protocol = st.session_state[key]
54
+ if event == RaiEvent.RAI_DATA_PREPROCESSING_PROTOCOL:
55
+ if metadata.data_preprocessing_protocol:
56
+ metadata.data_preprocessing_protocol[index] = st.session_state[key]
57
+ else:
58
+ metadata.data_preprocessing_protocol = []
59
+ metadata.data_preprocessing_protocol.append(st.session_state[key])
60
+ if event == RaiEvent.RAI_DATA_MANIPULATION_PROTOCOL:
61
+ metadata.data_manipulation_protocol = st.session_state[key]
62
+ if event == RaiEvent.RAI_DATA_ANNOTATION_PROTOCOL:
63
+
64
+ metadata.data_annotation_protocol = st.session_state[key]
65
+ if event == RaiEvent.RAI_DATA_ANNOTATION_PLATFORM:
66
+ metadata.data_annotation_platform = st.session_state[key]
67
+ if event == RaiEvent.RAI_DATA_ANNOTATION_ANALYSIS:
68
+ metadata.data_annotation_analysis = st.session_state[key]
69
+ if event == RaiEvent.RAI_DATA_ANNOTATION_PER_ITEM:
70
+ metadata.annotation_per_item = st.session_state[key]
71
+ if event == RaiEvent.RAI_DATA_ANNOTATION_DEMOGRAPHICS:
72
+ metadata.annotator_demographics = st.session_state[key]
73
+ if event == RaiEvent.RAI_DATA_ANNOTATION_TOOLS:
74
+ metadata.machine_annotation_tools = st.session_state[key]
75
+ if event == RaiEvent.RAI_DATA_USE_CASES:
76
+
77
+ if metadata.data_use_cases:
78
+ metadata.data_use_cases[int(index)] = st.session_state[key]
79
+ else:
80
+ metadata.data_use_cases = []
81
+ metadata.data_use_cases.append(st.session_state[key])
82
+
83
+ if event == RaiEvent.RAI_DATA_BIAS:
84
+
85
+ if metadata.data_biases:
86
+ metadata.data_biases[int(index)] = st.session_state[key]
87
+ else:
88
+ metadata.data_biases = []
89
+ metadata.data_biases.append(st.session_state[key])
90
+
91
+ if event == RaiEvent.RAI_DATA_LIMITATION:
92
+ if metadata.data_limitations:
93
+ metadata.data_limitations[int(index)] = st.session_state[key]
94
+ else:
95
+ metadata.data_limitations = []
96
+ metadata.data_limitations.append(st.session_state[key])
97
+ if event == RaiEvent.RAI_DATA_SOCIAL_IMPACT:
98
+ metadata.data_social_impact = st.session_state[key]
99
+ if event == RaiEvent.RAI_SENSITIVE:
100
+
101
+ if metadata.personal_sensitive_information:
102
+ metadata.personal_sensitive_information[int(index)] = st.session_state[key]
103
+ else:
104
+ metadata.personal_sensitive_information = []
105
+ metadata.personal_sensitive_information.append(st.session_state[key])
106
+ if event == RaiEvent.RAI_MAINTENANCE:
107
+ metadata.data_release_maintenance_plan = st.session_state[key]
108
+
109
+
110
+ def get_widget_cadinality(key: str):
111
+ return key.split("_")[-1]
requirements.txt CHANGED
@@ -1,5 +1,5 @@
1
  etils[epath]
2
- mlcroissant==1.0.3
3
  numpy
4
  pandas
5
  pytest
 
1
  etils[epath]
2
+ mlcroissant
3
  numpy
4
  pandas
5
  pytest
views/load.py CHANGED
@@ -16,7 +16,7 @@ HTML.
16
  - [OpenML](https://www.openml.org/search?type=data) offers a 🥐 button on all of their
17
  datasets.
18
  - [Hugging Face](https://huggingface.co/) offers an
19
- [API endpoint](https://datasets-server.huggingface.co/croissant?dataset=${dataset_id) to
20
  build a Croissant JSON-LD."""
21
 
22
 
 
16
  - [OpenML](https://www.openml.org/search?type=data) offers a 🥐 button on all of their
17
  datasets.
18
  - [Hugging Face](https://huggingface.co/) offers an
19
+ [API endpoint](https://huggingface.co/docs/datasets-server/croissant) to
20
  build a Croissant JSON-LD."""
21
 
22
 
views/metadata.py CHANGED
@@ -14,49 +14,6 @@ def render_metadata():
14
  col1, col2 = st.columns([1, 1])
15
  with col1.expander("**Generic metadata**", expanded=True):
16
  _render_generic_metadata(metadata)
17
- with col2.expander("**Responsible AI (RAI) metadata**", expanded=True):
18
- _render_rai_metadata(metadata)
19
-
20
-
21
- def _render_rai_metadata(metadata: Metadata):
22
- """Renders RAI (Responsible AI) metadata."""
23
- key = "metadata-data-collection"
24
- st.text_area(
25
- label=(
26
- "**Data collection**. Key stages of the data collection process encourage"
27
- " its creators to reflect on the process and improves understanding for"
28
- " users."
29
- ),
30
- key=key,
31
- value=metadata.data_collection,
32
- on_change=handle_metadata_change,
33
- args=(MetadataEvent.DATA_COLLECTION, metadata, key),
34
- )
35
- key = "metadata-data-biases"
36
- st.text_area(
37
- label=(
38
- "**Data biases**. Involves understanding the potential risks associated"
39
- " with data usage and to prevent unintended and potentially harmful"
40
- " consequences that may arise from using models trained on or evaluated"
41
- " with the respective data."
42
- ),
43
- key=key,
44
- value=metadata.data_biases,
45
- on_change=handle_metadata_change,
46
- args=(MetadataEvent.DATA_BIASES, metadata, key),
47
- )
48
- key = "metadata-personal-sensitive-information"
49
- st.text_area(
50
- label=(
51
- "**Personal sensitive information**. Personal and sensitive information, if"
52
- " contained within the dataset, can play an important role in the"
53
- " mitigation of any risks and the responsible use of the datasets."
54
- ),
55
- key=key,
56
- value=metadata.personal_sensitive_information,
57
- on_change=handle_metadata_change,
58
- args=(MetadataEvent.PERSONAL_SENSITIVE_INFORMATION, metadata, key),
59
- )
60
 
61
 
62
  def _render_generic_metadata(metadata: Metadata):
 
14
  col1, col2 = st.columns([1, 1])
15
  with col1.expander("**Generic metadata**", expanded=True):
16
  _render_generic_metadata(metadata)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
17
 
18
 
19
  def _render_generic_metadata(metadata: Metadata):
views/rai.py ADDED
@@ -0,0 +1,249 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+
3
+ from core.state import Metadata
4
+ from events.metadata import find_license_index
5
+ from events.metadata import LICENSES
6
+ from events.metadata import LICENSES_URL
7
+ from events.rai import handle_rai_change
8
+ from events.rai import RaiEvent
9
+
10
+ _INFO_TEXT = """This tab is the Responsible AI extension of Croissant. **Filling this tab is optional.**
11
+
12
+ More information on how to fill this part at: http://mlcommons.org/croissant/RAI/
13
+ """
14
+
15
+
16
+ def render_rai_metadata():
17
+ """Renders the `Metadata` view."""
18
+ metadata: Metadata = st.session_state[Metadata]
19
+ st.info(_INFO_TEXT, icon="💡")
20
+ col1, col2 = st.columns([1, 1])
21
+ with col1.expander("**Provenance**", expanded=True):
22
+ with st.expander("**Data Collection**", expanded=False):
23
+ key = "metadata-data-collection"
24
+ st.text_area(
25
+ label=("Explanation"),
26
+ placeholder="Explain the key stages of the data collection process to improves understanding of potential users",
27
+ key=key,
28
+ value=metadata.data_collection,
29
+ on_change=handle_rai_change,
30
+ args=(RaiEvent.RAI_DATA_COLLECTION, metadata, key),
31
+ )
32
+ key = "metadata-data-collection-type"
33
+ st.text_area(
34
+ label=(
35
+ "Define the data collection type. Recommended values Recommended values: Surveys, Secondary Data analysis, Physical data collection, Direct measurement, Document analysis, Manual Human Curator, Software Collection, Experiments, Web Scraping, Web API, Focus groups, Self-reporting, Customer feedback data, User-generated content data, Passive Data Collection, Others"
36
+ ),
37
+ key=key,
38
+ value=metadata.data_collection_type,
39
+ on_change=handle_rai_change,
40
+ args=(RaiEvent.RAI_DATA_COLLECTION_TYPE, metadata, key),
41
+ )
42
+ key = "metadata-data-collection-missing"
43
+ st.text_area(
44
+ label=("**Missing Data**."),
45
+ key=key,
46
+ placeholder="Description of missing data in structured/unstructured form",
47
+ value=metadata.data_collection_missing_data,
48
+ on_change=handle_rai_change,
49
+ args=(RaiEvent.RAI_DATA_COLLECTION_MISSING_DATA, metadata, key),
50
+ )
51
+ key = "metadata-data-collection-raw"
52
+ st.text_area(
53
+ label=("**Raw Data**."),
54
+ key=key,
55
+ placeholder="Description of the raw data i.e. source of the data ",
56
+ value=metadata.data_collection_raw_data,
57
+ on_change=handle_rai_change,
58
+ args=(RaiEvent.RAI_DATA_COLLECTION_RAW, metadata, key),
59
+ )
60
+ with st.expander("**Data Annotation**", expanded=False):
61
+ key = "metadata-data-annotation-protocol"
62
+ st.text_area(
63
+ label=(
64
+ "**Protocol**. Description of annotations (labels, ratings) produced, including how these were created or authored - Annotation Workforce Type, Annotation Characteristic(s), Annotation Description(s), Annotation Task(s), Annotation Distribution(s)"
65
+ ),
66
+ key=key,
67
+ value=metadata.data_annotation_protocol,
68
+ on_change=handle_rai_change,
69
+ args=(RaiEvent.RAI_DATA_ANNOTATION_PROTOCOL, metadata, key),
70
+ )
71
+ key = "metadata-data-annotation-platform"
72
+ st.text_area(
73
+ label=(
74
+ "**Platform**. Platform, tool, or library used to collect annotations by human annotators"
75
+ ),
76
+ key=key,
77
+ value=metadata.data_annotation_platform,
78
+ on_change=handle_rai_change,
79
+ args=(RaiEvent.RAI_DATA_ANNOTATION_PLATFORM, metadata, key),
80
+ )
81
+ key = "metadata-data-annotation-analysis"
82
+ st.text_area(
83
+ label=(
84
+ "**Analysis**. Considerations related to the process of converting the “raw” annotations into the labels that are ultimately packaged in a dataset - Uncertainty or disagreement between annotations on each instance as a signal in the dataset, analysis of systematic disagreements between annotators of different socio demographic group, how the final dataset annotations will relate to individual annotator responses"
85
+ ),
86
+ key=key,
87
+ value=metadata.data_annotation_analysis,
88
+ on_change=handle_rai_change,
89
+ args=(RaiEvent.RAI_DATA_ANNOTATION_ANALYSIS, metadata, key),
90
+ )
91
+ key = "metadata-data-annotation-demographics"
92
+ st.text_area(
93
+ label=(
94
+ "**Demographics**. List of demographics specifications about the annotators"
95
+ ),
96
+ key=key,
97
+ value=metadata.annotator_demographics,
98
+ on_change=handle_rai_change,
99
+ args=(RaiEvent.RAI_DATA_ANNOTATION_DEMOGRAPHICS, metadata, key),
100
+ )
101
+ key = "metadata-data-annotation-tools"
102
+ st.text_area(
103
+ label=(
104
+ "**Tools**. List of software used for data annotation ( e.g. concept extraction, NER, and additional characteristics of the tools used for annotation to allow for replication or extension) "
105
+ ),
106
+ key=key,
107
+ value=metadata.machine_annotation_tools,
108
+ on_change=handle_rai_change,
109
+ args=(RaiEvent.RAI_DATA_ANNOTATION_TOOLS, metadata, key),
110
+ )
111
+ key = "metadata-data-annotation-per-item"
112
+ st.text_area(
113
+ label=(
114
+ "**Annotation per item**. Number of human labels per dataset item "
115
+ ),
116
+ key=key,
117
+ value=metadata.annotation_per_item,
118
+ on_change=handle_rai_change,
119
+ args=(RaiEvent.RAI_DATA_ANNOTATION_PER_ITEM, metadata, key),
120
+ )
121
+ with st.expander("**Data Preprocessing**", expanded=False):
122
+ one_to_many_property(
123
+ title="**Protocols**",
124
+ metadata=metadata,
125
+ attributes=metadata.data_preprocessing_protocol,
126
+ key="metadata-data-preprocessing-protocol_",
127
+ label="Description of data manipulation process if applicable ",
128
+ event=RaiEvent.RAI_DATA_PREPROCESSING_PROTOCOL,
129
+ )
130
+
131
+ key = "metadata-data-manipulation-protocol"
132
+ st.text_area(
133
+ label=(
134
+ "**Manipulation**. Description of data manipulation process if applicable "
135
+ ),
136
+ key=key,
137
+ value=metadata.data_manipulation_protocol,
138
+ on_change=handle_rai_change,
139
+ args=(RaiEvent.RAI_DATA_MANIPULATION_PROTOCOL, metadata, key),
140
+ )
141
+ key = "metadata-data-imputation-protocol"
142
+ st.text_area(
143
+ label=(
144
+ "**Imputation**. Description of data imputation process if applicable "
145
+ ),
146
+ key=key,
147
+ value=metadata.data_imputation_protocol,
148
+ on_change=handle_rai_change,
149
+ args=(RaiEvent.RAI_DATA_IMPUTATION_PROTOCOL, metadata, key),
150
+ )
151
+
152
+ with col2.expander("**Data uses and social impact**", expanded=True):
153
+ one_to_many_property(
154
+ title="**Use cases**",
155
+ metadata=metadata,
156
+ attributes=metadata.data_use_cases,
157
+ key="metadata-data-use-cases_",
158
+ label="Dataset use case - training, testing, validation, development or production use, fine tuning, others (please specify), usage guidelines, recommended uses, etc.",
159
+ event=RaiEvent.RAI_DATA_USE_CASES,
160
+ )
161
+
162
+ one_to_many_property(
163
+ title="**Data biases**",
164
+ metadata=metadata,
165
+ attributes=metadata.data_biases,
166
+ key="metadata-data-biases_",
167
+ label="**Data biases**. Involves understanding the potential risks associated with data usage and to prevent unintended and potentially harmful consequences that may arise from using models trained on or evaluated with the respective data",
168
+ event=RaiEvent.RAI_DATA_BIAS,
169
+ )
170
+
171
+ one_to_many_property(
172
+ title="**Personal and sensitive information**",
173
+ metadata=metadata,
174
+ attributes=metadata.personal_sensitive_information,
175
+ key="metadata-personal-sensitive-information_",
176
+ label="Personal and sensitive information, if contained within the dataset, can play an important role in the mitigation of any risks and the responsible use of the datasets",
177
+ event=RaiEvent.RAI_SENSITIVE,
178
+ )
179
+
180
+ key = "metadata-social-impact"
181
+ st.text_area(
182
+ label=("**Social impact**. Discussion of social impact, if applicable"),
183
+ key=key,
184
+ value=metadata.data_social_impact,
185
+ on_change=handle_rai_change,
186
+ args=(RaiEvent.RAI_DATA_SOCIAL_IMPACT, metadata, key),
187
+ )
188
+
189
+ one_to_many_property(
190
+ "**Data limitations**",
191
+ metadata,
192
+ metadata.data_limitations,
193
+ "metadata-data-limitations_",
194
+ "Known limitations - Data generalization limits (e.g related to data distribution, data quality issues, or data sources) and on-recommended uses.",
195
+ RaiEvent.RAI_DATA_LIMITATION,
196
+ )
197
+
198
+ key = "metadata-data-maintenance"
199
+ st.text_area(
200
+ label=(
201
+ "**Data release maintenance**. Versioning information in terms of the updating timeframe, the maintainers, and the deprecation policies. "
202
+ ),
203
+ key=key,
204
+ value=metadata.data_release_maintenance_plan,
205
+ on_change=handle_rai_change,
206
+ args=(RaiEvent.RAI_MAINTENANCE, metadata, key),
207
+ )
208
+
209
+
210
+ def one_to_many_property(
211
+ title: str, metadata: Metadata, attributes, key: str, label: str, event: str
212
+ ):
213
+ """Generates a one to many cardinality property. Attributes should be empty, have one element or being a list of elements"""
214
+ with st.expander(title, expanded=True):
215
+ if attributes:
216
+ if not isinstance(attributes, list):
217
+ attributes = [attributes]
218
+ for index, single_attribute in enumerate(attributes):
219
+ key = key + str(index)
220
+ st.text_area(
221
+ label=(label),
222
+ key=key,
223
+ value=single_attribute,
224
+ on_change=handle_rai_change,
225
+ args=(event, metadata, key, index),
226
+ )
227
+ else:
228
+ key = key + "0"
229
+ st.text_area(
230
+ label=(label),
231
+ key=key,
232
+ on_change=handle_rai_change,
233
+ args=(event, metadata, key),
234
+ )
235
+ add, remove = st.columns(2)
236
+ with add:
237
+ if st.button("+ add", key=key + "add"):
238
+ if attributes:
239
+ attributes.append("")
240
+ st.rerun()
241
+ else:
242
+ attributes = []
243
+ attributes.append("")
244
+ st.rerun()
245
+ with remove:
246
+ if st.button("- remove", key=key + "remove"):
247
+ if attributes:
248
+ attributes.pop()
249
+ st.rerun()
views/wizard.py CHANGED
@@ -9,6 +9,7 @@ from core.constants import OVERVIEW
9
  from core.constants import RECORD_SETS
10
  from core.constants import RESOURCES
11
  from core.constants import TABS
 
12
  from core.past_projects import save_current_project
13
  from core.state import get_tab
14
  from core.state import Metadata
@@ -18,6 +19,7 @@ from views.files import render_files
18
  from views.metadata import render_metadata
19
  from views.overview import render_overview
20
  from views.record_sets import render_record_sets
 
21
 
22
 
23
  def _export_json() -> str | None:
@@ -49,5 +51,7 @@ def render_editor():
49
  render_files()
50
  elif tab == RECORD_SETS:
51
  render_record_sets()
 
 
52
  save_current_project()
53
  set_tab(tab)
 
9
  from core.constants import RECORD_SETS
10
  from core.constants import RESOURCES
11
  from core.constants import TABS
12
+ from core.constants import RAI
13
  from core.past_projects import save_current_project
14
  from core.state import get_tab
15
  from core.state import Metadata
 
19
  from views.metadata import render_metadata
20
  from views.overview import render_overview
21
  from views.record_sets import render_record_sets
22
+ from views.rai import render_rai_metadata
23
 
24
 
25
  def _export_json() -> str | None:
 
51
  render_files()
52
  elif tab == RECORD_SETS:
53
  render_record_sets()
54
+ elif tab == RAI:
55
+ render_rai_metadata()
56
  save_current_project()
57
  set_tab(tab)