Monitors¶
- class pikos.monitors.function_monitor.FunctionMonitor(recorder, record_type=None)[source]¶
Bases: pikos.monitors.monitor.Monitor
Record python function events.
The class hooks on the setprofile function to receive function events and record them.
- __init__(recorder, record_type=None)[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.
- record_type (type) – A class object to be used for records. Default is FunctionRecord.
- 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.
- class pikos.monitors.focused_function_monitor.FocusedFunctionMonitor(*arguments, **keywords)[source]¶
Bases: pikos.monitors.focused_function_mixin.FocusedFunctionMixin, pikos.monitors.function_monitor.FunctionMonitor
Record python function events.
The class hooks on the setprofile function to receive function events and record them if they take place inside the provided functions.
- __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.
- class pikos.monitors.function_memory_monitor.FunctionMemoryMonitor(recorder, record_type=None)[source]¶
Bases: pikos.monitors.function_monitor.FunctionMonitor
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.
- __init__(recorder, record_type=None)[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. - record_type: class object
- A class object to be used for records. Default is FunctionMemoryMonitor
- enable()[source]¶
Enable the monitor.
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.
- 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.
- __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.
- class pikos.monitors.line_monitor.LineMonitor(recorder, record_type=None)[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.
- __init__(recorder, record_type=None)[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. - record_type: class object
- A class object to be used for records. Default is LineMonitor
- 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.
- 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.
- __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.
- class pikos.monitors.line_memory_monitor.LineMemoryMonitor(recorder, record_type=None)[source]¶
Bases: pikos.monitors.line_monitor.LineMonitor
Record process memory on python line 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.
- __init__(recorder, record_type=None)[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. - record_type: class object
- A class object to be used for records. Default is LineMemoryMonitor
- enable()[source]¶
Enable the monitor.
The first time the method is called (the context is entered) it will initialize the Process class, set the settrace hooks and initialize 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.
- __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.
- class pikos.monitors.focused_function_mixin.FocusedFunctionMixin(*arguments, **keywords)[source]¶
Bases: object
Mixing class to support recording python function events focused on a set of functions.
The method is used along a function event based monitor. It mainly overrides the on_function_event method to only record events when the interpreter is working inside one of predefined functions.
Public
- functions : FunctionSet
- A set of function or method objects inside which recording will take place.
- __init__(*arguments, **keywords)[source]¶
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.
- on_function_event(frame, event, arg)[source]¶
Record the function event if we are inside one of the functions.
- attach(instance, *args, **kwards)¶
Attach (i.e. wrap) the monitor to the decorated function.
This method supports decorating functions with and without keyword arguments.
Parameters: - instance (object) – The monitor instance to attach.
- *args (list) – The list of arguments passed to the decorator.
- **kwargs (dict) – The dictionary of keyword arguments passed to the decorator.
Returns: fn (callable) – Depending on the usage of the decorator (with or without arguments). The return callable is an instance of: - MonitorAttach, if the decorator is used without arguments. - FocusedMonitorAttach, if the decorator is used with arguments.
Raises: TypeError – Raised if the monitor cannot be attached to the function.
- class pikos.monitors.focused_line_mixin.FocusedLineMixin(*arguments, **keywords)[source]¶
Bases: object
Mixing class to support recording python line events focused on a set of functions.
The method is used along a line event based monitor. It mainly overrides the on_line_event method to only record events when the interpreter is working inside the predefined functions.
Public
- functions : FunctionSet
- A set of function or method objects inside which recording will take place.
- __init__(*arguments, **keywords)[source]¶
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.
- attach(instance, *args, **kwards)¶
Attach (i.e. wrap) the monitor to the decorated function.
This method supports decorating functions with and without keyword arguments.
Parameters: - instance (object) – The monitor instance to attach.
- *args (list) – The list of arguments passed to the decorator.
- **kwargs (dict) – The dictionary of keyword arguments passed to the decorator.
Returns: fn (callable) – Depending on the usage of the decorator (with or without arguments). The return callable is an instance of: - MonitorAttach, if the decorator is used without arguments. - FocusedMonitorAttach, if the decorator is used with arguments.
Raises: TypeError – Raised if the monitor cannot be attached to the function.