pacman.executor package


pacman.executor.algorithm_metadata_xml_reader module

class pacman.executor.algorithm_metadata_xml_reader.AlgorithmMetadataXmlReader(xml_paths)[source]

Bases: object

Converts an XML file into algorithm data

Parameters:xml_paths – paths to extra metadata files
Return type:None
Returns:the algorithm data objects which represent all the algorithm’s inputs and outputs

pacman.executor.injection_decorator module

exception pacman.executor.injection_decorator.InjectionException[source]

Bases: exceptions.Exception

Raised when there is an error with injection


Clear the current set of injectables

pacman.executor.injection_decorator.do_injection(objects_to_inject, objects_to_inject_into=None)[source]

Perform the actual injection of objects

  • objects_to_inject (dict(str)->object) – The objects to be injected as a dict of type name -> object of type
  • objects_to_inject_into (list) – The objects whose classes support_injection, or None to use all instances that have been created

Marks a method as something to be called to inject an object of the given type. The type is just a name for the type, and should match up at some point with some generated data

Parameters:type_to_inject – The type to be injected using this method

Indicates values that need to be injected into the method

Parameters:types – A dict of method argument name to type name to be injected
class pacman.executor.injection_decorator.injection_context(injection_dictionary)[source]

Bases: object

Provides a context for injection to use with “with”

Parameters:injection_dictionary – The dictionary of items to inject whilst in the context

Set the objects from which values should be injected into methods

Parameters:injectables – A dict of type to value

Indicates that injection of the given types is required before this method is called; an Exception is raised if the types have not been injected

Parameters:types_required (list of str) – A list of types that must have been injected

Indicate that the class has methods on which objects can be injected

pacman.executor.pacman_algorithm_executor module

class pacman.executor.pacman_algorithm_executor.PACMANAlgorithmExecutor(algorithms, optional_algorithms, inputs, required_outputs, xml_paths=None, packages=None, do_timings=True, print_timings=False, do_immediate_injection=True, do_post_run_injection=False, inject_inputs=True, do_direct_injection=True, use_unscanned_annotated_algorithms=True)[source]

Bases: object

An executor of PACMAN algorithms where the order is deduced from the input and outputs of the algorithm using an XML description of the algorithm

  • algorithms – A list of algorithms that must all be run
  • optional_algorithms – A list of algorithms that must be run if their inputs are available
  • inputs – A dict of input type to value
  • required_outputs – A list of output types that must be generated
  • xml_paths – An optional list of paths to XML files containing algorithm descriptions; if not specified, only detected algorithms will be used (or else those found in packages)
  • packages – An optional list of packages to scan for decorated algorithms; if not specified, only detected algorithms will be used (or else those specified in packages
  • do_timings – True if timing information should be printed after each algorithm, False otherwise
  • do_immediate_injection – Perform injection with objects as they are created; can result in multiple calls to the same inject-annotated methods
  • do_post_run_injection – Perform injection at the end of the run. This will only set the last object of any type created.
  • inject_inputs – True if inputs should be injected; only active if one of do_immediate_injection or do_post_run_injection is True. These variables define when the injection of inputs is done; if immediate injection is True, injection of inputs is done at the start of the run, otherwise it is done at the end.
  • do_direct_injection – True if direct injection into methods should be supported. This will allow any of the inputs or generated outputs to be injected into a method
  • use_unscanned_annotated_algorithms – True if algorithms that have been detected outside of the packages argument specified above should be used

Executes the algorithms

Return type:None

Get an item from the outputs of the execution

Parameters:item_type – the item from the internal type mapping to be returned
Returns:the returned item

Get all the outputs from a execution

Returns:dictionary of types as keys and values.

Module contents