lisa.trace.SimpleTxtTraceParser#
- class lisa.trace.SimpleTxtTraceParser(*args, **kwargs)[source]#
Bases:
TxtTraceParserBase
Simple text trace parser (base) class.
- Parameters:
lines (collections.abc.Iterable(str)) – Lines of the text to parse.
events (list(str)) – List of events that will be potentially parsed by
parse_events()
. IfNone
, all available will be considered but that may increase the initial parsing stage.event_parsers (list(TxtTraceParserBase)) –
Optional list of
TxtTraceParserBase
to provide fully customized event regex.Note
See
EVENT_DESCS
for class-provided special case handling.header_regex (str) – Regex used to parse the header of each event. See
HEADER_REGEX
documentation.
Note
This class is easier to customize than
TxtTraceParser
but may have higher processing time and peak memory usage.Attributes
Mapping of event names to parser description as a dict.
Default regex to use to parse event header. It must parse the following groups:.
DEFAULT_EVENT_PARSER_CLS
inheritedClass used to create event parsers when inferred from the trace.
DTYPE_INFERENCE_ORDER
inheritedWhen the dtype of a field is not provided by a user-defined parser, these dtypes will be tried in order to convert the column from string to something more appropriate.
HEADER_FIELDS
inheritedPandas dtype of the header fields.
METADATA_KEYS
inheritedPossible metadata keys.
Properties
logger
inheritedConvenience short-hand for
self.get_logger()
.Methods
__enter__()
inherited__exit__()
inheritedfactory()
inheritedDecorator to use on alternative constructors, i.e. classmethods that return instances of the class.
from_string()
inheritedBuild an instance from a single multiline string.
from_txt_file()
inheritedBuild an instance from a path to a text file.
get_all_metadata()
inheritedCollect all available metadata.
get_logger()
inheritedProvides a
logging.Logger
named aftercls
.get_metadata()
inheritedReturn the metadata value.
get_parser_id()
inheritedGet the unique ID of that parser. Any parameter affecting the output dataframes or metadata must be somehow part of that ID, so that the cache is not accidentally hit with stale data.
log_locals()
inheritedDebugging aid: log the local variables of the calling function.
parse_all_events()
inheritedParse all available events.
parse_event()
inheritedParse the given event from the trace and return a
pandas.DataFrame
with the following columns:.parse_events()
inheritedSame as
parse_event()
but taking a list of events as input, and returning a mapping of event names topandas.DataFrame
for each.
Attributes#
- SimpleTxtTraceParser.EVENT_DESCS = {}#
Mapping of event names to parser description as a dict.
Each event description can include the following dict keys:
header_regex
: Regex to parse the event header. If not set, the header regex from the trace parser will be used.fields_regex
: Regex to parse the fields part of the event (i.e. the part after the header). This is the most commonly modified setting to take into account special cases in event formatting.fields
: Mapping of field names topandas.DataFrame
column dtype. This allows using a smaller dtype or the use of a non-inferred dtype likeboolean
.positional_field
: Name of the positional field (comming before the named fields). IfNone
, the column will be suppressed in the parsed dataframe.
- SimpleTxtTraceParser.HEADER_REGEX = None#
Default regex to use to parse event header. It must parse the following groups:
__timestamp
: the timestamp of the event__event
: the name of the event__cpu
(optional): the CPU by which the event was emitted__pid
(optional): the currently scheduled PID at the point the event was emitted__comm
(optional): the currently scheduled task’s name at the point the event was emitted
Note
It must not capture the event fields, as it will be concatenated with the field regex of each event to parse full lines.
- SimpleTxtTraceParser.DEFAULT_EVENT_PARSER_CLS = None#
Inherited attribute, see
lisa.trace.TxtTraceParserBase.DEFAULT_EVENT_PARSER_CLS
Class used to create event parsers when inferred from the trace.
- SimpleTxtTraceParser.DTYPE_INFERENCE_ORDER = ['int64', 'uint64', 'float64']#
Inherited attribute, see
lisa.trace.TxtTraceParserBase.DTYPE_INFERENCE_ORDER
When the dtype of a field is not provided by a user-defined parser, these dtypes will be tried in order to convert the column from string to something more appropriate.
- SimpleTxtTraceParser.HEADER_FIELDS = {'__comm': 'string', '__cpu': 'uint32', '__event': 'string', '__pid': 'uint32', '__timestamp': 'float64'}#
Inherited attribute, see
lisa.trace.TxtTraceParserBase.HEADER_FIELDS
Pandas dtype of the header fields.
- SimpleTxtTraceParser.METADATA_KEYS = ['time-range', 'symbols-address', 'cpus-count', 'available-events', 'trace-id']#
Inherited attribute, see
lisa.trace.TraceParserBase.METADATA_KEYS
Possible metadata keys.
Properties#
- property SimpleTxtTraceParser.logger#
Inherited property, see
lisa.utils.Loggable.logger
Convenience short-hand for
self.get_logger()
.
Methods#
- SimpleTxtTraceParser.__enter__()#
Inherited method, see
lisa.trace.TraceParserBase.__enter__()
- SimpleTxtTraceParser.__exit__(*args, **kwargs)#
Inherited method, see
lisa.trace.TraceParserBase.__exit__()
- classmethod SimpleTxtTraceParser.factory(f)#
Inherited method, see
lisa.utils.PartialInit.factory()
Decorator to use on alternative constructors, i.e. classmethods that return instances of the class.
- classmethod SimpleTxtTraceParser.from_string(txt, path=None, *, events=None, needed_metadata=None, event_parsers=None, default_event_parser_cls=None, pre_filled_metadata=None, temp_dir)#
Inherited method, see
lisa.trace.TxtTraceParserBase.from_string()
Build an instance from a single multiline string.
- classmethod SimpleTxtTraceParser.from_txt_file(path, *, events=None, needed_metadata=None, event_parsers=None, default_event_parser_cls=None, pre_filled_metadata=None, temp_dir)#
Inherited method, see
lisa.trace.TxtTraceParserBase.from_txt_file()
Build an instance from a path to a text file.
- SimpleTxtTraceParser.get_all_metadata()#
Inherited method, see
lisa.trace.TraceParserBase.get_all_metadata()
Collect all available metadata.
- classmethod SimpleTxtTraceParser.get_logger(suffix=None)#
Inherited method, see
lisa.utils.Loggable.get_logger()
Provides a
logging.Logger
named aftercls
.
- SimpleTxtTraceParser.get_metadata(key)#
Inherited method, see
lisa.trace.TxtTraceParserBase.get_metadata()
Return the metadata value.
- SimpleTxtTraceParser.get_parser_id()#
Inherited method, see
lisa.trace.TraceParserBase.get_parser_id()
Get the unique ID of that parser. Any parameter affecting the output dataframes or metadata must be somehow part of that ID, so that the cache is not accidentally hit with stale data.
- classmethod SimpleTxtTraceParser.log_locals(var_names=None, level='debug')#
Inherited method, see
lisa.utils.Loggable.log_locals()
Debugging aid: log the local variables of the calling function.
- SimpleTxtTraceParser.parse_all_events()#
Inherited method, see
lisa.trace.TraceParserBase.parse_all_events()
Parse all available events.
- SimpleTxtTraceParser.parse_event(event)#
Inherited method, see
lisa.trace.TxtTraceParserBase.parse_event()
Parse the given event from the trace and return a
pandas.DataFrame
with the following columns:.
- SimpleTxtTraceParser.parse_events(events, best_effort=False, **kwargs)#
Inherited method, see
lisa.trace.TraceParserBase.parse_events()
Same as
parse_event()
but taking a list of events as input, and returning a mapping of event names topandas.DataFrame
for each.