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_fake_inputs(inputs)[source]

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

Parameters:inputs – A set of input types
Returns:A set of input parameter names that are not available in inputs
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
get_matching_inputs(inputs)[source]

Get input types that are in inputs and satisfy this input

Parameters:inputs – A set of input types
Returns:A set of input parameter names that are available in inputs
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, pacman.executor.algorithm_decorators.AllOf, pacman.executor.algorithm_decorators.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, pacman.executor.algorithm_decorators.AllOf, pacman.executor.algorithm_decorators.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, required_input_tokens=None, optional_input_tokens=None, generated_output_tokens=None)[source]

Define an object to be a PACMAN algorithm that can be executed by the pacman.executor.pacman_algorithm_executor.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 pacman.executor.algorithm_decorators.OneOf or pacman.executor.algorithm_decorators.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 pacman.executor.algorithm_decorators.OneOf or pacman.executor.algorithm_decorators.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
  • required_input_tokens – A list of tokens required to have been generated before this algorithm runs
  • optional_input_tokens – A list of tokens that if generated by any algorithm, must have been generated before this algorithm runs
  • generated_output_tokens – A list of tokens generated by running this algorithm
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_fake_inputs(inputs)[source]

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

Parameters:inputs – A set of input types
Returns:A set of input parameter names that are not available in inputs
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
get_matching_inputs(inputs)[source]

Get input types that are in inputs and satisfy this input

Parameters:inputs – A set of input types
Returns:A set of input parameter names that are available in inputs
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_fake_inputs(inputs)[source]

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

Parameters:inputs – A set of input types
Returns:A set of input parameter names that are not available in inputs
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
get_matching_inputs(inputs)[source]

Get input types that are in inputs and satisfy this input

Parameters:inputs – A set of input types
Returns:A set of input parameter names that are available in inputs
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(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 – A set of input types
Returns:A set of input parameter names that are not available in inputs
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
get_matching_inputs(inputs)[source]

Get input types that are in inputs and satisfy this input

Parameters:inputs – A set of input types
Returns:A set of input parameter names that are available in inputs
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.token module

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

Bases: object

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

name
part

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 – A set of input types
Returns:A set of input parameter names that are not available in inputs
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
get_matching_inputs(inputs)[source]

Get input types that are in inputs and satisfy this input

Parameters:inputs – A set of input types
Returns:A set of input parameter names that are available in inputs
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

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 – 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 – A set of input types
Returns:A set of input parameter names that are not available in inputs
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
get_matching_inputs(inputs)[source]

Get input types that are in inputs and satisfy this input

Parameters:inputs – A set of input types
Returns:A set of input parameter names that are available in inputs
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

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 – 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 – A set of input types
Returns:A set of input parameter names that are not available in inputs
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
get_matching_inputs(inputs)[source]

Get input types that are in inputs and satisfy this input

Parameters:inputs – A set of input types
Returns:A set of input parameter names that are available in inputs
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

class pacman.executor.algorithm_decorators.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
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 – A set of input types
Returns:A set of input parameter names that are not available in inputs
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
get_matching_inputs(inputs)[source]

Get input types that are in inputs and satisfy this input

Parameters:inputs – A set of input types
Returns:A set of input parameter names that are available in inputs
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

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

Bases: object

Indicates that all of the items specified are required.

Parameters:items (str, pacman.executor.algorithm_decorators.AllOf, pacman.executor.algorithm_decorators.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 (str, pacman.executor.algorithm_decorators.AllOf, pacman.executor.algorithm_decorators.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]

Define an object to be a PACMAN algorithm that can be executed by the pacman.executor.pacman_algorithm_executor.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 pacman.executor.algorithm_decorators.OneOf or pacman.executor.algorithm_decorators.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 pacman.executor.algorithm_decorators.OneOf or pacman.executor.algorithm_decorators.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
  • required_input_tokens – A list of tokens required to have been generated before this algorithm runs
  • optional_input_tokens – A list of tokens that if generated by any algorithm, must have been generated before this algorithm runs
  • generated_output_tokens – 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 – A list of algorithm definitions
pacman.executor.algorithm_decorators.get_algorithms()[source]

Get the dict of known algorithm ID -> algorithm data

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 – 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

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.

name
part