flux.job.validator.validator module

class flux.job.validator.validator.JobValidator(argv, pluginpath=None, parser=None)

Bases: object

A plugin-based job validator class

JobValidator loads plugins that implenment the ValidatorPlugin interface from the 'flux.job.validator.plugins' namespace. Plugins may be configured at runtime by passing in a --plugins=LIST option

default_validators = ['jobspec']
plugin_namespace = 'flux.job.validator.plugins'
start()

Select and configure plugins, start executor, etc.

validate(jobinfo)

Validate jobinfo using all loaded validators

Parameters:jobinfo (ValidatorJobInfo) -- A ValidatorJobInfo object which describes the job to be validated.
Returns:ValidatorResult

If any one validator plugin fails, then result will indicate failure.

class flux.job.validator.validator.ValidatorJobInfo(jobinfo)

Bases: object

An instance of a Flux job specification used by job validators

jobspec

Submitted jobspec in Python dict form

Type:dict
userid

Submitting user id

Type:int
flags

Job flags supplied during submission

Type:int
urgency

Job urgency

Type:int
flux

On-demand, per-thread Flux handle

Type:Flux
tls = <_thread._local object>
class flux.job.validator.validator.ValidatorPlugin(parser)

Bases: abc.ABC

Base class for Validator Plugins

configure(args)

Configure a ValidatorPlugin. Run after argparse.parse_args()

Parameters:
  • args (Namespace) -- The resulting Namespace after calling
  • argparse.parse_args() --
validate(job)

Validate a job. A ValidatorPlugin must implement this method

If a job fails validation, this method should either throw an exception, which will be caught by the calling script, or a (errnum, errmsg) tuple may optionally be returned, if that is more convenient.

On success, this method should return nothing or explicitly:

(0, None)
Parameters:job (ValidatorJobInfo) -- the job to validate
Returns:None or (errnum, errmsg) tuple.
class flux.job.validator.validator.ValidatorResult

Bases: object

Container for result or results from the JobValidator validate method

errmsg

comma-separated string list of all error messages

Type:str
push_result(errnum, errmsg=None)

Add a result from one validator to a ValidatorResult

Parameters:
  • errnum (int) -- error number (0 for success)
  • errmsg (str, optional) -- An optional error messsage for a failed result.
success

True if job validated successfully, False otherwise

Type:bool
flux.job.validator.validator.import_path(file_path)
flux.job.validator.validator.import_plugins(pkg_name, pluginpath=None)

Load plugins from a namespace package and optional additional paths

A plugin in pluginpath with the same name as an existing plugin will take precedence

flux.job.validator.validator.import_plugins_pkg(ns_pkg)

Import all modules found in the namespace package ns_pkg