Skip to main content

Utility functions for monitoring the Stride blockchain

Project description

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

  1. Install the required dependency:

    pip install python-telegram-bot>=22.0
    
  2. Set the TELEGRAM_BOT_TOKEN environment 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)

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

strideutils-0.9.1.tar.gz (65.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

strideutils-0.9.1-py3-none-any.whl (60.5 kB view details)

Uploaded Python 3

File details

Details for the file strideutils-0.9.1.tar.gz.

File metadata

  • Download URL: strideutils-0.9.1.tar.gz
  • Upload date:
  • Size: 65.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.15

File hashes

Hashes for strideutils-0.9.1.tar.gz
Algorithm Hash digest
SHA256 5c2d95d4952acd4b7c9771a69dc289aa41b737b83c212595779a33b330eef160
MD5 bf1299caf07ad68393412a5e358e511f
BLAKE2b-256 ffcc757bb1a3af7824e24d746c20d28a11fcd3557abc9afe80984b4f31942801

See more details on using hashes here.

File details

Details for the file strideutils-0.9.1-py3-none-any.whl.

File metadata

  • Download URL: strideutils-0.9.1-py3-none-any.whl
  • Upload date:
  • Size: 60.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.15

File hashes

Hashes for strideutils-0.9.1-py3-none-any.whl
Algorithm Hash digest
SHA256 21de534d367880480b674505150f962c74a99b8c8955cbf88097a2d334f236b4
MD5 9f5a29b50230e8d09ffb14ad03361380
BLAKE2b-256 c5041596f8181224286908d4ca8dedf1a587644240ec1683dd15c247e0c3243f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page