pearmut 0.1.3__py3-none-any.whl → 0.2.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
pearmut/app.py CHANGED
@@ -53,7 +53,8 @@ async def _log_response(request: LogResponseRequest):
53
53
  return JSONResponse(content={"error": "Unknown user ID"}, status_code=400)
54
54
 
55
55
  # append response to the output log
56
- save_db_payload(campaign_id, request.payload | {"user_id": user_id, "item_i": item_i})
56
+ save_db_payload(campaign_id, request.payload | {
57
+ "user_id": user_id, "item_i": item_i})
57
58
 
58
59
  # if actions were submitted, we can log time data
59
60
  if "actions" in request.payload:
@@ -68,7 +69,16 @@ async def _log_response(request: LogResponseRequest):
68
69
  for a, b in zip(times, times[1:])
69
70
  ])
70
71
 
71
- update_progress(campaign_id, user_id, tasks_data, progress_data, request.item_i, request.payload)
72
+ # Initialize validation_checks if it doesn't exist
73
+ print(request.payload.keys())
74
+ if "validations" in request.payload:
75
+ if "validations" not in progress_data[campaign_id][user_id]:
76
+ progress_data[campaign_id][user_id]["validations"] = {}
77
+
78
+ progress_data[campaign_id][user_id]["validations"][request.item_i] = request.payload["validations"]
79
+
80
+ update_progress(campaign_id, user_id, tasks_data,
81
+ progress_data, request.item_i, request.payload)
72
82
  save_progress_data(progress_data)
73
83
 
74
84
  return JSONResponse(content={"status": "ok"}, status_code=200)
@@ -145,6 +155,11 @@ async def _dashboard_data(request: DashboardDataRequest):
145
155
  for user_id, user_val in progress_data[campaign_id].items():
146
156
  # shallow copy
147
157
  entry = dict(user_val)
158
+ entry["validations"] = [
159
+ all(v)
160
+ for v in list(entry.get("validations", {}).values())
161
+ ]
162
+
148
163
 
149
164
  if not is_privileged:
150
165
  entry["token_correct"] = None
@@ -229,10 +244,11 @@ async def _download_progress(
229
244
 
230
245
  static_dir = f"{os.path.dirname(os.path.abspath(__file__))}/static/"
231
246
  if not os.path.exists(static_dir + "index.html"):
232
- raise FileNotFoundError("Static directory not found. Please build the frontend first.")
247
+ raise FileNotFoundError(
248
+ "Static directory not found. Please build the frontend first.")
233
249
 
234
250
  app.mount(
235
251
  "/",
236
252
  StaticFiles(directory=static_dir, html=True, follow_symlink=True),
237
253
  name="static",
238
- )
254
+ )
pearmut/assignment.py CHANGED
@@ -76,8 +76,6 @@ def get_i_item_taskbased(
76
76
  Get specific item for task-based protocol.
77
77
  """
78
78
  user_progress = progress_data[campaign_id][user_id]
79
- if all(user_progress["progress"]):
80
- return _completed_response(progress_data, campaign_id, user_id)
81
79
 
82
80
  # try to get existing annotations if any
83
81
  items_existing = get_db_log_item(campaign_id, user_id, item_i)
@@ -120,8 +118,6 @@ def get_i_item_singlestream(
120
118
  Get specific item for single-stream assignment.
121
119
  """
122
120
  user_progress = progress_data[campaign_id][user_id]
123
- if all(user_progress["progress"]):
124
- return _completed_response(progress_data, campaign_id, user_id)
125
121
 
126
122
  # try to get existing annotations if any
127
123
  # note the None user_id since it is shared
@@ -254,6 +250,7 @@ def _reset_user_time(progress_data: dict, campaign_id: str, user_id: str) -> Non
254
250
  progress_data[campaign_id][user_id]["time"] = 0.0
255
251
  progress_data[campaign_id][user_id]["time_start"] = None
256
252
  progress_data[campaign_id][user_id]["time_end"] = None
253
+ progress_data[campaign_id][user_id]["validations"] = {}
257
254
 
258
255
 
259
256
  def reset_task(
@@ -299,7 +296,6 @@ def update_progress(
299
296
  if assignment == "task-based":
300
297
  # even if it's already set it should be fine
301
298
  progress_data[campaign_id][user_id]["progress"][item_i] = True
302
- # TODO: log attention checks/quality?
303
299
  return JSONResponse(content={"status": "ok"}, status_code=200)
304
300
  elif assignment == "single-stream":
305
301
  # progress all users
pearmut/cli.py CHANGED
@@ -214,7 +214,7 @@ def main():
214
214
  import shutil
215
215
 
216
216
  confirm = input(
217
- "Are you sure you want to purge all campaign data? This action cannot be undone. [y/n]"
217
+ "Are you sure you want to purge all campaign data? This action cannot be undone. [y/n] "
218
218
  )
219
219
  if confirm.lower() == 'y':
220
220
  shutil.rmtree(f"{ROOT}/data/tasks", ignore_errors=True)
@@ -225,4 +225,11 @@ input[type="button"].error_delete:hover {
225
225
 
226
226
  #progress span.progress_incomplete:hover {
227
227
  background: #aaa;
228
+ }
229
+
230
+ /* Validation warning indicator */
231
+ .validation_warning {
232
+ margin-right: 5px;
233
+ position: relative;
234
+ top: -5px;
228
235
  }