inginious.agent package¶
-
class
inginious.agent.
Agent
(context, backend_addr, friendly_name, concurrency, tasks_filesystem)[source]¶ Bases:
object
An INGInious agent, that grades specific kinds of jobs, and interacts with a Backend.
-
environments
¶ Returns: a dict of available environments (containers most of the time) in the form { - ”name”: { #for example, “default”
- ”id”: “container img id”, # “sha256:715c5cb5575cdb2641956e42af4a53e69edf763ce701006b2c6e0f4f39b68dd3” “created”: 12345678 # create date, as an unix timestamp
}
}
If the environments are not containers, fills created with a fixed date (that will be shared by all agents of the same version), that could be 0. id can be anything, but should also be the same for the same versions of environments.
Only the name field is shared with the Clients.
-
new_job
(message: inginious.common.messages.BackendNewJob)[source]¶ Starts a new job. Most of the time, this function should not call send_job_result directly (as job are intended to be asynchronous). When there is a problem starting the job, raise CannotCreateJobException. If the job ends immediately, you are free to call send_job_result. :param message: message containing all the data needed to start the job :return: nothing. If any problems occurs, this method should raise a CannotCreateJobException,
which will result in the cancellation of the job.
-
run
()[source]¶ Runs the agent. Answer to the requests made by the Backend. May raise an asyncio.CancelledError, in which case the agent should clean itself and restart completely.
-
send_job_result
(job_id: Tuple[bytes, str], result: str, text: str = '', grade: float = None, problems: Dict[str, Tuple[str, str]] = None, tests: Dict[str, Any] = None, custom: Dict[str, Any] = None, archive: Optional[bytes] = None, stdout: Optional[str] = None, stderr: Optional[str] = None)[source]¶ Send the result of a job back to the backend. Must be called once and only once for each job :exception JobNotRunningException: is raised when send_job_result is called more than once for a given job_id
-
send_ssh_job_info
(job_id: Tuple[bytes, str], host: str, port: int, key: str)[source]¶ Send info about the SSH debug connection to the backend/client. Must be called at most once for each job. :exception JobNotRunningException: is raised when the job is not running anymore (send_job_result already called) :exception TooManyCallsException: is raised when this function has been called more than once
-
-
exception
inginious.agent.
CannotCreateJobException
(message)[source]¶ Bases:
Exception
Exception that should be raised when a (batch or std) job cannot be created in Agent.new_job or Agent.new_batch_job
-
exception
inginious.agent.
JobNotRunningException
[source]¶ Bases:
Exception
Exception raised by the Agent when the functions send_job_result/send_ssh_job_info are called but the job is not running anymore
-
exception
inginious.agent.
TooManyCallsException
[source]¶ Bases:
Exception
Exception raised by the Agent when the function send_ssh_job_info has been called more than once
Submodules¶
inginious.agent.docker_agent module¶
-
class
inginious.agent.docker_agent.
DockerAgent
(context, backend_addr, friendly_name, concurrency, tasks_fs: inginious.common.filesystems.provider.FileSystemProvider, ssh_host=None, ssh_ports=None, tmp_dir='./agent_tmp')[source]¶ Bases:
inginious.agent.Agent
-
create_student_container
(job_id, parent_container_id, sockets_path, student_path, systemfiles_path, course_common_student_path, socket_id, environment_name, memory_limit, time_limit, hard_time_limit, share_network, write_stream)[source]¶ Creates a new student container. :param write_stream: stream on which to write the return value of the container (with a correctly formatted msgpack message)
-
environments
¶ Returns: a dict of available environments (containers most of the time) in the form - {
- “name”: { #for example, “default”
- “id”: “container img id”, # “sha256:715c5cb5575cdb2641956e42af4a53e69edf763ce701006b2c6e0f4f39b68dd3” “created”: 12345678 # create date, as an unix timestamp
}
}
If the environments are not containers, fills created with a fixed date (that will be shared by all agents of the same version), that could be 0. id can be anything, but should also be the same for the same versions of environments.
Only the name field is shared with the Clients.
-
handle_job_closing
(container_id, retval)[source]¶ Handle a closing student container. Do some cleaning, verify memory limits, timeouts, … and returns data to the backend
-
handle_running_container
(job_id, container_id, inputdata, debug, ssh_port, orig_env, orig_memory_limit, orig_time_limit, orig_hard_time_limit, sockets_path, student_path, systemfiles_path, course_common_student_path, future_results)[source]¶ Talk with a container. Sends the initial input. Allows to start student containers
-
handle_student_job_closing
(container_id, retval)[source]¶ Handle a closing student container. Do some cleaning, verify memory limits, timeouts, … and returns data to the associated grading container
-
kill_job
(message: inginious.common.messages.BackendKillJob)[source]¶ Handles kill messages. Kill things.
-
inginious.agent.mcq_agent module¶
-
class
inginious.agent.mcq_agent.
MCQAgent
(context, backend_addr, friendly_name, concurrency, tasks_filesystem)[source]¶ Bases:
inginious.agent.Agent
-
environments
¶ Returns: a dict of available environments (containers most of the time) in the form - {
- “name”: { #for example, “default”
- “id”: “container img id”, # “sha256:715c5cb5575cdb2641956e42af4a53e69edf763ce701006b2c6e0f4f39b68dd3” “created”: 12345678 # create date, as an unix timestamp
}
}
If the environments are not containers, fills created with a fixed date (that will be shared by all agents of the same version), that could be 0. id can be anything, but should also be the same for the same versions of environments.
Only the name field is shared with the Clients.
-
new_job
(msg: inginious.common.messages.BackendNewJob)[source]¶ Starts a new job. Most of the time, this function should not call send_job_result directly (as job are intended to be asynchronous). When there is a problem starting the job, raise CannotCreateJobException. If the job ends immediately, you are free to call send_job_result. :param message: message containing all the data needed to start the job :return: nothing. If any problems occurs, this method should raise a CannotCreateJobException,
which will result in the cancellation of the job.
-