Ejemplo n.º 1
0
 def stop_run(self, run_id):
     """Stops a run and runs auto-purge if it was enabled
     - Used by the website and API for manually stopping runs
     - Called during /api/update_task:
       - for stopping SPRT runs if the test is accepted or rejected
       - for stopping a run after all games are finished
     """
     self.clear_params(run_id)  # spsa stuff
     run = self.get_run(run_id)
     for task in run["tasks"]:
         task["active"] = False
     run["results_stale"] = True
     results = self.get_results(run, True)
     run["results_info"] = format_results(results, run)
     # De-couple the styling of the run from its finished status
     if run["results_info"]["style"] == "#44EB44":
         run["is_green"] = True
     elif run["results_info"]["style"] == "yellow":
         run["is_yellow"] = True
     run["finished"] = True
     self.buffer(run, True)
     # Publish the results of the run to the Fishcooking forum
     post_in_fishcooking_results(run)
     self.task_time = 0  # triggers a reload of self.task_runs
     # Auto-purge runs here. This may revive the run.
     if run["args"].get("auto_purge", True) and "spsa" not in run["args"]:
         message = self.purge_run(run)
         if message == "":
             print("Run {} was auto-purged".format(str(run_id)), flush=True)
         else:
             print(
                 "Run {} was not auto-purged. Message: {}.".format(
                     str(run_id), message),
                 flush=True,
             )
Ejemplo n.º 2
0
 def stop_run(self, run_id, run=None):
   """ Stops a run and runs auto-purge if it was enabled
       - Used by the website and API for manually stopping runs
       - Called during /api/update_task:
         - for stopping SPRT runs if the test is accepted or rejected
         - for stopping a run after all games are finished
   """
   self.clear_params(run_id)
   save_it = False
   if run is None:
     run = self.get_run(run_id)
     save_it = True
   run.pop('cores', None)
   run['tasks'] = [task for task in run['tasks'] if 'stats' in task]
   for task in run['tasks']:
     task['pending'] = False
     task['active'] = False
   if save_it:
     self.buffer(run, True)
     self.task_time = 0
     # Auto-purge runs here
     purged = False
     if run['args'].get('auto_purge', True) and 'spsa' not in run['args']:
       if self.purge_run(run):
         purged = True
         run = self.get_run(run['_id'])
         results = self.get_results(run, True)
         run['results_info'] = format_results(results, run)
         self.buffer(run, True)
     if not purged:
       # The run is now finished and will no longer be updated after this
       run['finished'] = True
       results = self.get_results(run, True)
       run['results_info'] = format_results(results, run)
       # De-couple the styling of the run from its finished status
       if run['results_info']['style'] == '#44EB44':
         run['is_green'] = True
       elif run['results_info']['style'] == 'yellow':
         run['is_yellow'] = True
       self.buffer(run, True)
       # Publish the results of the run to the Fishcooking forum
       post_in_fishcooking_results(run)
Ejemplo n.º 3
0
 def stop_run(self, run_id, run=None):
     """Stops a run and runs auto-purge if it was enabled
     - Used by the website and API for manually stopping runs
     - Called during /api/update_task:
       - for stopping SPRT runs if the test is accepted or rejected
       - for stopping a run after all games are finished
     """
     self.clear_params(run_id)
     save_it = False
     if run is None:
         run = self.get_run(run_id)
         save_it = True
     run["tasks"] = [task for task in run["tasks"] if "stats" in task]
     for task in run["tasks"]:
         task["pending"] = False
         task["active"] = False
     if save_it:
         self.buffer(run, True)
         self.task_time = 0
         # Auto-purge runs here
         purged = False
         if run["args"].get("auto_purge",
                            True) and "spsa" not in run["args"]:
             if self.purge_run(run):
                 purged = True
                 run = self.get_run(run["_id"])
                 results = self.get_results(run, True)
                 run["results_info"] = format_results(results, run)
                 self.buffer(run, True)
         if not purged:
             # The run is now finished and will no longer be updated after this
             run["finished"] = True
             results = self.get_results(run, True)
             run["results_info"] = format_results(results, run)
             # De-couple the styling of the run from its finished status
             if run["results_info"]["style"] == "#44EB44":
                 run["is_green"] = True
             elif run["results_info"]["style"] == "yellow":
                 run["is_yellow"] = True
             self.buffer(run, True)
             # Publish the results of the run to the Fishcooking forum
             post_in_fishcooking_results(run)