def __init__(self, image_aliases, task_directory, course_factory, task_factory, agent_tmp_dir="./agent_tmp", hook_manager=None, is_testing=False, agent_class=LocalAgent): AbstractJobManager.__init__(self, image_aliases, hook_manager, is_testing) self._agent = agent_class(image_aliases, task_directory, course_factory, task_factory, agent_tmp_dir)
def test_merge_text_global(self): res = AbstractJobManager._merge_results({"result": "success", "text": "a"}, {"result": "success", "text": "b"}) assert res["text"] == "b\na"
def test_merge_text_problem(self): res = AbstractJobManager._merge_results({"result": "success", "problems": {"id": "a"}}, {"result": "success", "problems": {"id": "b"}}) assert res["problems"]["id"] == "b\na"
def test_strange_result_types(self): res = AbstractJobManager._merge_results({"result": "success"}, {"result": "strange"}) assert res["result"] == "error"
def test_std_out_err(self): res = AbstractJobManager._merge_results({"result": "success"}, {"result": "success", "stdout": "a", "stderr": "b"}) assert res["stdout"] == "a" assert res["stderr"] == "b"
def test_non_float_grades(self): res = AbstractJobManager._merge_results({"result": "success", "grade": "You shall not grade!"}, None) assert res["grade"] == 0
def test_too_high_grades(self): res = AbstractJobManager._merge_results({"result": "success", "grade": 100000}, None) assert res["grade"] == 200
def test_neg_grades(self): res = AbstractJobManager._merge_results({"result": "success", "grade": -8}, None) assert res["grade"] == 0
def test_norun_merge_list(self): res = AbstractJobManager._merge_results({"result": "success", "problems": {"id1": ["a", "a"]}, "text": ["b", "b"]}, None) assert res["problems"]["id1"] == "a\na" assert res["text"] == "b\nb"
def __init__(self, agents, image_aliases, task_directory, course_factory, task_factory, hook_manager=None, is_testing=False): """ Starts the job manager. Arguments: :param agents: A list of dictionaries containing information about distant inginious.backend agents: :: { 'host': "the host of the agent", 'port': "the port on which the agent listens" 'ssh_port': "the port on which the interface for accessing the debug ssh server is accessible (not mandatory, can be None)" } If a least one ssh_port is absent or None, remote debugging will be deactivated for all agents :param task_directory: the task directory :param course_factory: a CourseFactory object :param task_factory: a TaskFactory object, possibly with specific task files managers attached :param image_aliases: a dict of image aliases, like {"default": "ingi/inginious-c-default"}. :param hook_manager: An instance of HookManager. If no instance is given(None), a new one will be created. """ AbstractJobManager.__init__(self, image_aliases, hook_manager, is_testing) # Count the number of times the function _try_agent_connection is called, when testing if is_testing: self._connection_attempts = 0 self._task_directory = task_directory self._agents = [None for _ in range(0, len(agents))] self._agents_thread = [None for _ in range(0, len(agents))] self._agents_info = agents self._course_factory = course_factory self._task_factory = task_factory self._next_agent = 0 self._running_on_agent = [[] for _ in range(0, len(agents))] self._last_content_in_task_directory = None self._timers = {} # Is remote debugging activated? nb_ok = 0 message = "ok" for info in self._agents_info: if info.get('ssh_port') is not None: nb_ok += 1 elif nb_ok != 0: nb_ok = -1 message = "one_error" if nb_ok == 0: self._remote_debugging_activated = False print "Remote debugging is deactivated as all agent have no ssh_port defined" elif nb_ok == -1: self._remote_debugging_activated = False print "Remote debugging is deactivated as one agent has no ssh_port defined" else: self._remote_debugging_activated = True
def _agent_batch_job_ended(self, jobid, result, agent_id=None): """ Custom _job_ended with more infos """ if agent_id is not None: self._running_on_agent[agent_id].remove(jobid) AbstractJobManager._batch_job_ended(self, jobid, result)
def __init__(self, agents, image_aliases, task_directory, course_factory, task_factory, hook_manager=None, is_testing=False): """ Starts the job manager. Arguments: :param agents: A list of dictionaries containing information about distant inginious.backend agents: :: { 'host': "the host of the agent", 'port': "the port on which the agent listens" 'ssh_port': "the port on which the interface for accessing the debug ssh server is accessible (not mandatory, can be None)" } If a least one ssh_port is absent or None, remote debugging will be deactivated for all agents :param task_directory: the task directory :param course_factory: a CourseFactory object :param task_factory: a TaskFactory object, possibly with specific task files managers attached :param image_aliases: a dict of image aliases, like {"default": "ingi/inginious-c-default"}. :param hook_manager: An instance of HookManager. If no instance is given(None), a new one will be created. """ AbstractJobManager.__init__(self, image_aliases, hook_manager, is_testing) # Count the number of times the function _try_agent_connection is called, when testing if is_testing: self._connection_attempts = 0 self._task_directory = task_directory self._agents = [None for _ in range(0, len(agents))] self._agents_thread = [None for _ in range(0, len(agents))] self._agents_info = agents self._course_factory = course_factory self._task_factory = task_factory self._next_agent = 0 self._running_on_agent = [[] for _ in range(0, len(agents))] self._last_content_in_task_directory = None self._timers = {} # Is remote debugging activated? nb_ok = 0 message = "ok" for info in self._agents_info: if info.get('ssh_port') is not None: nb_ok += 1 elif nb_ok != 0: nb_ok = -1 message = "one_error" if nb_ok == 0: self._remote_debugging_activated = False self._logger.info( "Remote debugging is deactivated as all agent have no ssh_port defined" ) elif nb_ok == -1: self._remote_debugging_activated = False self._logger.info( "Remote debugging is deactivated as one agent has no ssh_port defined" ) else: self._remote_debugging_activated = True