pacman.executor.algorithm_classes package

Module contents

class pacman.executor.algorithm_classes.AbstractAlgorithm(algorithm_id, required_inputs, optional_inputs, outputs, required_input_tokens, optional_input_tokens, generated_output_tokens)

Bases: object

Represents the metadata for an algorithm.

Parameters:
  • algorithm_id (str) – The unique ID of the algorithm
  • required_inputs (list(AbstractInput)) – The inputs required by the algorithm
  • optional_inputs (list(AbstractInput)) – The optional inputs for the algorithm, which will be provided when available
  • outputs (list(Output)) – The output types of the algorithm
  • required_input_tokens (list(Token)) – Tokens required to have been generated before this algorithm can start
  • optional_input_tokens (list(Token)) – Tokens required to have been generated before this algorithm can start if and only if at least one algorithm generates the token
  • generated_output_tokens (list(Token)) – Tokens generated by this algorithm
algorithm_id

The ID for this algorithm

Return type:str
call(inputs)[source]

Call the algorithm with the given inputs and return the outputs

Parameters:inputs (dict(str, ..)) – A dict of input type -> value
Returns:A dict of output type -> value
Return type:dict(str, ..)
generated_output_tokens

The generated output tokens of the algorithm

optional_input_tokens

The optional input tokens of the algorithm

Return type:list(Token)
optional_inputs

The optional inputs of the algorithm

Return type:list(AbstractInput)
outputs

The outputs of the algorithm

Return type:list(Output)
required_input_tokens

The required input tokens of the algorithm

Return type:list(Token)
required_inputs

The required inputs of the algorithm

Return type:list(AbstractInput)
write_provenance_header(provenance_file)[source]

Writes the header info for this algorithm So things like name, module, class, function and command_line_arguments

But not anything about input and outputs as this is done elsewhere

Parameters:provenance_file (FileIO) – File to write to
class pacman.executor.algorithm_classes.AbstractPythonAlgorithm(algorithm_id, required_inputs, optional_inputs, outputs, required_input_tokens, optional_input_tokens, generated_output_tokens, python_module)

Bases: pacman.executor.algorithm_classes.AbstractAlgorithm

An algorithm written in Python.

Parameters:
  • algorithm_id (str) – The unique ID of the algorithm
  • required_inputs (list(AbstractInput)) – The inputs required by the algorithm
  • optional_inputs (list(AbstractInput)) – The optional inputs for the algorithm, which will be provided when available
  • outputs (list(Output)) – The output types of the algorithm
  • required_input_tokens (list(Token)) – Tokens required to have been generated before this algorithm can start
  • optional_input_tokens (list(Token)) – Tokens required to have been generated before this algorithm can start if and only if at least one algorithm generates the token
  • generated_output_tokens (list(Token)) – Tokens generated by this algorithm
  • python_module (str) – The module containing the python code to execute
call(inputs)[source]

Call the algorithm with the given inputs and return the outputs

Parameters:inputs (dict(str, ..)) – A dict of input type -> value
Returns:A dict of output type -> value
Return type:dict(str, ..)
call_python(inputs)[source]

Call the algorithm

Parameters:inputs (dict(str, ..)) – A dict of parameter name -> value
Returns:The result of calling the Python algorithm
class pacman.executor.algorithm_classes.ExternalAlgorithm(algorithm_id, required_inputs, optional_inputs, outputs, required_input_tokens, optional_input_tokens, generated_output_tokens, command_line_arguments)

Bases: pacman.executor.algorithm_classes.AbstractAlgorithm

An algorithm which is external to the SpiNNaker software, or rather its wrapper into PACMAN.

Parameters:
  • algorithm_id (str) – The unique ID of the algorithm
  • required_inputs (list(AbstractInput)) – The inputs required by the algorithm
  • optional_inputs (list(AbstractInput)) – The optional inputs for the algorithm, which will be provided when available
  • outputs (list(Output)) – The output types of the algorithm
  • required_input_tokens (list(Token)) – Tokens required to have been generated before this algorithm can start
  • optional_input_tokens (list(Token)) – Tokens required to have been generated before this algorithm can start if and only if at least one algorithm generates the token
  • generated_output_tokens (list(Token)) – Tokens generated by this algorithm
  • command_line_arguments (list(str)) –

    The command line to call

call(inputs)[source]

Call the algorithm with the given inputs and return the outputs

Parameters:inputs (dict(str, ..)) – A dict of input type -> value
Returns:A dict of output type -> value
Return type:dict(str, ..)
write_provenance_header(provenance_file)[source]

Writes the header info for this algorithm So things like name, module, class, function and command_line_arguments

But not anything about input and outputs as this is done elsewhere

Parameters:provenance_file (FileIO) – File to write to
class pacman.executor.algorithm_classes.PythonClassAlgorithm(algorithm_id, required_inputs, optional_inputs, outputs, required_input_tokens, optional_input_tokens, generated_output_tokens, python_module, python_class, python_method=None)

Bases: pacman.executor.algorithm_classes.AbstractPythonAlgorithm

An algorithm that is a class.

Parameters:
  • algorithm_id (str) – The unique ID of the algorithm
  • required_inputs (list(AbstractInput)) – The inputs required by the algorithm
  • optional_inputs (list(AbstractInput)) – The optional inputs for the algorithm, which will be provided when available
  • outputs (list(Output)) – The output types of the algorithm
  • required_input_tokens (list(Token)) – Tokens required to have been generated before this algorithm can start
  • optional_input_tokens (list(Token)) – Tokens required to have been generated before this algorithm can start if and only if at least one algorithm generates the token
  • generated_output_tokens (list(Token)) – Tokens generated by this algorithm
  • python_module (str) – The module containing the python code to execute
  • python_class (str) – The class of the algorithm
  • python_method (str or None) – The method of the algorithm, or None if the class is callable
call_python(inputs)[source]

Call the algorithm

Parameters:inputs (dict(str, ..)) – A dict of parameter name -> value
Returns:The result of calling the Python algorithm
write_provenance_header(provenance_file)[source]

Writes the header info for this algorithm So things like name, module, class, function and command_line_arguments

But not anything about input and outputs as this is done elsewhere

Parameters:provenance_file (FileIO) – File to write to
class pacman.executor.algorithm_classes.PythonFunctionAlgorithm(algorithm_id, required_inputs, optional_inputs, outputs, required_input_tokens, optional_input_tokens, generated_output_tokens, python_module, python_function)

Bases: pacman.executor.algorithm_classes.AbstractPythonAlgorithm

An algorithm that is a function.

Parameters:
  • algorithm_id (str) – The unique ID of the algorithm
  • required_inputs (list(AbstractInput)) – The inputs required by the algorithm
  • optional_inputs (list(AbstractInput)) – The optional inputs for the algorithm, which will be provided when available
  • outputs (list(Output)) – The output types of the algorithm
  • required_input_tokens (list(Token)) – Tokens required to have been generated before this algorithm can start
  • optional_input_tokens (list(Token)) – Tokens required to have been generated before this algorithm can start if and only if at least one algorithm generates the token
  • generated_output_tokens (list(Token)) – Tokens generated by this algorithm
  • python_module (str) – The module containing the python code to execute
  • python_function (str) – The name of the function to call
call_python(inputs)[source]

Call the algorithm

Parameters:inputs (dict(str, ..)) – A dict of parameter name -> value
Returns:The result of calling the Python algorithm
write_provenance_header(provenance_file)[source]

Writes the header info for this algorithm So things like name, module, class, function and command_line_arguments

But not anything about input and outputs as this is done elsewhere

Parameters:provenance_file (FileIO) – File to write to