ntpstats.plugins¶
Plugins: add parsers, estimators, detectors, masks and import profiles from other packages.
A plugin is an installed Python package that declares entry points::
[project.entry-points."ntpstats.parsers"]
toycsv = "ntpstats_toy_csv:PARSER" # a ParserPlugin
[project.entry-points."ntpstats.estimators"]
myfilter = "my_pkg:MyEstimator" # see ntpstats.estimators
[project.entry-points."ntpstats.detectors"]
glitch = "my_pkg:DETECTOR" # a DetectorPlugin
[project.entry-points."ntpstats.masks"]
my-tdev = "my_pkg:MASK" # mask text, a Mask, or a callable returning one
[project.entry-points."ntpstats.profiles"]
my-counter = "my_pkg:PROFILE" # a profile dict (same keys as TOML profiles)
Plugins appear in ntpstats plugins, in -f/--format, in the web UI's
format list and in ntpstats events. A plugin that fails to load is listed
with its error and otherwise ignored: a broken plugin never breaks the tool.
pytest --pyargs ntpstats.testing.plugin_contract checks installed plugins.
ParserPlugin
dataclass
¶
A log format.
parse(lines, name) returns a list of :class:TimeSeries (offset =
reference - local, seconds; time = POSIX seconds). detect(lines)
returns a confidence in [0, 1] that the first lines are this format; at
0.9 or above the plugin wins over the built-in detection, from 0.5 it is
used before falling back to generic CSV. example is a short sample
the contract tests parse.
DetectorPlugin
dataclass
¶
An event detector: detect(series) returns :class:ntpstats.events.Event objects.
register_parser(p)
¶
Register a parser in-process (how the built-in research formats are registered).
discover(kind, refresh=False)
¶
Load the entry points of one group (parsers, estimators, ...); cached.
parsers()
¶
Built-in parser plugins plus installed ones (installed ones cannot shadow a built-in format).
mask(name)
¶
A mask provided by a plugin, or None.
detect_plugin(lines, threshold)
¶
Best external parser whose detector scores at least threshold.
listing()
¶
Everything that can be extended, with where it comes from (for ntpstats plugins).