pacman.executor package

Submodules

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
decode_algorithm_data_objects()[source]
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: Exception

Raised when there is an error with injection.

pacman.executor.injection_decorator.clear_injectables()[source]

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.

Parameters:
  • 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
pacman.executor.injection_decorator.inject(type_to_inject)[source]

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
pacman.executor.injection_decorator.inject_items(types)[source]

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
pacman.executor.injection_decorator.provide_injectables(injectables)[source]

Set the objects from which values should be injected into methods

Parameters:injectables – A dict of type to value
pacman.executor.injection_decorator.requires_injection(types_required)[source]

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(str)) – A list of types that must have been injected
pacman.executor.injection_decorator.supports_injection(injectable_class)[source]

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, tokens, required_output_tokens, 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, provenance_path=None, provenance_name=None)[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.

Parameters:
  • 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
  • tokens – A list of tokens that should be considered to have been generated
  • required_output_tokens – A list of tokens that should be generated by the end of the run
  • 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
  • provenance_path – Path to file to append full provenance data to If None no provenance is written
algorithm_timings
execute_mapping()[source]

Executes the algorithms

Return type:None
get_completed_tokens()[source]

Get all of the tokens that have completed as part of this execution

Returns:A list of tokens
get_item(item_type)[source]

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

Get all the outputs from a execution

Returns:dictionary of types as keys and values.

pacman.executor.token_states module

class pacman.executor.token_states.TokenStates[source]

Bases: object

Keeps track of multiple token state objects to determine if they are complete

get_completed_tokens()[source]

Get a list of tokens that have been completed

is_token_complete(token)[source]

True if the given token has completed

is_tracking_token(token)[source]

Determine if the token is being tracked

process_output_token(output_token)[source]

Process an output token marking a process or part as complete

track_token(token)[source]

Start tracking a token

Module contents

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

Bases: object

Converts an XML file into algorithm data.

Parameters:xml_paths – paths to extra metadata files
Return type:None
decode_algorithm_data_objects()[source]
Returns:the algorithm data objects which represent all the algorithm’s inputs and outputs
class pacman.executor.PACMANAlgorithmExecutor(algorithms, optional_algorithms, inputs, required_outputs, tokens, required_output_tokens, 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, provenance_path=None, provenance_name=None)[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.

Parameters:
  • 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
  • tokens – A list of tokens that should be considered to have been generated
  • required_output_tokens – A list of tokens that should be generated by the end of the run
  • 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
  • provenance_path – Path to file to append full provenance data to If None no provenance is written
algorithm_timings
execute_mapping()[source]

Executes the algorithms

Return type:None
get_completed_tokens()[source]

Get all of the tokens that have completed as part of this execution

Returns:A list of tokens
get_item(item_type)[source]

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

Get all the outputs from a execution

Returns:dictionary of types as keys and values.