def _create_single_assignment(self, assignment_data) -> None: """ Create a single assignment in the database using its read assignment_data """ task_run = self.task_run task_config = task_run.get_task_config() assignment_id = self.db.new_assignment( task_run.task_id, task_run.db_id, task_run.requester_id, task_run.task_type, task_run.provider_type, task_run.sandbox, ) assignment = Assignment(self.db, assignment_id) assignment.write_assignment_data(assignment_data) self.assignments.append(assignment) unit_count = len(assignment_data.unit_data) for unit_idx in range(unit_count): unit_id = self.db.new_unit( task_run.task_id, task_run.db_id, task_run.requester_id, assignment_id, unit_idx, task_config.task_reward, task_run.provider_type, task_run.task_type, task_run.sandbox, ) self.units.append(Unit(self.db, unit_id)) with self.unlaunched_units_access_condition: self.unlaunched_units[unit_id] = Unit(self.db, unit_id)
} ] # Write a new task, and then complete it for annotation in test_annotations: assignment_id = db.new_assignment( task_run.task_id, task_run.db_id, task_run.requester_id, task_run.task_type, task_run.provider_type, task_run.sandbox, ) assignment = Assignment(db, assignment_id) assignment.write_assignment_data( InitializationData(unit_data={}, shared=annotation["inputs"]) ) unit_id = db.new_unit( task_run.task_id, task_run.db_id, task_run.requester_id, assignment_id, 0, # Unit_index 0, # reward task_run.provider_type, task_run.task_type, task_run.sandbox, ) unit = Unit(db, unit_id)