Description
Strideutils contains common patterns for cosmos api requests, monitoring, and other integrations for gsheets, slack, and twilio.
Setup
In a virtual environment of your choice install strideutils.
pip install strideutils
with poetry
poetry add strideutils
This package is frequently updated, so keep that in mind while developing.
Configuration
Strideutils requires three different environment variables that can be added to ~/.zshrc or ~/.bashrc
export STRIDEUTILS_CONFIG_PATH=
export STRIDEUTILS_ENV_PATH=
Examples of these files are included under strideutils/config_examples. Stride Labs employees can find config.yaml in launchpad and .env.local in lastpass. We recommend you place .env.local in your launchpad repo.
Any configuration or secrets that aren't consumed don't need to be set. However if one is accessed but unset, an error will be thrown for easier debugging.
Once strideutils is installed and configured, each module you need should be imported individually. This isolates the different secrets that are expected and consumed.
Some common imports:
from strideutils.stride_config import config
config.get_chain(name='osmosis')
from strideutils import stride_requests
stride_requests.request('https://google.com')
from strideutils.stride_alerts import raise_alert
Slack Connector
TODO
Sheets Connector
TODO
Redis Connector
TODO
Telegram Connector
The Telegram connector provides a simple interface for sending messages and files to Telegram chats. It uses the python-telegram-bot library internally but provides a synchronous interface for ease of use.
Setup
-
Install the required dependency:
pip install python-telegram-bot>=22.0 -
Set the
TELEGRAM_BOT_TOKENenvironment variable with your Telegram bot token (can be obtained from BotFather on Telegram)
Usage Examples
# Send a simple message
from strideutils import telegram_connector
# Simple message
telegram_connector.send_message("123456789", "Hello Berachain validators!")
# Thread messages
telegram_connector.send_message(
"123456789",
[
"Stride delegation update:",
"We've delegated 1000 BGT to your validator node.",
"Transaction hash: 0x1234..."
]
)
# Send a file with caption
telegram_connector.send_file(
"123456789",
"/path/to/a/file/eg/delegation_report.pdf",
caption="March delegation report"
)
The connector follows the singleton pattern used elsewhere in strideutils, and automatically handles the conversion between async and sync interfaces.
Developing Strideutils
To access the strideutils repo locally rather than using the pip version (for actively making changes to strideutils and a dependency), add the path to strideutils to the beginning of PYTHONPATH
import sys
sys.path = ['/path/to/strideutils/'] + sys.path
Alternatively, you can install strideutils through local mode. However, please be warned that this will make your local Python environment always use your local strideutils. This might lead to unexpected behavior if you local changes.
To install in local mode, run the following:
pip3 install -e /Users/username/Documents/strideutils
Confirm the location of where it's being imported from by printing the module. After making changes to strideutils, reload it before testing your application.
from importlib import reload
reload(strideutils)
Metadata
Release files for strideutils 0.9.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 |
|---|---|---|---|---|
| strideutils-0.9.2.tar.gz | 65.6 kB | Without provenance | Details for strideutils-0.9.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| strideutils-0.9.2-py3-none-any.whl | Python 3 | none | any | Details for strideutils-0.9.2-py3-none-any.whl |
Total release size: 126.3 kB
Release files / strideutils-0.9.2.tar.gz
| Download URL | strideutils-0.9.2.tar.gz |
|---|---|
| Size | 65.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
88f6318122a2a32b2378cefa22394660d4fadb2f3dd0e37013f95c95491034e6
|
|
BLAKE2b-256 checksum How to use checksums |
8b29104410bd290fe8546f4deec408ac5c02109d1985ed58fcde335d07b4d32a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.11.16
|
Release files / strideutils-0.9.2-py3-none-any.whl
| Download URL | strideutils-0.9.2-py3-none-any.whl |
|---|---|
| Size | 60.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a2f1a0ad854c607a6fe9eefe53c9b767708e3f0f1ef66a2ea641fe63e76b4300
|
|
BLAKE2b-256 checksum How to use checksums |
cbdeb5518701d6fd854c31a0497d40da65fadf46e4b43edfd6e6de17fdffb6e3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.11.16
|
Security for strideutils 0.9.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.