Monitors

class pikos.monitors.function_monitor.FunctionRecord[source]

Bases: pikos.monitors.function_monitor.FunctionRecord

classmethod header()[source]

Return a formatted header line

line()[source]

Return a formatted header line


class pikos.monitors.function_monitor.FunctionMonitor(recorder)[source]

Bases: pikos.monitors.monitor.Monitor

Record python function events.

The class hooks on the setprofile function to receive function events and record them.

Private

_recorder = object

A recorder object that implementes the AbstractRecorder interface.

_profiler = object

An instance of the ProfilerFunctions utility class that is used to set and unset the setprofile function as required by the monitor.

_index = int

The current zero based record index. Each function event will increase the index by one.

_call_tracker = object

An instance of the keep_track utility class to keep track of recursive calls to the monitor’s __enter__() and __exit__() methods.

__init__(recorder)[source]

Initialize the monitoring class.

Parameters:recorder (object) – A subclass of AbstractRecorder or a class that implements the same interface to handle the values to be logged.
__enter__()

The entry point of the context manager.

Default implementation is calling enable().

__exit__(exc_type, exc_val, exc_tb)

The exit point of the context manager.

Default implementation is calling disable().

enable()[source]

Enable the monitor.

The first time the method is called (the context is entered) it will set the setprofile hooks and initialize the recorder.

disable()[source]

Disable the monitor.

The last time the method is called (the context is exited) it will unset the setprofile hooks and finalize the recorder.

on_function_event(frame, event, arg)[source]

Record the current function event.

Called on function events, it will retrieve the necessary information from the frame, create a FunctionRecord and send it to the recorder.

_abc_cache = <_weakrefset.WeakSet object at 0x12d55d0>
_abc_negative_cache = <_weakrefset.WeakSet object at 0x12d5250>
_abc_negative_cache_version = 20
_abc_registry = <_weakrefset.WeakSet object at 0x12d5910>
class pikos.monitors.focused_function_monitor.FunctionMonitor(recorder)

Bases: pikos.monitors.monitor.Monitor

Record python function events.

The class hooks on the setprofile function to receive function events and record them.

Private

_recorder = object

A recorder object that implementes the AbstractRecorder interface.

_profiler = object

An instance of the ProfilerFunctions utility class that is used to set and unset the setprofile function as required by the monitor.

_index = int

The current zero based record index. Each function event will increase the index by one.

_call_tracker = object

An instance of the keep_track utility class to keep track of recursive calls to the monitor’s __enter__() and __exit__() methods.

FocusedFunctionMonitor.__init__(*arguments, **keywords)

Initialize the monitoring class.

Parameters:
  • *arguments (list) – The list of arguments required by the base monitor. They will be passed on the super class of the mixing
  • **keywords (dict) – Dictionary of keyword arguments. The functions keyword if defined should be a list of function or method objects inside which recording will take place.
FocusedFunctionMonitor.__enter__()

The entry point of the context manager.

Default implementation is calling enable().

FocusedFunctionMonitor.__exit__(exc_type, exc_val, exc_tb)

The exit point of the context manager.

Default implementation is calling disable().

enable()

Enable the monitor.

The first time the method is called (the context is entered) it will set the setprofile hooks and initialize the recorder.

disable()

Disable the monitor.

The last time the method is called (the context is exited) it will unset the setprofile hooks and finalize the recorder.

on_function_event(frame, event, arg)

Record the current function event.

Called on function events, it will retrieve the necessary information from the frame, create a FunctionRecord and send it to the recorder.

_abc_cache = <_weakrefset.WeakSet object at 0x12d55d0>
_abc_negative_cache = <_weakrefset.WeakSet object at 0x12d5250>
_abc_negative_cache_version = 20
_abc_registry = <_weakrefset.WeakSet object at 0x12d5910>



class pikos.monitors.line_monitor.LineRecord[source]

Bases: pikos.monitors.line_monitor.LineRecord

classmethod header()[source]

Return a formatted header line

line()[source]

Return a formatted header line


class pikos.monitors.line_monitor.LineMonitor(recorder)[source]

Bases: pikos.monitors.monitor.Monitor

Record python line events.

The class hooks on the settrace function to receive trace events and record when a line of code is about to be executed.

Private

_recorder = object

A recorder object that implementes the AbstractRecorder interface.

_tracer = object

An instance of the TraceFunctionManager utility class that is used to set and unset the settrace function as required by the monitor.

_index = int

The current zero based record index. Each line trace event will increase the index by one.

_call_tracker = object

An instance of the keep_track utility class to keep track of recursive calls to the monitor’s __enter__() and __exit__() methods.

__init__(recorder)[source]

Initialize the monitoring class.

Parameters:recorder (object) – A subclass of AbstractRecorder or a class that implements the same interface to handle the values to be recorded.
__enter__()

The entry point of the context manager.

Default implementation is calling enable().

__exit__(exc_type, exc_val, exc_tb)

The exit point of the context manager.

Default implementation is calling disable().

enable()[source]

Enable the monitor.

The first time the method is called (the context is entered) it will set the settrace hook and initialize the recorder.

disable()[source]

Disable the monitor.

The last time the method is called (the context is exited) it will unset the settrace hook and finalize the recorder.

on_line_event(frame, why, arg)[source]

Record the current line trace event.

Called on trace events and when they refer to line traces, it will retrieve the necessary information from the frame, create a LineRecord and send it to the recorder.

_abc_cache = <_weakrefset.WeakSet object at 0x2124410>
_abc_negative_cache = <_weakrefset.WeakSet object at 0x2124490>
_abc_negative_cache_version = 20
_abc_registry = <_weakrefset.WeakSet object at 0x2124350>
class pikos.monitors.focused_line_monitor.FocusedLineMonitor(*arguments, **keywords)[source]

Bases: pikos.monitors.focused_line_mixin.FocusedLineMixin, pikos.monitors.line_monitor.LineMonitor

Record python line events.

The class hooks on the settrace function to receive trace events and record when a line of code is about to be executed. The events are recorded only when the interpreter is working inside the functions that are provided in the functions attribute.

Public

functions = FunctionSet

A set of function or method objects inside which recording will take place.

Private

_recorder = object

A recorder object that implementes the AbstractRecorder interface.

_tracer = object

An instance of the TraceFunctionManager utility class that is used to set and unset the settrace function as required by the monitor.

_index = int

The current zero based record index. Each line trace event will increase the index by one.

_call_tracker = object

An instance of the keep_track utility class to keep track of recursive calls to the monitor’s __enter__() and __exit__() methods.

_code_trackers = dictionary

A dictionary of KeepTrack instances associated with the code object of each function in functions. It is used to keep track and check that we are inside the execution of one these functions when we record data.

__init__(*arguments, **keywords)

Initialize the monitoring class.

Parameters:
  • *arguments (list) – The list of arguments required by the base monitor. They will be passed on the super class of the mixing
  • **keywords (dict) – Dictionary of keyword arguments. The functions keyword if defined should be a list of function or method objects inside which recording will take place.
__enter__()

The entry point of the context manager.

Default implementation is calling enable().

__exit__(exc_type, exc_val, exc_tb)

The exit point of the context manager.

Default implementation is calling disable().

_abc_cache = <_weakrefset.WeakSet object at 0x2197a50>
_abc_negative_cache = <_weakrefset.WeakSet object at 0x2197950>
_abc_negative_cache_version = 20
_abc_registry = <_weakrefset.WeakSet object at 0x2192990>