def dataset_updated(self, task_id): """Notice that the active dataset of a task has been changed. Usually called by AdminWebServer when the contest administrator changed the active dataset of a task. This means that we should update all the scores for the task using the submission results on the new active dataset. If some of them are not available yet we keep the old scores (we don't delete them!) and wait for ScoringService to notify us that the new ones are available. task_id (int): the ID of the task whose dataset has changed. """ with SessionGen() as session: task = Task.get_from_id(task_id, session) dataset = task.active_dataset logger.info("Dataset update for task %d (dataset now is %d)." % ( task.id, dataset.id)) # max_score and/or extra_headers might have changed. self.reinitialize() for submission in task.submissions: # Update RWS. if not submission.user.hidden and \ submission.get_result().scored(): self.send_score(submission)
def extract_complexity(task_id, file_lengther=None): """Extract the complexity of all submissions of the task. The results are stored in a file task_<id>.info task_id (int): the id of the task we are interested in. file_lengther (type): a File-like object that tell the dimension of the input (see example above for how to write one). return (int): 0 if operation was successful. """ with SessionGen() as session: task = Task.get_from_id(task_id, session) if task is None: return -1 # Extracting the length of the testcase. file_cacher = FileCacher() testcases_lengths = [file_length(testcase.input, file_cacher, file_lengther) for testcase in task.testcases] file_cacher.purge_cache() # Compute the complexity of the solutions. with open("task_%s.info" % task_id, "wt") as info: for submission in task.contest.get_submissions(): if submission.task_id == task_id and \ submission.evaluated(): print submission.user.username result = extract_complexity_submission(testcases_lengths, submission) if result[1] is None: continue info.write("Submission: %s" % submission.id) info.write(" - user: %15s" % submission.user.username) info.write(" - task: %s" % task.name) if result[0] is not None: info.write(" - score: %6.2lf" % result[0]) info.write(" - complexity: %20s" % complexity_to_string(result[1])) if result[2] is not None: info.write(" - confidence %5.1lf" % result[2]) info.write("\n") return 0
def dataset_updated(self, task_id): """This function updates RWS with new data about a task. It should be called after the live dataset of a task is changed. task_id (int): id of the task whose dataset has changed. """ with SessionGen(commit=False) as session: task = Task.get_from_id(task_id, session) dataset = task.active_dataset logger.info("Dataset update for task %d (dataset now is %d)." % ( task.id, dataset.id)) for submission in task.submissions: # Update RWS. if submission.get_result().scored(): self.rankings_send_score(submission)
def dataset_updated(self, task_id): """Notice that the active dataset of a task has been changed. Usually called by AdminWebServer when the contest administrator changed the active dataset of a task. This means that we should update all the scores for the task using the submission results on the new active dataset. If some of them are not available yet we keep the old scores (we don't delete them!) and wait for ScoringService to notify us that the new ones are available. task_id (int): the ID of the task whose dataset has changed. """ with SessionGen() as session: task = Task.get_from_id(task_id, session) dataset = task.active_dataset # This ProxyService may focus on a different contest, and it should # ignore this update. if task.contest_id != self.contest_id: logger.debug("Ignoring dataset change for task %d of contest " "%d (this ProxyService considers contest %d " "only).", task_id, task.contest.id, self.contest_id) return logger.info("Dataset update for task %d (dataset now is %d).", task.id, dataset.id) # max_score and/or extra_headers might have changed. self.reinitialize() for submission in task.submissions: # Update RWS. if not submission.participation.hidden and \ submission.official and \ submission.get_result() is not None and \ submission.get_result().scored(): for operation in self.operations_for_score(submission): self.enqueue(operation)