law.job.dashboard#

Definition of the job dashboard interface.

Class BaseJobDashboard#

class BaseJobDashboard(max_rate=0)[source]#

Bases: object

Base class of a minimal job dashboard interface that is used from within law.workflow.remote.BaseRemoteWorkflow’s.

classattribute persistent_attributes#

type: list

List of instance attributes that should be marked as being persistent. This is (e.g.) used in the law.workflow.remote.BaseRemoteWorkflow when saving job and submission information to submission files. Common use cases are user information.

max_rate#

type: int

Maximum number of events that can be published per second. rate_guard() uses this value to delay function calls.

static cache_by_status(func)#

Decorator for BaseJobDashboard.publish() (and inheriting classes) that caches the last published status to decide if the a new publication is necessary or not. When the status did not change since the last call, the actual publish method is not invoked and None is returned.

get_persistent_config()[source]#

Returns the values of all persistent_attributes of this instance in a dictionary.

apply_config(config)[source]#

Sets all attributes in a dictionary config to this instance. This can be understand as the counterpart of get_persistent_config().

rate_guard()[source]#

Context guard that ensures that decorated contexts are delayed in order to limit the number of status publications per second, defined by max_rate. Example:

# print some numbers, which will take 10 / max_rate seconds
for i in range(10):
    with self.rate_guard():
        print(i)
remote_hook_file()[source]#

This method can return the path to a file that is considered as an input file to remote jobs. This file can contain bash functions, environment variables, etc., that are necessary to communicate with the implemented job dashboard. When None is returned, no file is sent.

remote_hook_data(job_num, attempt)[source]#

This method can return a dictionary that is sent with remote jobs in the format key1=value1 key2=value2 .... The returned dictionary should (but does not have to) include the job number job_num and the retry attempt.

create_tracking_url()[source]#

This method can return a tracking url that refers to a web page that visualizes jobs. When set, the url is shown in the central luigi scheduler.

abstract map_status(job_status, event)[source]#

Maps the job_status (see law.job.base.BaseJobManager) for a particular event to the status name that is accepted by the implemented job dashobard. Possible events are:

  • action.submit

  • action.cancel

  • status.pending

  • status.running

  • status.finished

  • status.retry

  • status.failed

abstract publish(job_data, event, job_num, *args, **kwargs)[source]#

Publishes the status of a job to the implemented job dashboard. job_data is a dictionary that contains a job_id and a status string (see law.workflow.remote.StatusData.job_data()).

Class NoJobDashboard#

class NoJobDashboard(max_rate=0)[source]#

Bases: BaseJobDashboard

Null job dashboard implementation. Instances of this class actually does not publish any job status. It can rather be used as a placeholder in situations where a job dashboard is required, such as in law.workflow.remote.BaseRemoteWorkflow.