rbiswasfc commited on
Commit
fa5f821
1 Parent(s): 9ef5e02
Files changed (2) hide show
  1. .gitignore +2 -0
  2. app.py +40 -37
.gitignore CHANGED
@@ -1 +1,3 @@
1
  .sesskey
 
 
 
1
  .sesskey
2
+ data
3
+ __pycache__
app.py CHANGED
@@ -113,11 +113,31 @@ def render_stats(stats):
113
 
114
  def render_example(example):
115
  return Div(
116
- H3("Example Details"),
117
  Table(
118
  *[Tr(Th(key), Td(str(value))) for key, value in example.items()],
119
  cls="example-table",
120
  ),
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
121
  id="example-details",
122
  )
123
 
@@ -131,7 +151,7 @@ def upload_to_hf():
131
  exist_ok=True,
132
  )
133
 
134
- examples = db.t.examples
135
  annotations = examples()
136
 
137
  hf_ds = Dataset.from_list(annotations)
@@ -161,25 +181,6 @@ def get(question_type: str = None):
161
  H2("Example"),
162
  Div(
163
  render_example(example),
164
- Form(
165
- Button(
166
- "Good Example",
167
- name="decision",
168
- value="good",
169
- hx_post="/evaluate",
170
- hx_target="#example-details",
171
- ),
172
- Button(
173
- "Bad Example",
174
- name="decision",
175
- value="bad",
176
- hx_post="/evaluate",
177
- hx_target="#example-details",
178
- ),
179
- # Hidden(name="example", value=json.dumps(example)),
180
- Hidden(name="example_id", value=str(example["example_id"])),
181
- id="evaluation-form",
182
- ),
183
  id="example-container",
184
  ),
185
  )
@@ -188,30 +189,17 @@ def get(question_type: str = None):
188
 
189
  return Titled(
190
  "Example Curation",
191
- H2("Question Type Selection"),
192
  dropdown,
193
  content,
 
194
  view_stats_link,
195
  )
196
 
197
 
198
- @rt("/stats")
199
- def get():
200
- stats = get_stats()
201
- stats = render_stats(stats)
202
-
203
- return Titled(
204
- "Curation Statistics",
205
- Div(
206
- stats,
207
- A("Back to Curation", href="/", cls="back-link"),
208
- cls="container",
209
- ),
210
- )
211
-
212
-
213
  @rt("/evaluate")
214
  def post(decision: str, example_id: str):
 
215
  example_id = int(example_id)
216
  example_dict = fact_dataset[example_id]
217
 
@@ -235,6 +223,21 @@ def post(decision: str, example_id: str):
235
  return render_example(new_example)
236
 
237
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
238
  # serve()
239
  if __name__ == "__main__":
240
  import os
 
113
 
114
  def render_example(example):
115
  return Div(
 
116
  Table(
117
  *[Tr(Th(key), Td(str(value))) for key, value in example.items()],
118
  cls="example-table",
119
  ),
120
+ Form(
121
+ Button(
122
+ "Good Example",
123
+ name="decision",
124
+ value="good",
125
+ hx_post="/evaluate",
126
+ hx_target="#example-container",
127
+ ),
128
+ Button(
129
+ "Bad Example",
130
+ name="decision",
131
+ value="bad",
132
+ hx_post="/evaluate",
133
+ hx_target="#example-container",
134
+ ),
135
+ Hidden(
136
+ name="example_id",
137
+ value=str(example["example_id"]),
138
+ id="hidden-example-id",
139
+ ),
140
+ ),
141
  id="example-details",
142
  )
143
 
 
151
  exist_ok=True,
152
  )
153
 
154
+ # examples = db.t.examples
155
  annotations = examples()
156
 
157
  hf_ds = Dataset.from_list(annotations)
 
181
  H2("Example"),
182
  Div(
183
  render_example(example),
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
184
  id="example-container",
185
  ),
186
  )
 
189
 
190
  return Titled(
191
  "Example Curation",
192
+ H2("Question Type"),
193
  dropdown,
194
  content,
195
+ Div(),
196
  view_stats_link,
197
  )
198
 
199
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
200
  @rt("/evaluate")
201
  def post(decision: str, example_id: str):
202
+ print(f"params to post: {decision}, {example_id}")
203
  example_id = int(example_id)
204
  example_dict = fact_dataset[example_id]
205
 
 
223
  return render_example(new_example)
224
 
225
 
226
+ @rt("/stats")
227
+ def get():
228
+ stats = get_stats()
229
+ stats = render_stats(stats)
230
+
231
+ return Titled(
232
+ "Curation Statistics",
233
+ Div(
234
+ stats,
235
+ A("Back to Curation", href="/", cls="back-link"),
236
+ cls="container",
237
+ ),
238
+ )
239
+
240
+
241
  # serve()
242
  if __name__ == "__main__":
243
  import os