Skip to content

Commit

Permalink
Fixed edge case with unclaimed units
Browse files Browse the repository at this point in the history
  • Loading branch information
meta-paul committed Jul 27, 2023
1 parent b207500 commit 19a2354
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def main():
skipped_names = []
for i, server_name in enumerate(all_server_names):
_name = f'"{server_name}"'
logger.debug(f'{i+1}/{n_names} Removing {_name}...')
logger.info(f'{i+1}/{n_names} Removing {_name}...')

session = boto3.Session(profile_name=iam_role_name, region_name='us-east-2')
try:
Expand Down
20 changes: 6 additions & 14 deletions mephisto/abstractions/providers/prolific/prolific_unit.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,19 +144,7 @@ def get_status(self) -> str:

return self.db_status

# Remaining statuses are tracking a live Study
prolific_study_id = self.get_prolific_study_id()
if prolific_study_id is None:
# If the study_id is None and there's an agent still assigned,
# then that agent has timed out, and we should expire
agent = self.get_assigned_agent()
if agent is not None:
if agent.get_status() != AgentState.STATUS_EXPIRED:
agent.update_status(AgentState.STATUS_EXPIRED)

# Can't determine anything else if there is no Study on this unit
return self.db_status

requester: 'ProlificRequester' = self.get_requester()
client = self._get_client(requester.requester_name)

Expand All @@ -168,7 +156,6 @@ def get_status(self) -> str:

# Record latest study status from Prolific
self.datastore.update_study_status(study.id, study.status)

local_status = self.db_status
external_status = self.db_status

Expand All @@ -192,7 +179,12 @@ def get_status(self) -> str:
# TODO (#1008): Choose correct mapping
pass
elif study.status == StudyStatus.AWAITING_REVIEW:
external_status = AssignmentState.COMPLETED
# Check for `worker_id` to avoid labeling not-yet-worked-on units as "COMPLETED"
# TODO (#1008): need to rely on status of Submissions, not Study
if self.worker_id:
external_status = AssignmentState.COMPLETED
else:
external_status = AssignmentState.EXPIRED
elif study.status == StudyStatus.COMPLETED:
external_status = AssignmentState.COMPLETED
else:
Expand Down

0 comments on commit 19a2354

Please sign in to comment.