pacman.executor.algorithm_decorators package

Submodules

pacman.executor.algorithm_decorators.abstract_input module

class pacman.executor.algorithm_decorators.abstract_input.AbstractInput[source]

Bases: object

An abstract input to an algorithm

get_inputs_by_name(inputs)[source]

Get the inputs that match this input by parameter name

Parameters:inputs – A dict of type to value
Returns:A dict of parameter name to value
Return type:dict
input_matches(inputs)[source]

Determine if this input is in the set of inputs

Parameters:inputs – A set of input types
Returns:True if this input type is in the list
name

The name of the input

param_types

The types of the input

pacman.executor.algorithm_decorators.algorithm_decorator module

class pacman.executor.algorithm_decorators.algorithm_decorator.AllOf(*items)[source]

Bases: object

Indicates that all of the items specified are required

Parameters:items (str, AllOf, OneOf) – The items required
items

The items specified

real_class

The AbstractInput class to use for this input

class pacman.executor.algorithm_decorators.algorithm_decorator.OneOf(*items)[source]

Bases: object

Indicates that one of the items specified is required

Parameters:items (str, AllOf, OneOf) – The items required
items

The items specified

real_class

The AbstractInput class to use for this input

pacman.executor.algorithm_decorators.algorithm_decorator.algorithm(input_definitions, outputs, algorithm_id=None, required_inputs=None, optional_inputs=None, method=None)[source]

Define an object to be a PACMAN algorithm that can be executed by the PacmanAlgorithmExecutor.

Can be used to decorate either a class or a function (not a method). If this decorates a class, the class must be callable (i.e. have a __call__ method), or else a method must be specified to call to run the algorithm.

The inputs and outputs referenced below refer to the parameters of the method or function.

Parameters:
  • input_definitions (dict of str -> (str or list of str)) – dict of algorithm parameter name to list of types, one for each required algorithm parameter, and one for each optional parameter that is used in this algorithm call
  • outputs (list of str) – A list of types output from the algorithm that must match the order in which they are returned.
  • algorithm_id (str) – Optional unique id of the algorithm; if not specified, the name of the class or function is used.
  • required_inputs (list of (str or OneOf or AllOf)) – Optional list of required algorithm parameter names; if not specified those parameters which have no default values are used.
  • optional_inputs (list of (str or OneOf or AllOf)) – Optional list of optional algorithm parameter names; if not specified those parameters which have default values are used.
  • method – The optional name of the method to call if decorating a class; if not specified, __call__ is used (i.e. it is assumed to be callable). Must not be used if decorating a function
pacman.executor.algorithm_decorators.algorithm_decorator.algorithms(algorithms)[source]

Specify multiple algorithms for a single class or function

Parameters:algorithms – A list of algorithm definitions
pacman.executor.algorithm_decorators.algorithm_decorator.get_algorithms()[source]

Get the dict of known algorithm id -> algorithm data

pacman.executor.algorithm_decorators.algorithm_decorator.reset_algorithms()[source]

Reset the known algorithms

pacman.executor.algorithm_decorators.algorithm_decorator.scan_packages(packages, recursive=True)[source]

Scan packages for algorithms

Parameters:
  • packages – The names of the packages to scan (using dotted notation), or the actual package modules
  • recursive – True if sub-packages should be examined
Returns:

A dict of algorithm name -> algorithm data

pacman.executor.algorithm_decorators.all_of_input module

class pacman.executor.algorithm_decorators.all_of_input.AllOfInput(inputs)[source]

Bases: pacman.executor.algorithm_decorators.abstract_input.AbstractInput

A composite input for which all input parameters must be matched

Parameters:inputs – The inputs that make up this input
get_inputs_by_name(inputs)[source]

Get the inputs that match this input by parameter name

Parameters:inputs – A dict of type to value
Returns:A dict of parameter name to value
Return type:dict
input_matches(inputs)[source]

Determine if this input is in the set of inputs

Parameters:inputs – A set of input types
Returns:True if this input type is in the list
name

The name of the input

param_types

The types of the input

pacman.executor.algorithm_decorators.one_of_input module

class pacman.executor.algorithm_decorators.one_of_input.OneOfInput(inputs)[source]

Bases: pacman.executor.algorithm_decorators.abstract_input.AbstractInput

An input for which one of the input parameters must be matched

Parameters:inputs – The inputs that make up this input
get_inputs_by_name(inputs)[source]

Get the inputs that match this input by parameter name

Parameters:inputs – A dict of type to value
Returns:A dict of parameter name to value
Return type:dict
input_matches(inputs)[source]

Determine if this input is in the set of inputs

Parameters:inputs – A set of input types
Returns:True if this input type is in the list
name

The name of the input

param_types

The types of the input

pacman.executor.algorithm_decorators.output module

class pacman.executor.algorithm_decorators.output.Output(output_type, file_name_type=None)[source]

Bases: object

Represents an output from an algorithm

Parameters:
  • output_type – The type of the output
  • file_name_type – If the output is file based, the type of the input holding the file name
file_name_type
output_type

pacman.executor.algorithm_decorators.single_input module

class pacman.executor.algorithm_decorators.single_input.SingleInput(name, param_types)[source]

Bases: pacman.executor.algorithm_decorators.abstract_input.AbstractInput

An input that is just one item

Parameters:
  • name (str) – The name of the input parameter
  • param_types (list of str) – The ordered possible types of the input parameter
get_inputs_by_name(inputs)[source]

Get the inputs that match this input by parameter name

Parameters:inputs – A dict of type to value
Returns:A dict of parameter name to value
Return type:dict
input_matches(inputs)[source]

Determine if this input is in the set of inputs

Parameters:inputs – A set of input types
Returns:True if this input type is in the list
name

The name of the input

param_types

The types of the input

Module contents