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

Enter the monitor context.

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

__exit__(exc_type, exc_val, exc_tb)[source]

Exit the monitor context.

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.

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__()

Enter the monitor context.

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

FocusedFunctionMonitor.__exit__(exc_type, exc_val, exc_tb)

Exit the monitor context.

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.


class pikos.monitors.function_memory_monitor.FunctionMemoryRecord[source]

Bases: pikos.monitors.function_memory_monitor.FunctionMemoryRecord

classmethod header()[source]

Return a formatted header line.

line()[source]

Return a formatted header line


class pikos.monitors.function_memory_monitor.FunctionMemoryMonitor(recorder)[source]

Bases: pikos.monitors.monitor.Monitor

Record process memory on python function events.

The class hooks on the setprofile function to receive function events and record the current process memory when they happen.

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.

_process = object

An instanse of psutil.Process for the current process, used to get memory information in a platform independent way.

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

Enter the monitor context.

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

__exit__(exc_type, exc_val, exc_tb)[source]

Exit the monitor context.

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

on_function_event(frame, event, arg)[source]

Record the process memory usage during the current function event.

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

class pikos.monitors.focused_function_memory_monitor.FocusedFunctionMemoryMonitor(*arguments, **keywords)[source]

Bases: pikos.monitors.focused_function_mixin.FocusedFunctionMixin, pikos.monitors.function_memory_monitor.FunctionMemoryMonitor

Record process memory on python function events.

The class hooks on the setprofile function to receive function events and record while inside the provided functions the current process memory when they happen.

Public

functions = FunctionSet

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

Private

_recorder = object

A recorder object that implements 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.

_process = object

An instance of psutil.Process for the current process, used to get memory information in a platform independent way.

_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__()

Enter the monitor context.

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

__exit__(exc_type, exc_val, exc_tb)

Exit the monitor context.

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


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

Enter the monitor context.

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

__exit__(exc_type, exc_val, exc_tb)[source]

Exit the monitor context.

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.

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__()

Enter the monitor context.

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

__exit__(exc_type, exc_val, exc_tb)

Exit the monitor context.

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


class pikos.monitors.line_memory_monitor.LineMemoryRecord[source]

Bases: pikos.monitors.line_memory_monitor.LineMemoryRecord

classmethod header()[source]

Return a formatted header line

line()[source]

Return a formatted header line


class pikos.monitors.line_memory_monitor.LineMemoryMonitor(recorder)[source]

Bases: pikos.monitors.monitor.Monitor

Record process memory on python function events.

The class hooks on the settrace function to receive trace events and record the current process memory 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 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.

_process = object

An instanse of psutil.Process for the current process, used to get memory information in a platform independent way.

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

Enter the monitor context.

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

__exit__(exc_type, exc_val, exc_tb)[source]

Exit the monitor context.

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

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 and get the current memory info, create a LineMemoryRecord and send it to the recorder.

class pikos.monitors.focused_line_memory_monitor.FocusedLineMemoryMonitor(*arguments, **keywords)[source]

Bases: pikos.monitors.focused_line_mixin.FocusedLineMixin, pikos.monitors.line_memory_monitor.LineMemoryMonitor

Record process memory on python function events.

The class hooks on the settrace function to receive trace events and record the current process memory 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 implements 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 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.

_process = object

An instanse of psutil.Process for the current process, used to get memory information in a platform independent way.

_code_trackers: dict
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__()

Enter the monitor context.

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

__exit__(exc_type, exc_val, exc_tb)

Exit the monitor context.

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

Previous topic

Library Reference

Next topic

Recorders

This Page