inginious.client package

Submodules

inginious.client.client module

class inginious.client.client.AbstractClient[source]

Bases: object

abstract close()[source]

Close the Client

abstract get_available_environments()Dict[str, List[str]][source]

Returns the dict of available environments for grading. Keys are the type of the environment, and values are each of list of available environments for each type.

abstract get_job_queue_info(jobid)[source]
Parameters

jobid – the jobid of a task.

Returns

If the submission is in the queue, then returns a tuple (nb tasks before running (or -1 if running), approx wait time in seconds) Else, returns None

abstract get_job_queue_snapshot()[source]

Get a snapshot of the remote backend job queue. May be a cached version. May not contain recent jobs. May return None if no snapshot is available.

Returns

a tuple of two lists (or None, None):

  • jobs_running : a list of tuples in the form (job_id, is_current_client_job, info, launcher, started_at, max_time) where

    • job_id is a job id. It may be from another client.

    • is_current_client_job is a boolean indicating if the client that asked the request has started the job

    • agent_name is the agent name

    • info is “courseid/taskid”

    • launcher is the name of the launcher, which may be anything

    • started_at the time (in seconds since UNIX epoch) at which the job started

    • max_time the maximum time that can be used, or -1 if no timeout is set

  • jobs_waiting : a list of tuples in the form (job_id, is_current_client_job, info, launcher, max_time) where

    • job_id is a job id. It may be from another client.

    • is_current_client_job is a boolean indicating if the client that asked the request has started the job

    • info is “courseid/taskid”

    • launcher is the name of the launcher, which may be anything

    • max_time the maximum time that can be used, or -1 if no timeout is set

abstract kill_job(job_id)[source]

Kills a running job :param job_id:

abstract new_job(task, inputdata, callback, launcher_name='Unknown', debug=False, ssh_callback=None)[source]

Add a new job. Every callback will be called once and only once.

Parameters
  • inputdata (Storage or dict) – input from the student

  • callback (__builtin__.function or __builtin__.instancemethod) –

    a function that will be called asynchronously in the client’s process, with the results. it’s signature must be (result, grade, problems, tests, custom, archive), where: result is itself a tuple containing the result string and the main feedback (i.e. (‘success’, ‘You succeeded’); grade is a number between 0 and 100 indicating the grade of the users; problems is a dict of tuple, in the form {‘problemid’: result}; test is a dict of tests made in the environment custom is a dict containing random things set in the environment archive is either None or a bytes containing a tgz archive of files from the job

    The callback will always be called exactly once.

  • launcher_name (str) – for informational use

  • debug (bool or string) – Either True(outputs more info), False(default), or “ssh” (starts a remote ssh server. ssh_callback needs to be defined)

  • ssh_callback (__builtin__.function or __builtin__.instancemethod or None) – a callback function that will be called with (host, port, user, password), the needed credentials to connect to the remote ssh server. May be called with host, port, password being None, meaning no session was open.

Returns

the new job id, or None if an error happened

abstract start()[source]

Starts the Client. Should be done after a complete initialisation of the hook manager.

class inginious.client.client.Client(context, backend_addr, queue_update=10)[source]

Bases: inginious.client._zeromq_client.BetterParanoidPirateClient

close()[source]

Close the Client

get_available_environments()Dict[str, List[str]][source]

Returns the dict of available environments for grading. Keys are the type of the environment, and values are each of list of available environments for each type.

get_job_queue_info(jobid)[source]
get_job_queue_snapshot()[source]
kill_job(job_id)[source]

Kills a running job

new_job(priority, task, inputdata, callback, launcher_name='Unknown', debug=False, ssh_callback=None)[source]

Add a new job. Every callback will be called once and only once. :param priority: Priority of the job :type task: Task :param inputdata: input from the student :type inputdata: Storage or dict :param callback: a function that will be called asynchronously in the client’s process, with the results. Is signature must be (result, grade, problems, tests, custom, archive), where: result is itself a tuple containing the result string and the main feedback (i.e. (‘success’, ‘You succeeded’); grade is a number between 0 and 100 indicating the grade of the users; problems is a dict of tuple, in the form {‘problemid’: result}; test is a dict of tests made in the environment custom is a dict containing random things set in the environment archive is either None or a bytes containing a tgz archive of files from the job :type callback: __builtin__.function or __builtin__.instancemethod :param launcher_name: for informational use :type launcher_name: str :param debug: Either True(outputs more info), False(default), or “ssh” (starts a remote ssh server. ssh_callback needs to be defined) :type debug: bool or string :param ssh_callback: a callback function that will be called with (host, port, user, password), the needed credentials to connect to the remote ssh server. May be called with host, port, password being None, meaning no session was open. :type ssh_callback: __builtin__.function or __builtin__.instancemethod or None :return: the new job id, or None if an error happened

start()[source]

Starts the Client. Should be done after a complete initialisation of the hook manager.

inginious.client.client_buffer module

Contains ClientBuffer, which creates a buffer for a Client

class inginious.client.client_buffer.ClientBuffer(client)[source]

Bases: object

A buffer for a Client

get_result(bjobid)[source]

Get the result of task. Must only be called ONCE, AFTER the task is done (after a successfull call to is_done). :return a tuple (result, grade, problems, tests, custom, archive) result is itself a tuple containing the result string and the main feedback (i.e. (‘success’, ‘You succeeded’) grade is a number between 0 and 100 indicating the grade of the users problems is a dict of tuple, in the form {‘problemid’: result} test is a dict of tests made in the container custom is a dict containing random things set in the container archive is either None or a bytes containing a tgz archive of files from the job

is_done(bjobid)[source]

Return true if the job is done

is_waiting(bjobid)[source]

Return true if the job is in queue

new_job(priority, task, inputdata, launcher_name='Unknown', debug=False)[source]

Runs a new job. It works exactly like the Client class, instead that there is no callback

inginious.client.client_sync module

A synchronized “layer” for Client

class inginious.client.client_sync.ClientSync(client)[source]

Bases: object

Runs job synchronously

new_job(priority, task, inputdata, launcher_name='Unknown', debug=False)[source]

Runs a new job. It works exactly like the Client class, instead that there is no callback and directly returns result, in the form of a tuple (result, grade, problems, tests, custom, archive).