KaushikSid
commited on
Commit
Β·
2577a76
1
Parent(s):
15f663c
Add debug logging to track issue_type saving
Browse files
app.py
CHANGED
|
@@ -519,6 +519,13 @@ def save_label(decision, issue_type="", notes=""):
|
|
| 519 |
traj = current_trajectories[current_idx]
|
| 520 |
traj_id = traj.get("id", "")
|
| 521 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 522 |
row_data = {
|
| 523 |
"dataset_repo": traj.get("dataset_repo", ""),
|
| 524 |
"config_name": traj.get("config_name", ""),
|
|
@@ -530,19 +537,27 @@ def save_label(decision, issue_type="", notes=""):
|
|
| 530 |
"timestamp": pd.Timestamp.now().isoformat()
|
| 531 |
}
|
| 532 |
|
|
|
|
|
|
|
| 533 |
# Upsert: update if exists
|
| 534 |
existing_mask = evaluations_df['trajectory_id'] == traj_id
|
| 535 |
is_update = existing_mask.any()
|
| 536 |
if is_update:
|
| 537 |
idx = evaluations_df[existing_mask].index[-1]
|
|
|
|
| 538 |
for col, val in row_data.items():
|
| 539 |
evaluations_df.at[idx, col] = val
|
|
|
|
| 540 |
status_msg = f"β
Updated: {decision}"
|
| 541 |
else:
|
|
|
|
| 542 |
evaluations_df = pd.concat([evaluations_df, pd.DataFrame([row_data])], ignore_index=True)
|
|
|
|
|
|
|
| 543 |
status_msg = f"β
Added: {decision}"
|
| 544 |
|
| 545 |
save_evaluations()
|
|
|
|
| 546 |
|
| 547 |
if dataset_sync_enabled:
|
| 548 |
from hf_dataset_sync import append_to_dataset
|
|
@@ -556,9 +571,24 @@ def save_label(decision, issue_type="", notes=""):
|
|
| 556 |
def save_with_decision(decision, review_reason, notes):
|
| 557 |
# Ensure issue is always empty string unless decision is "review" with valid reason
|
| 558 |
valid_choices = ['too_short', 'too_long', 'wrong_description', 'task_already_completed', 'mislabeled_success', 'mislabeled_failure', 'mislabeled_suboptimal', 'other']
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 559 |
issue = ""
|
| 560 |
if decision == "review" and review_reason and str(review_reason) in valid_choices:
|
| 561 |
issue = str(review_reason)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 562 |
return save_label(decision, issue, notes)
|
| 563 |
|
| 564 |
|
|
|
|
| 519 |
traj = current_trajectories[current_idx]
|
| 520 |
traj_id = traj.get("id", "")
|
| 521 |
|
| 522 |
+
# Debug logging
|
| 523 |
+
print(f"πΎ save_label called:")
|
| 524 |
+
print(f" decision: {decision}")
|
| 525 |
+
print(f" issue_type: '{issue_type}' (type: {type(issue_type)}, len: {len(str(issue_type))})")
|
| 526 |
+
print(f" notes: {notes}")
|
| 527 |
+
print(f" traj_id: {traj_id[:20]}...")
|
| 528 |
+
|
| 529 |
row_data = {
|
| 530 |
"dataset_repo": traj.get("dataset_repo", ""),
|
| 531 |
"config_name": traj.get("config_name", ""),
|
|
|
|
| 537 |
"timestamp": pd.Timestamp.now().isoformat()
|
| 538 |
}
|
| 539 |
|
| 540 |
+
print(f" π row_data issue_type: '{row_data['issue_type']}'")
|
| 541 |
+
|
| 542 |
# Upsert: update if exists
|
| 543 |
existing_mask = evaluations_df['trajectory_id'] == traj_id
|
| 544 |
is_update = existing_mask.any()
|
| 545 |
if is_update:
|
| 546 |
idx = evaluations_df[existing_mask].index[-1]
|
| 547 |
+
print(f" π Updating existing row at index {idx}")
|
| 548 |
for col, val in row_data.items():
|
| 549 |
evaluations_df.at[idx, col] = val
|
| 550 |
+
print(f" β
After update, issue_type = '{evaluations_df.at[idx, 'issue_type']}'")
|
| 551 |
status_msg = f"β
Updated: {decision}"
|
| 552 |
else:
|
| 553 |
+
print(f" β Adding new row")
|
| 554 |
evaluations_df = pd.concat([evaluations_df, pd.DataFrame([row_data])], ignore_index=True)
|
| 555 |
+
new_idx = evaluations_df.index[-1]
|
| 556 |
+
print(f" β
After add, issue_type = '{evaluations_df.at[new_idx, 'issue_type']}'")
|
| 557 |
status_msg = f"β
Added: {decision}"
|
| 558 |
|
| 559 |
save_evaluations()
|
| 560 |
+
print(f" πΎ Saved to CSV")
|
| 561 |
|
| 562 |
if dataset_sync_enabled:
|
| 563 |
from hf_dataset_sync import append_to_dataset
|
|
|
|
| 571 |
def save_with_decision(decision, review_reason, notes):
|
| 572 |
# Ensure issue is always empty string unless decision is "review" with valid reason
|
| 573 |
valid_choices = ['too_short', 'too_long', 'wrong_description', 'task_already_completed', 'mislabeled_success', 'mislabeled_failure', 'mislabeled_suboptimal', 'other']
|
| 574 |
+
|
| 575 |
+
# Debug logging
|
| 576 |
+
print(f"π save_with_decision called:")
|
| 577 |
+
print(f" decision: {decision} (type: {type(decision)})")
|
| 578 |
+
print(f" review_reason: {review_reason} (type: {type(review_reason)})")
|
| 579 |
+
print(f" notes: {notes}")
|
| 580 |
+
|
| 581 |
issue = ""
|
| 582 |
if decision == "review" and review_reason and str(review_reason) in valid_choices:
|
| 583 |
issue = str(review_reason)
|
| 584 |
+
print(f" β
Setting issue_type to: {issue}")
|
| 585 |
+
else:
|
| 586 |
+
print(f" β Issue NOT set. Checks:")
|
| 587 |
+
print(f" decision == 'review': {decision == 'review'}")
|
| 588 |
+
print(f" review_reason truthy: {bool(review_reason)}")
|
| 589 |
+
if review_reason:
|
| 590 |
+
print(f" review_reason in valid_choices: {str(review_reason) in valid_choices}")
|
| 591 |
+
|
| 592 |
return save_label(decision, issue, notes)
|
| 593 |
|
| 594 |
|