robokudo.utils.decorators

Decorator utilities for RoboKudo annotators.

This module provides decorators to extend annotator functionality.

module:

decorators

synopsis:

Decorator utilities for RoboKudo annotators

moduleauthor:

RoboKudo Team

Dependencies:
  • timeit

  • collections.defaultdict

  • robokudo.annotators.core

Functions:

Functions

timer_decorator(func)

Log execution time of decorated function.

record_time(func)

Record execution time of annotator method.

publish_variables(func)

Publish annotator variables after method execution.

Module Contents

robokudo.utils.decorators.timer_decorator(func)

Log execution time of decorated function.

Parameters:

func (callable) – Function to be timed

Returns:

Wrapped function that logs execution time

Return type:

callable

Example:

@timer_decorator
def my_function():
    # Function code here
    pass

Note

Uses rk_logger if available, otherwise prints to stdout

robokudo.utils.decorators.record_time(func)

Record execution time of annotator method.

Parameters:

func (callable) – Annotator method to time

Returns:

Wrapped method that records execution time

Return type:

callable

Example:

@record_time
def compute(self):
    # Method code here
    pass

Note

Only works on annotator instance methods

robokudo.utils.decorators.publish_variables(func)

Publish annotator variables after method execution.

Parameters:

func (callable) – Annotator method to wrap

Returns:

Wrapped method that publishes variables

Return type:

callable

Raises:

AssertionError – If not used on BaseAnnotator instance method

Example:

@publish_variables
def update(self):
    # Method code here
    pass

Note

Only works on BaseAnnotator instance methods