From 19a2354490a5a92cabd347b5336ef941386aa728 Mon Sep 17 00:00:00 2001 From: Paul Abumov Date: Thu, 27 Jul 2023 13:50:27 -0400 Subject: [PATCH] Fixed edge case with unclaimed units --- .../architects/ec2/cleanup_ec2_server_all.py | 2 +- .../providers/prolific/prolific_unit.py | 20 ++++++------------- 2 files changed, 7 insertions(+), 15 deletions(-) diff --git a/mephisto/abstractions/architects/ec2/cleanup_ec2_server_all.py b/mephisto/abstractions/architects/ec2/cleanup_ec2_server_all.py index ec57c6a37..807f29ff9 100644 --- a/mephisto/abstractions/architects/ec2/cleanup_ec2_server_all.py +++ b/mephisto/abstractions/architects/ec2/cleanup_ec2_server_all.py @@ -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: diff --git a/mephisto/abstractions/providers/prolific/prolific_unit.py b/mephisto/abstractions/providers/prolific/prolific_unit.py index bbdc3e7ee..3973a1310 100644 --- a/mephisto/abstractions/providers/prolific/prolific_unit.py +++ b/mephisto/abstractions/providers/prolific/prolific_unit.py @@ -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) @@ -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 @@ -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: