pearmut 0.1.3__py3-none-any.whl → 0.2.1__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(
57
+ campaign_id, request.payload | {"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,15 @@ 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
+ if "validations" in request.payload:
74
+ if "validations" not in progress_data[campaign_id][user_id]:
75
+ progress_data[campaign_id][user_id]["validations"] = {}
76
+
77
+ progress_data[campaign_id][user_id]["validations"][request.item_i] = request.payload["validations"]
78
+
79
+ update_progress(campaign_id, user_id, tasks_data,
80
+ progress_data, request.item_i, request.payload)
72
81
  save_progress_data(progress_data)
73
82
 
74
83
  return JSONResponse(content={"status": "ok"}, status_code=200)
@@ -145,6 +154,11 @@ async def _dashboard_data(request: DashboardDataRequest):
145
154
  for user_id, user_val in progress_data[campaign_id].items():
146
155
  # shallow copy
147
156
  entry = dict(user_val)
157
+ entry["validations"] = [
158
+ all(v)
159
+ for v in list(entry.get("validations", {}).values())
160
+ ]
161
+
148
162
 
149
163
  if not is_privileged:
150
164
  entry["token_correct"] = None
@@ -229,10 +243,11 @@ async def _download_progress(
229
243
 
230
244
  static_dir = f"{os.path.dirname(os.path.abspath(__file__))}/static/"
231
245
  if not os.path.exists(static_dir + "index.html"):
232
- raise FileNotFoundError("Static directory not found. Please build the frontend first.")
246
+ raise FileNotFoundError(
247
+ "Static directory not found. Please build the frontend first.")
233
248
 
234
249
  app.mount(
235
250
  "/",
236
251
  StaticFiles(directory=static_dir, html=True, follow_symlink=True),
237
252
  name="static",
238
- )
253
+ )
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
  }