pearmut 0.2.3__tar.gz → 0.2.5__tar.gz
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-0.2.3 → pearmut-0.2.5}/PKG-INFO +1 -1
- {pearmut-0.2.3 → pearmut-0.2.5}/pearmut.egg-info/PKG-INFO +1 -1
- {pearmut-0.2.3 → pearmut-0.2.5}/pyproject.toml +1 -1
- {pearmut-0.2.3 → pearmut-0.2.5}/server/app.py +18 -19
- {pearmut-0.2.3 → pearmut-0.2.5}/server/assignment.py +10 -10
- {pearmut-0.2.3 → pearmut-0.2.5}/server/cli.py +2 -3
- {pearmut-0.2.3 → pearmut-0.2.5}/server/static/assets/style.css +4 -0
- {pearmut-0.2.3 → pearmut-0.2.5}/server/static/dashboard.bundle.js +1 -1
- {pearmut-0.2.3 → pearmut-0.2.5}/server/static/dashboard.html +2 -1
- {pearmut-0.2.3 → pearmut-0.2.5}/server/static/listwise.bundle.js +1 -1
- {pearmut-0.2.3 → pearmut-0.2.5}/server/static/listwise.html +1 -1
- {pearmut-0.2.3 → pearmut-0.2.5}/server/static/pointwise.bundle.js +1 -1
- {pearmut-0.2.3 → pearmut-0.2.5}/server/static/pointwise.html +1 -1
- {pearmut-0.2.3 → pearmut-0.2.5}/LICENSE +0 -0
- {pearmut-0.2.3 → pearmut-0.2.5}/README.md +0 -0
- {pearmut-0.2.3 → pearmut-0.2.5}/pearmut.egg-info/SOURCES.txt +0 -0
- {pearmut-0.2.3 → pearmut-0.2.5}/pearmut.egg-info/dependency_links.txt +0 -0
- {pearmut-0.2.3 → pearmut-0.2.5}/pearmut.egg-info/entry_points.txt +0 -0
- {pearmut-0.2.3 → pearmut-0.2.5}/pearmut.egg-info/requires.txt +0 -0
- {pearmut-0.2.3 → pearmut-0.2.5}/pearmut.egg-info/top_level.txt +0 -0
- {pearmut-0.2.3 → pearmut-0.2.5}/server/static/assets/favicon.svg +0 -0
- {pearmut-0.2.3 → pearmut-0.2.5}/server/static/index.html +0 -0
- {pearmut-0.2.3 → pearmut-0.2.5}/server/utils.py +0 -0
- {pearmut-0.2.3 → pearmut-0.2.5}/setup.cfg +0 -0
|
@@ -54,9 +54,9 @@ async def _log_response(request: LogResponseRequest):
|
|
|
54
54
|
item_i = request.item_i
|
|
55
55
|
|
|
56
56
|
if campaign_id not in progress_data:
|
|
57
|
-
return JSONResponse(content=
|
|
57
|
+
return JSONResponse(content="Unknown campaign ID", status_code=400)
|
|
58
58
|
if user_id not in progress_data[campaign_id]:
|
|
59
|
-
return JSONResponse(content=
|
|
59
|
+
return JSONResponse(content="Unknown user ID", status_code=400)
|
|
60
60
|
|
|
61
61
|
# append response to the output log
|
|
62
62
|
save_db_payload(
|
|
@@ -86,7 +86,7 @@ async def _log_response(request: LogResponseRequest):
|
|
|
86
86
|
progress_data, request.item_i, request.payload)
|
|
87
87
|
save_progress_data(progress_data)
|
|
88
88
|
|
|
89
|
-
return JSONResponse(content=
|
|
89
|
+
return JSONResponse(content="ok", status_code=200)
|
|
90
90
|
|
|
91
91
|
|
|
92
92
|
class NextItemRequest(BaseModel):
|
|
@@ -100,9 +100,9 @@ async def _get_next_item(request: NextItemRequest):
|
|
|
100
100
|
user_id = request.user_id
|
|
101
101
|
|
|
102
102
|
if campaign_id not in progress_data:
|
|
103
|
-
return JSONResponse(content=
|
|
103
|
+
return JSONResponse(content="Unknown campaign ID", status_code=400)
|
|
104
104
|
if user_id not in progress_data[campaign_id]:
|
|
105
|
-
return JSONResponse(content=
|
|
105
|
+
return JSONResponse(content="Unknown user ID", status_code=400)
|
|
106
106
|
|
|
107
107
|
return get_next_item(
|
|
108
108
|
campaign_id,
|
|
@@ -125,9 +125,9 @@ async def _get_i_item(request: GetItemRequest):
|
|
|
125
125
|
item_i = request.item_i
|
|
126
126
|
|
|
127
127
|
if campaign_id not in progress_data:
|
|
128
|
-
return JSONResponse(content=
|
|
128
|
+
return JSONResponse(content="Unknown campaign ID", status_code=400)
|
|
129
129
|
if user_id not in progress_data[campaign_id]:
|
|
130
|
-
return JSONResponse(content=
|
|
130
|
+
return JSONResponse(content="Unknown user ID", status_code=400)
|
|
131
131
|
|
|
132
132
|
return get_i_item(
|
|
133
133
|
campaign_id,
|
|
@@ -147,15 +147,15 @@ class DashboardDataRequest(BaseModel):
|
|
|
147
147
|
async def _dashboard_data(request: DashboardDataRequest):
|
|
148
148
|
campaign_id = request.campaign_id
|
|
149
149
|
|
|
150
|
-
is_privileged = (request.token == tasks_data[campaign_id]["token"])
|
|
151
|
-
|
|
152
150
|
if campaign_id not in progress_data:
|
|
153
|
-
return JSONResponse(content=
|
|
151
|
+
return JSONResponse(content="Unknown campaign ID", status_code=400)
|
|
152
|
+
|
|
153
|
+
is_privileged = (request.token == tasks_data[campaign_id]["token"])
|
|
154
154
|
|
|
155
155
|
progress_new = {}
|
|
156
156
|
assignment = tasks_data[campaign_id]["info"]["assignment"]
|
|
157
157
|
if assignment not in ["task-based", "single-stream"]:
|
|
158
|
-
return JSONResponse(content=
|
|
158
|
+
return JSONResponse(content="Unsupported campaign assignment type", status_code=400)
|
|
159
159
|
|
|
160
160
|
# Get threshold info for the campaign
|
|
161
161
|
validation_threshold = tasks_data[campaign_id]["info"].get("validation_threshold")
|
|
@@ -184,7 +184,6 @@ async def _dashboard_data(request: DashboardDataRequest):
|
|
|
184
184
|
|
|
185
185
|
return JSONResponse(
|
|
186
186
|
content={
|
|
187
|
-
"status": "ok",
|
|
188
187
|
"data": progress_new,
|
|
189
188
|
"validation_threshold": validation_threshold
|
|
190
189
|
},
|
|
@@ -206,11 +205,11 @@ async def _reset_task(request: ResetTaskRequest):
|
|
|
206
205
|
token = request.token
|
|
207
206
|
|
|
208
207
|
if campaign_id not in progress_data:
|
|
209
|
-
return JSONResponse(content=
|
|
208
|
+
return JSONResponse(content="Unknown campaign ID", status_code=400)
|
|
210
209
|
if token != tasks_data[campaign_id]["token"]:
|
|
211
|
-
return JSONResponse(content=
|
|
210
|
+
return JSONResponse(content="Invalid token", status_code=400)
|
|
212
211
|
if user_id not in progress_data[campaign_id]:
|
|
213
|
-
return JSONResponse(content=
|
|
212
|
+
return JSONResponse(content="Unknown user ID", status_code=400)
|
|
214
213
|
|
|
215
214
|
response = reset_task(campaign_id, user_id, tasks_data, progress_data)
|
|
216
215
|
save_progress_data(progress_data)
|
|
@@ -228,7 +227,7 @@ async def _download_annotations(
|
|
|
228
227
|
for campaign_id in campaign_id:
|
|
229
228
|
output_path = f"{ROOT}/data/outputs/{campaign_id}.jsonl"
|
|
230
229
|
if campaign_id not in progress_data:
|
|
231
|
-
return JSONResponse(content=
|
|
230
|
+
return JSONResponse(content=f"Unknown campaign ID {campaign_id}", status_code=400)
|
|
232
231
|
if not os.path.exists(output_path):
|
|
233
232
|
output[campaign_id] = []
|
|
234
233
|
else:
|
|
@@ -245,14 +244,14 @@ async def _download_progress(
|
|
|
245
244
|
):
|
|
246
245
|
|
|
247
246
|
if len(campaign_id) != len(token):
|
|
248
|
-
return JSONResponse(content=
|
|
247
|
+
return JSONResponse(content="Mismatched campaign_id and token count", status_code=400)
|
|
249
248
|
|
|
250
249
|
output = {}
|
|
251
250
|
for i, cid in enumerate(campaign_id):
|
|
252
251
|
if cid not in progress_data:
|
|
253
|
-
return JSONResponse(content=
|
|
252
|
+
return JSONResponse(content=f"Unknown campaign ID {cid}", status_code=400)
|
|
254
253
|
if token[i] != tasks_data[cid]["token"]:
|
|
255
|
-
return JSONResponse(content=
|
|
254
|
+
return JSONResponse(content=f"Invalid token for campaign ID {cid}", status_code=400)
|
|
256
255
|
|
|
257
256
|
output[cid] = progress_data[cid]
|
|
258
257
|
|
|
@@ -48,7 +48,7 @@ def get_next_item(
|
|
|
48
48
|
elif assignment == "dynamic":
|
|
49
49
|
return get_next_item_dynamic(campaign_id, user_id, tasks_data, progress_data)
|
|
50
50
|
else:
|
|
51
|
-
return JSONResponse(content=
|
|
51
|
+
return JSONResponse(content="Unknown campaign assignment type", status_code=400)
|
|
52
52
|
|
|
53
53
|
|
|
54
54
|
def get_i_item(
|
|
@@ -67,7 +67,7 @@ def get_i_item(
|
|
|
67
67
|
elif assignment == "single-stream":
|
|
68
68
|
return get_i_item_singlestream(campaign_id, user_id, tasks_data, progress_data, item_i)
|
|
69
69
|
else:
|
|
70
|
-
return JSONResponse(content=
|
|
70
|
+
return JSONResponse(content="Get item not supported for this assignment type", status_code=400)
|
|
71
71
|
|
|
72
72
|
|
|
73
73
|
def get_i_item_taskbased(
|
|
@@ -90,7 +90,7 @@ def get_i_item_taskbased(
|
|
|
90
90
|
|
|
91
91
|
if item_i < 0 or item_i >= len(data_all[campaign_id]["data"][user_id]):
|
|
92
92
|
return JSONResponse(
|
|
93
|
-
content=
|
|
93
|
+
content="Item index out of range",
|
|
94
94
|
status_code=400
|
|
95
95
|
)
|
|
96
96
|
|
|
@@ -133,7 +133,7 @@ def get_i_item_singlestream(
|
|
|
133
133
|
|
|
134
134
|
if item_i < 0 or item_i >= len(data_all[campaign_id]["data"]):
|
|
135
135
|
return JSONResponse(
|
|
136
|
-
content=
|
|
136
|
+
content="Item index out of range",
|
|
137
137
|
status_code=400
|
|
138
138
|
)
|
|
139
139
|
|
|
@@ -280,7 +280,7 @@ def reset_task(
|
|
|
280
280
|
})
|
|
281
281
|
progress_data[campaign_id][user_id]["progress"] = [False] * num_items
|
|
282
282
|
_reset_user_time(progress_data, campaign_id, user_id)
|
|
283
|
-
return JSONResponse(content=
|
|
283
|
+
return JSONResponse(content="ok", status_code=200)
|
|
284
284
|
elif assignment == "single-stream":
|
|
285
285
|
# Save reset markers for all items (shared pool)
|
|
286
286
|
num_items = len(tasks_data[campaign_id]["data"])
|
|
@@ -294,9 +294,9 @@ def reset_task(
|
|
|
294
294
|
for uid in progress_data[campaign_id]:
|
|
295
295
|
progress_data[campaign_id][uid]["progress"] = [False] * num_items
|
|
296
296
|
_reset_user_time(progress_data, campaign_id, user_id)
|
|
297
|
-
return JSONResponse(content=
|
|
297
|
+
return JSONResponse(content="ok", status_code=200)
|
|
298
298
|
else:
|
|
299
|
-
return JSONResponse(content=
|
|
299
|
+
return JSONResponse(content="Reset not supported for this assignment type", status_code=400)
|
|
300
300
|
|
|
301
301
|
|
|
302
302
|
def update_progress(
|
|
@@ -319,8 +319,8 @@ def update_progress(
|
|
|
319
319
|
# progress all users
|
|
320
320
|
for uid in progress_data[campaign_id]:
|
|
321
321
|
progress_data[campaign_id][uid]["progress"][item_i] = True
|
|
322
|
-
return JSONResponse(content=
|
|
322
|
+
return JSONResponse(content="ok", status_code=200)
|
|
323
323
|
elif assignment == "dynamic":
|
|
324
|
-
return JSONResponse(content=
|
|
324
|
+
return JSONResponse(content="Dynamic protocol logging not implemented yet.", status_code=400)
|
|
325
325
|
else:
|
|
326
|
-
return JSONResponse(content=
|
|
326
|
+
return JSONResponse(content="Unknown campaign assignment type", status_code=400)
|
|
@@ -65,11 +65,10 @@ def _add_single_campaign(data_file, overwrite, server):
|
|
|
65
65
|
progress_data = json.load(f)
|
|
66
66
|
|
|
67
67
|
if campaign_data['campaign_id'] in progress_data and not overwrite:
|
|
68
|
-
|
|
69
|
-
f"Campaign {campaign_data['campaign_id']} already exists
|
|
68
|
+
raise ValueError(
|
|
69
|
+
f"Campaign {campaign_data['campaign_id']} already exists.\n"
|
|
70
70
|
"Use -o to overwrite."
|
|
71
71
|
)
|
|
72
|
-
exit(1)
|
|
73
72
|
|
|
74
73
|
if "info" not in campaign_data:
|
|
75
74
|
raise ValueError("Campaign data must contain 'info' field.")
|