Skip to main content

pinexq-tools

Utility tools for the DataCybernetics PinexQ platform. Distributed as pinexq-tools; modules live under the pinexq namespace.

Modules

pinexq.monitoring

Context managers that report an UptimeKuma push heartbeat when a block finishes — status=up on clean exit, status=down on exception — with ping set to the time spent inside the context.

from pinexq.monitoring import UptimeKumaPush, AsyncUptimeKumaPush

with UptimeKumaPush("https://kuma.example/api/push/abc123"):
    do_work()

async with AsyncUptimeKumaPush("https://kuma.example/api/push/abc123"):
    await do_work()

Read-only helpers that ask a Prometheus HTTP API whether a service's alert rules are active, per environment (distinguished by the tenant_cluster_name label). Instead of re-deriving health from raw metrics, they read the alerts the rules already encode.

query_prometheus_alerts_absent(...) returns True when there are no pending/firing alerts for the service on that cluster (i.e. healthy):

from pinexq.monitoring import query_prometheus_alerts_absent

healthy = query_prometheus_alerts_absent(
    "https://prometheus.example",   # base URL, without the /api/v1 suffix
    "epex-trader",                  # value of the `service` label on the rules
    "pinexq-k3s-prod",              # value of the `tenant_cluster_name` label
    username="user",
    password="password",
)
# healthy is True when the service has no active alerts on that cluster

query_prometheus_alert_rules(...) returns the per-cluster state of each alert rule for the service as a {rule_name: state} mapping ("inactive", "pending", or "firing"). Because it enumerates loaded rules, it also confirms the rules are present:

from pinexq.monitoring import query_prometheus_alert_rules

states = query_prometheus_alert_rules(
    "https://prometheus.example",
    "epex-trader",
    "pinexq-k3s-prod",
    username="user",
    password="password",
)
# {"M7MessagesDropped": "inactive", "M7QueueSpilling": "firing", ...}
all_ok = all(state == "inactive" for state in states.values())

all_prometheus_alerts_inactive(...) wraps that call and returns a single boolean — True when every matching rule is inactive. Unlike query_prometheus_alerts_absent, it raises ValueError if the service / tenant_cluster_name matched no rules, so a typo can't be mistaken for a healthy result:

from pinexq.monitoring import all_prometheus_alerts_inactive

healthy = all_prometheus_alerts_inactive(
    "https://prometheus.example",
    "epex-trader",
    "pinexq-k3s-prod",
    username="user",
    password="password",
)

Credentials may instead be embedded in the connection string as userinfo — explicit username / password override any embedded ones:

query_prometheus_alerts_absent(
    "https://user:password@prometheus.example", "epex-trader", "pinexq-k3s-prod"
)

Both accept an optional keyword-only timeout (seconds, default 10.0), authenticate via HTTP basic auth, and raise httpx.HTTPStatusError on a non-2xx response or RuntimeError if the API reports a non-success status.

Development

uv sync --all-groups
uv build
ruff check .
pytest

Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

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

pinexq_tools-0.1.0-py3-none-any.whl (7.9 kB view details)

Uploaded Python 3

File details

Details for the file pinexq_tools-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: pinexq_tools-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 7.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.9

File hashes

Hashes for pinexq_tools-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a37910b36773ef135fa6dceceaf868f4f65f6d14a2374694a2178db849ceee49
MD5 fe67e7ed449bb377bce69fafecdfc888
BLAKE2b-256 8b3c245c486e26f2ea8e335ddc2e44f98913086617a95b5b12caf6c3a0d57143

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.0 This release

1 file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page