Skip to main content

Official Python client for Whycron — cron job monitoring that tells you why.

Project description

whycron — Python client for Whycron

Cron job monitoring that tells you why. This is the official Python SDK.

pip install whycron-sdk

The pip-install name is whycron-sdk (PyPI), but you import it as whycron:

from whycron import Whycron, monitor

Heartbeat pings

The ping token is the credential — no API key needed.

from whycron import Whycron

client = Whycron()

client.ping("wcr_abc123def", state="started")
try:
    do_the_work()
    client.ping("wcr_abc123def", state="succeeded", duration_ms=1234)
except Exception as exc:
    client.ping("wcr_abc123def", state="failed", exit_code=1, logs=str(exc))
    raise

Decorator

For most jobs, this is all you need:

import whycron

@whycron.monitor("wcr_abc123def")
def nightly_backup():
    ...

Sends a started ping before the function runs, then succeeded (with exit_code=0 and duration_ms) on a clean return, or failed (with exit_code=1, duration_ms, and the traceback tail as logs) if it raises. The exception still propagates after the ping is sent.

Network errors during the ping never break the wrapped function — they're logged via the standard library logging module under the whycron logger.

Programmatic management (API key required)

Get a key from your dashboard at Account → API keys. Then:

from whycron import Whycron

client = Whycron(api_key="wcr_live_...")

monitor = client.create_monitor(
    name="Nightly Backup",
    schedule_type="cron",
    schedule_value="0 2 * * *",
    grace_period_seconds=120,
)

monitors = client.list_monitors(status="failing")
client.update_monitor(monitor["id"], paused=True)
client.delete_monitor(monitor["id"])

runs = client.list_runs(monitor_id=monitor["id"])
run = client.get_run(runs["items"][0]["id"])

Scope-gated routes obey your key's scopes:

Method Scope needed
list_monitors, get_monitor monitors:read
create_monitor, update_monitor, delete_monitor monitors:write
list_runs, get_run runs:read

A WhycronAuthError (401) means the key is missing, malformed, or revoked. A WhycronAPIError with .status_code == 403 means the key is valid but lacks the scope.

Errors

Exception When
WhycronAuthError 401 — bad/missing/revoked key
WhycronNotFoundError 404 — wrong ID, or resource in another org
WhycronRateLimitedError 429 — slow down
WhycronAPIError any other non-2xx
WhycronError base class of all of the above

Self-hosted / staging

client = Whycron(api_key="...", base_url="https://api.staging.example.com")

License

MIT.

Project details


Download files

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

Source Distribution

whycron_sdk-0.1.0.tar.gz (7.1 kB view details)

Uploaded Source

Built Distribution

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

whycron_sdk-0.1.0-py3-none-any.whl (8.9 kB view details)

Uploaded Python 3

File details

Details for the file whycron_sdk-0.1.0.tar.gz.

File metadata

  • Download URL: whycron_sdk-0.1.0.tar.gz
  • Upload date:
  • Size: 7.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for whycron_sdk-0.1.0.tar.gz
Algorithm Hash digest
SHA256 4854ff8eec299f5e8ac4891b7b4d0cf58401ebef397010ed828b7e2fe0270e40
MD5 c770ad2b482a8c7c4cb672f24d279a4b
BLAKE2b-256 8723a50f76dfaef04bcef8af9ca2104e33dee60c1c88674b8dac227253fd7084

See more details on using hashes here.

Provenance

The following attestation bundles were made for whycron_sdk-0.1.0.tar.gz:

Publisher: publish-python-sdk.yml on Saksham1367/Whycron

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

  • Download URL: whycron_sdk-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 8.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for whycron_sdk-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 74d45c74c04498276074f8af0f836e5fdf260da733a50f492a3db8e146f348db
MD5 2623a5acc000fcb774b58345f3808aa1
BLAKE2b-256 e6837098bebe838c36a61d5b6e1ea280a7b3cd76e8968d4dac722bebfe112aa2

See more details on using hashes here.

Provenance

The following attestation bundles were made for whycron_sdk-0.1.0-py3-none-any.whl:

Publisher: publish-python-sdk.yml on Saksham1367/Whycron

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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