Skip to content

Commit

Permalink
Making MTurk agent approve idempotent (#445)
Browse files Browse the repository at this point in the history
* Making MTurk agent approve idempotent

* Also edit reject
  • Loading branch information
JackUrb authored Apr 28, 2021
1 parent 165c692 commit 838c317
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions mephisto/abstractions/providers/mturk/mturk_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,18 @@ def new_from_provider_data(

def approve_work(self) -> None:
"""Approve the work done on this specific Unit"""
if self.get_status() == AgentState.STATUS_APPROVED:
logging.info(f"Approving already approved agent {self}, skipping")
return
client = self._get_client()
approve_work(client, self._get_mturk_assignment_id(), override_rejection=True)
self.update_status(AgentState.STATUS_APPROVED)

def reject_work(self, reason) -> None:
"""Reject the work done on this specific Unit"""
if self.get_status() == AgentState.STATUS_APPROVED:
logging.warning(f"Cannot reject {self}, it is already approved")
return
client = self._get_client()
reject_work(client, self._get_mturk_assignment_id(), reason)
self.update_status(AgentState.STATUS_REJECTED)
Expand Down

0 comments on commit 838c317

Please sign in to comment.