solidprivacy-nl commited on
Commit
fb11e5b
·
1 Parent(s): cf426cd

Patch review workflow with v12.4 guidance text

Browse files
Files changed (1) hide show
  1. fix_streamlit_nested_expanders.py +96 -6
fix_streamlit_nested_expanders.py CHANGED
@@ -9,6 +9,7 @@ Patches currently applied:
9
  - v12.1: add a user-facing review status model to the replacement table.
10
  - v12.2: add safe review-focus filters without changing export semantics.
11
  - v12.3: simplify the main review table and move audit details to a technical view.
 
12
  """
13
 
14
  from pathlib import Path
@@ -41,30 +42,68 @@ nested_new = ''' st.markdown("**Woordenlijsten**")
41
 
42
  text = replace_once(text, nested_old, nested_new)
43
 
44
- # v12.1/v12.2/v12.3: import review helpers.
45
  text = replace_once(
46
  text,
47
  'from display_labels_nl import entity_label, source_label, confidence_label\n',
48
  'from display_labels_nl import entity_label, source_label, confidence_label\n'
49
  'from review_status import review_status_for_source, review_status_label, review_status_order\n'
50
  'from review_filters import REVIEW_FILTER_OPTIONS, FILTER_SHOW_ALL, filter_review_dataframe\n'
51
- 'from review_table_config import main_review_columns, technical_display_columns\n',
 
 
 
 
 
 
 
 
52
  )
53
 
54
- # If v12.1 already added review_status but v12.2/v12.3 is not present yet, extend imports only.
55
  text = replace_once(
56
  text,
57
  'from review_status import review_status_for_source, review_status_label, review_status_order\n',
58
  'from review_status import review_status_for_source, review_status_label, review_status_order\n'
59
  'from review_filters import REVIEW_FILTER_OPTIONS, FILTER_SHOW_ALL, filter_review_dataframe\n'
60
- 'from review_table_config import main_review_columns, technical_display_columns\n',
 
 
 
 
 
 
 
 
61
  )
62
 
63
  text = replace_once(
64
  text,
65
  'from review_filters import REVIEW_FILTER_OPTIONS, FILTER_SHOW_ALL, filter_review_dataframe\n',
66
  'from review_filters import REVIEW_FILTER_OPTIONS, FILTER_SHOW_ALL, filter_review_dataframe\n'
 
 
 
 
 
 
 
 
 
 
 
 
 
67
  'from review_table_config import main_review_columns, technical_display_columns\n',
 
 
 
 
 
 
 
 
 
68
  )
69
 
70
  # v12.1: add review status fields to remembered rows.
@@ -131,13 +170,19 @@ text = replace_once(
131
  ''',
132
  )
133
 
134
- # v12.1/v12.2/v12.3: sort review rows, show status summary, focus filters and technical view.
135
  text = replace_once(
136
  text,
137
  ''' replacement_editor_df = pd.DataFrame(default_editor_rows)
138
  edited_replacements_df = st.data_editor(
139
  ''',
140
  ''' replacement_editor_df = pd.DataFrame(default_editor_rows)
 
 
 
 
 
 
141
  if "review_order" in replacement_editor_df.columns:
142
  replacement_editor_df = replacement_editor_df.sort_values(
143
  by=["review_order", "type_label", "find"], kind="stable"
@@ -151,7 +196,7 @@ text = replace_once(
151
  "Focusfilter voor controle",
152
  REVIEW_FILTER_OPTIONS,
153
  index=REVIEW_FILTER_OPTIONS.index(FILTER_SHOW_ALL),
154
- help="Gebruik dit als overzichtsfilter. De volledige vervangtabel hieronder blijft leidend voor de export.",
155
  )
156
  if review_filter != FILTER_SHOW_ALL:
157
  focus_df = filter_review_dataframe(replacement_editor_df, review_filter)
@@ -162,6 +207,7 @@ text = replace_once(
162
  )
163
  st.caption("Pas wijzigingen toe in de volledige vervangtabel hieronder; dit focusoverzicht is alleen bedoeld om sneller te controleren.")
164
  with st.expander("Technische details bij de vervangtabel", expanded=False):
 
165
  technical_columns = technical_display_columns(replacement_editor_df.columns)
166
  if technical_columns:
167
  st.dataframe(replacement_editor_df[technical_columns], use_container_width=True)
@@ -171,6 +217,40 @@ text = replace_once(
171
  ''',
172
  )
173
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
174
  # v12.1: make status visible in the editor.
175
  text = replace_once(
176
  text,
@@ -223,6 +303,16 @@ text = replace_once(
223
  ''',
224
  )
225
 
 
 
 
 
 
 
 
 
 
 
226
  # v12.1: include status in the scrub report rows where downstream exporters keep it.
227
  text = replace_once(
228
  text,
 
9
  - v12.1: add a user-facing review status model to the replacement table.
10
  - v12.2: add safe review-focus filters without changing export semantics.
11
  - v12.3: simplify the main review table and move audit details to a technical view.
12
+ - v12.4: add clear review guidance text around the review workflow.
13
  """
14
 
15
  from pathlib import Path
 
42
 
43
  text = replace_once(text, nested_old, nested_new)
44
 
45
+ # v12.1/v12.2/v12.3/v12.4: import review helpers.
46
  text = replace_once(
47
  text,
48
  'from display_labels_nl import entity_label, source_label, confidence_label\n',
49
  'from display_labels_nl import entity_label, source_label, confidence_label\n'
50
  'from review_status import review_status_for_source, review_status_label, review_status_order\n'
51
  'from review_filters import REVIEW_FILTER_OPTIONS, FILTER_SHOW_ALL, filter_review_dataframe\n'
52
+ 'from review_table_config import main_review_columns, technical_display_columns\n'
53
+ 'from review_guidance import (\n'
54
+ ' REVIEW_INTRO_GUIDANCE,\n'
55
+ ' CANDIDATE_GUIDANCE,\n'
56
+ ' FOCUS_FILTER_GUIDANCE,\n'
57
+ ' TECHNICAL_DETAILS_GUIDANCE,\n'
58
+ ' AI_USAGE_GUIDANCE,\n'
59
+ ' EXPORT_GUIDANCE,\n'
60
+ ')\n',
61
  )
62
 
63
+ # If v12.1 already added review_status but v12.2/v12.3/v12.4 is not present yet, extend imports only.
64
  text = replace_once(
65
  text,
66
  'from review_status import review_status_for_source, review_status_label, review_status_order\n',
67
  'from review_status import review_status_for_source, review_status_label, review_status_order\n'
68
  'from review_filters import REVIEW_FILTER_OPTIONS, FILTER_SHOW_ALL, filter_review_dataframe\n'
69
+ 'from review_table_config import main_review_columns, technical_display_columns\n'
70
+ 'from review_guidance import (\n'
71
+ ' REVIEW_INTRO_GUIDANCE,\n'
72
+ ' CANDIDATE_GUIDANCE,\n'
73
+ ' FOCUS_FILTER_GUIDANCE,\n'
74
+ ' TECHNICAL_DETAILS_GUIDANCE,\n'
75
+ ' AI_USAGE_GUIDANCE,\n'
76
+ ' EXPORT_GUIDANCE,\n'
77
+ ')\n',
78
  )
79
 
80
  text = replace_once(
81
  text,
82
  'from review_filters import REVIEW_FILTER_OPTIONS, FILTER_SHOW_ALL, filter_review_dataframe\n',
83
  'from review_filters import REVIEW_FILTER_OPTIONS, FILTER_SHOW_ALL, filter_review_dataframe\n'
84
+ 'from review_table_config import main_review_columns, technical_display_columns\n'
85
+ 'from review_guidance import (\n'
86
+ ' REVIEW_INTRO_GUIDANCE,\n'
87
+ ' CANDIDATE_GUIDANCE,\n'
88
+ ' FOCUS_FILTER_GUIDANCE,\n'
89
+ ' TECHNICAL_DETAILS_GUIDANCE,\n'
90
+ ' AI_USAGE_GUIDANCE,\n'
91
+ ' EXPORT_GUIDANCE,\n'
92
+ ')\n',
93
+ )
94
+
95
+ text = replace_once(
96
+ text,
97
  'from review_table_config import main_review_columns, technical_display_columns\n',
98
+ 'from review_table_config import main_review_columns, technical_display_columns\n'
99
+ 'from review_guidance import (\n'
100
+ ' REVIEW_INTRO_GUIDANCE,\n'
101
+ ' CANDIDATE_GUIDANCE,\n'
102
+ ' FOCUS_FILTER_GUIDANCE,\n'
103
+ ' TECHNICAL_DETAILS_GUIDANCE,\n'
104
+ ' AI_USAGE_GUIDANCE,\n'
105
+ ' EXPORT_GUIDANCE,\n'
106
+ ')\n',
107
  )
108
 
109
  # v12.1: add review status fields to remembered rows.
 
170
  ''',
171
  )
172
 
173
+ # v12.1/v12.2/v12.3/v12.4: sort review rows, show guidance/status summary, focus filters and technical view.
174
  text = replace_once(
175
  text,
176
  ''' replacement_editor_df = pd.DataFrame(default_editor_rows)
177
  edited_replacements_df = st.data_editor(
178
  ''',
179
  ''' replacement_editor_df = pd.DataFrame(default_editor_rows)
180
+ st.info(REVIEW_INTRO_GUIDANCE)
181
+ with st.expander("Uitleg bij deze controle", expanded=False):
182
+ st.markdown(f"- {CANDIDATE_GUIDANCE}")
183
+ st.markdown(f"- {FOCUS_FILTER_GUIDANCE}")
184
+ st.markdown(f"- {TECHNICAL_DETAILS_GUIDANCE}")
185
+ st.markdown(f"- {AI_USAGE_GUIDANCE}")
186
  if "review_order" in replacement_editor_df.columns:
187
  replacement_editor_df = replacement_editor_df.sort_values(
188
  by=["review_order", "type_label", "find"], kind="stable"
 
196
  "Focusfilter voor controle",
197
  REVIEW_FILTER_OPTIONS,
198
  index=REVIEW_FILTER_OPTIONS.index(FILTER_SHOW_ALL),
199
+ help=FOCUS_FILTER_GUIDANCE,
200
  )
201
  if review_filter != FILTER_SHOW_ALL:
202
  focus_df = filter_review_dataframe(replacement_editor_df, review_filter)
 
207
  )
208
  st.caption("Pas wijzigingen toe in de volledige vervangtabel hieronder; dit focusoverzicht is alleen bedoeld om sneller te controleren.")
209
  with st.expander("Technische details bij de vervangtabel", expanded=False):
210
+ st.caption(TECHNICAL_DETAILS_GUIDANCE)
211
  technical_columns = technical_display_columns(replacement_editor_df.columns)
212
  if technical_columns:
213
  st.dataframe(replacement_editor_df[technical_columns], use_container_width=True)
 
217
  ''',
218
  )
219
 
220
+ # v12.4: if v12.1/v12.2/v12.3 block is already present, add guidance to that block.
221
+ text = replace_once(
222
+ text,
223
+ ''' replacement_editor_df = pd.DataFrame(default_editor_rows)
224
+ if "review_order" in replacement_editor_df.columns:
225
+ ''',
226
+ ''' replacement_editor_df = pd.DataFrame(default_editor_rows)
227
+ st.info(REVIEW_INTRO_GUIDANCE)
228
+ with st.expander("Uitleg bij deze controle", expanded=False):
229
+ st.markdown(f"- {CANDIDATE_GUIDANCE}")
230
+ st.markdown(f"- {FOCUS_FILTER_GUIDANCE}")
231
+ st.markdown(f"- {TECHNICAL_DETAILS_GUIDANCE}")
232
+ st.markdown(f"- {AI_USAGE_GUIDANCE}")
233
+ if "review_order" in replacement_editor_df.columns:
234
+ ''',
235
+ )
236
+
237
+ text = replace_once(
238
+ text,
239
+ ' help="Gebruik dit als overzichtsfilter. De volledige vervangtabel hieronder blijft leidend voor de export.",\n',
240
+ ' help=FOCUS_FILTER_GUIDANCE,\n',
241
+ )
242
+
243
+ text = replace_once(
244
+ text,
245
+ ''' with st.expander("Technische details bij de vervangtabel", expanded=False):
246
+ technical_columns = technical_display_columns(replacement_editor_df.columns)
247
+ ''',
248
+ ''' with st.expander("Technische details bij de vervangtabel", expanded=False):
249
+ st.caption(TECHNICAL_DETAILS_GUIDANCE)
250
+ technical_columns = technical_display_columns(replacement_editor_df.columns)
251
+ ''',
252
+ )
253
+
254
  # v12.1: make status visible in the editor.
255
  text = replace_once(
256
  text,
 
303
  ''',
304
  )
305
 
306
+ # v12.4: add export guidance before downloads if a download section marker is present.
307
+ text = replace_once(
308
+ text,
309
+ ''' st.subheader("4. Download opgeschoonde bestanden")
310
+ ''',
311
+ ''' st.subheader("4. Download opgeschoonde bestanden")
312
+ st.warning(EXPORT_GUIDANCE)
313
+ ''',
314
+ )
315
+
316
  # v12.1: include status in the scrub report rows where downstream exporters keep it.
317
  text = replace_once(
318
  text,