Seagrass
A Python event auditing and profiling multitool
Seagrass is a library providing fast, pluggable hooks for instrumenting Python code.
Installation
You can install the latest version of Seagrass using pip:
pip install seagrass
Introduction
At a low level, Seagrass is just a wrapper around Python's context managers and function decorators. Working in conjunction, these two features make it possible to instrument and attach context to arbitrary functions and blocks of code. However, at the far end it can be tedious to have to manage, configure, and toggle code hooks using just the standard library.
Seagrass provides a framework for developing hot-swappable hooks and managing
them at scale. For instance, suppose you wanted to count the number of times a
function was entered and see how much time was spent in it. You could use
Seagrass's built-in CounterHook and TimerHook as follows:
import seagrass
from seagrass import Auditor
from seagrass.hooks import CounterHook, TimerHook
auditor = Auditor()
hooks = [CounterHook(), TimerHook()]
@auditor.audit(seagrass.auto, hooks=hooks)
def some_function_i_want_to_audit():
...
with auditor.start_auditing(log_results=True):
some_function_i_want_to_audit()
Alternatively, you could use the ProfilerHook hook to get finer-grained
performance statistics based on Python's
cProfile
module.
Seagrass really starts to shine once you start writing your own
hooks through the
ProtoHook interface, or using one of the lightly-configurable hooks such as
LoggingHook
or
ContextManagerHook.
You can write one set of hooks that transfer across multiple projects and toggle
them on-demand, filter them by event name, attach logging context with them, and
so on.
Check out the quickstart tutorial for a longer crash course on using Seagrass.
Documentation
The full documentation for Seagrass is available on ReadTheDocs: https://seagrass.readthedocs.io/en/stable/
Metadata
Release files for seagrass 0.10.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| seagrass-0.10.2.tar.gz | 37.4 kB | Without provenance | Details for seagrass-0.10.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| seagrass-0.10.2-py3-none-any.whl | Python 3 | none | any | Details for seagrass-0.10.2-py3-none-any.whl |
Total release size: 89.4 kB
Release files / seagrass-0.10.2.tar.gz
| Download URL | seagrass-0.10.2.tar.gz |
|---|---|
| Size | 37.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d7170717f54fea37b802a2f625331cc4b81b7e6e544c38a68cfaf07320a289c5
|
|
BLAKE2b-256 checksum How to use checksums |
4007b0dcb39974fb57fadbe5edd1a244df5a4688e336df7712519be21e0a551f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.16
|
Release files / seagrass-0.10.2-py3-none-any.whl
| Download URL | seagrass-0.10.2-py3-none-any.whl |
|---|---|
| Size | 52.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
92fe39a32c335eaf7eb9f507c838ab0887bb5facb1bf51024a8d83afbec39865
|
|
BLAKE2b-256 checksum How to use checksums |
564dce6a502ab6b3f12344f574d867d2b9c3eaa790a5fc8c65cce1cc6a8fd707
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.16
|
Security for seagrass 0.10.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.