pacman.executor.algorithm_decorators package

Module contents

class pacman.executor.algorithm_decorators.AbstractInput[source]

Bases: object

An abstract input to an algorithm

get_fake_inputs(inputs)[source]

Get input types that are not in inputs but which satisfy this input

Parameters:inputs (dict(str, ..)) – A set of input types
Returns:A set of input parameter names that are not available in inputs
Return type:set(str)
get_inputs_by_name(inputs)[source]

Get the inputs that match this input by parameter name

Parameters:inputs (dict(str, ..)) – A dict of type to value
Returns:A dict of parameter name to value
Return type:dict(str, ..)
get_matching_inputs(inputs)[source]

Get input types that are in inputs and satisfy this input

Parameters:inputs (dict(str, ..)) – A set of input types
Returns:A set of input parameter names that are available in inputs
Return type:set(str)
input_matches(inputs)[source]

Determine if this input is in the set of inputs

Parameters:inputs (dict(str, ..)) – A set of input types
Returns:True if this input type is in the list
Return type:bool
name

The name of the input

Return type:str
param_types

The types of the input

Return type:list(str)
class pacman.executor.algorithm_decorators.AllOfInput(inputs)[source]

Bases: pacman.executor.algorithm_decorators.abstract_input.AbstractInput

A composite input for which all input parameters must be matched.

Parameters:inputs (list(AbstractInput)) – The inputs that make up this input
get_fake_inputs(inputs)[source]

Get input types that are not in inputs but which satisfy this input

Parameters:inputs (dict(str, ..)) – A set of input types
Returns:A set of input parameter names that are not available in inputs
Return type:set(str)
get_inputs_by_name(inputs)[source]

Get the inputs that match this input by parameter name

Parameters:inputs (dict(str, ..)) – A dict of type to value
Returns:A dict of parameter name to value
Return type:dict(str, ..)
get_matching_inputs(inputs)[source]

Get input types that are in inputs and satisfy this input

Parameters:inputs (dict(str, ..)) – A set of input types
Returns:A set of input parameter names that are available in inputs
Return type:set(str)
input_matches(inputs)[source]

Determine if this input is in the set of inputs

Parameters:inputs (dict(str, ..)) – A set of input types
Returns:True if this input type is in the list
Return type:bool
name

The name of the input

Return type:str
param_types

The types of the input

Return type:list(str)
class pacman.executor.algorithm_decorators.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 (list(AbstractInput)) – The inputs that make up this input
get_fake_inputs(inputs)[source]

Get input types that are not in inputs but which satisfy this input

Parameters:inputs (dict(str, ..)) – A set of input types
Returns:A set of input parameter names that are not available in inputs
Return type:set(str)
get_inputs_by_name(inputs)[source]

Get the inputs that match this input by parameter name

Parameters:inputs (dict(str, ..)) – A dict of type to value
Returns:A dict of parameter name to value
Return type:dict(str, ..)
get_matching_inputs(inputs)[source]

Get input types that are in inputs and satisfy this input

Parameters:inputs (dict(str, ..)) – A set of input types
Returns:A set of input parameter names that are available in inputs
Return type:set(str)
input_matches(inputs)[source]

Determine if this input is in the set of inputs

Parameters:inputs (dict(str, ..)) – A set of input types
Returns:True if this input type is in the list
Return type:bool
name

The name of the input

Return type:str
param_types

The types of the input

Return type:list(str)
class pacman.executor.algorithm_decorators.Output(output_type, file_name_type=None)[source]

Bases: object

Represents an output from an algorithm.

Parameters:
  • output_type (str) – The type of the output
  • file_name_type (str or None) – If the output is file based, the type of the input holding the file name
file_name_type
output_type
class pacman.executor.algorithm_decorators.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(str)) – The ordered possible types of the input parameter
get_fake_inputs(inputs)[source]

Get input types that are not in inputs but which satisfy this input

Parameters:inputs (dict(str, ..)) – A set of input types
Returns:A set of input parameter names that are not available in inputs
Return type:set(str)
get_inputs_by_name(inputs)[source]

Get the inputs that match this input by parameter name

Parameters:inputs (dict(str, ..)) – A dict of type to value
Returns:A dict of parameter name to value
Return type:dict(str, ..)
get_matching_inputs(inputs)[source]

Get input types that are in inputs and satisfy this input

Parameters:inputs (dict(str, ..)) – A set of input types
Returns:A set of input parameter names that are available in inputs
Return type:set(str)
input_matches(inputs)[source]

Determine if this input is in the set of inputs

Parameters:inputs (dict(str, ..)) – A set of input types
Returns:True if this input type is in the list
Return type:bool
name

The name of the input

Return type:str
param_types

The types of the input

Return type:list(str)
class pacman.executor.algorithm_decorators.AllOf(*items)[source]

Bases: object

Indicates that all of the items specified are required.

Parameters:items (list(str or AllOf or OneOf)) – The items required
items

The items specified

real_class

The AbstractInput class to use for this input

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

Bases: object

Indicates that one of the items specified is required.

Parameters:items (list(str or AllOf or OneOf)) – The items required
items

The items specified

real_class

The AbstractInput class to use for this input

pacman.executor.algorithm_decorators.algorithm(input_definitions, outputs, algorithm_id=None, required_inputs=None, optional_inputs=None, method=None, required_input_tokens=None, optional_input_tokens=None, generated_output_tokens=None)[source]
A decorator that defines 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(str, str or list(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(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(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(str or OneOf or AllOf)) – Optional list of optional algorithm parameter names; if not specified those parameters which have default values are used.
  • method (str or None) – 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
  • required_input_tokens (list(Token)) – A list of tokens required to have been generated before this algorithm runs
  • optional_input_tokens (list(Token)) – A list of tokens that if generated by any algorithm, must have been generated before this algorithm runs
  • generated_output_tokens (list(Token)) – A list of tokens generated by running this algorithm
pacman.executor.algorithm_decorators.algorithms(algorithms)[source]

Specify multiple algorithms for a single class or function

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

Get the dict of known algorithm ID -> algorithm data

Return type:dict(str, AbstractAlgorithm)
pacman.executor.algorithm_decorators.reset_algorithms()[source]

Reset the known algorithms

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

Scan packages for algorithms

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

A dict of algorithm name -> algorithm data

Return type:

dict(str, AbstractAlgorithm)

class pacman.executor.algorithm_decorators.Token(name, part=None)[source]

Bases: object

A token in the algorithm flow that indicates a process or part of a process.

Parameters:
  • name (str) – The name of the token
  • part (str or None) – The part of the token, or None if no part
name
part