Skip to main content

The official Python SDK for Task Badger

Project description

Task Badger Python Client

This is the official Python SDK for Task Badger.

For full documentation go to https://docs.taskbadger.net/python/.

Integration Tests


Getting Started

Install

pip install --upgrade taskbadger

Client Usage

Configuration

import taskbadger

taskbadger.init(
    organization_slug="my-org",
    project_slug="my-project",
    token="***"
)

Usage with Celery

import taskbadger
from celery import Celery

app = Celery("tasks")

@app.task(bind=True, base=taskbadger.Task)
def my_task(self):
    task = self.taskbadger_task
    for i in range(1000):
        do_something(i)
        if i % 100 == 0:
            task.update(value=i, value_max=1000)
    task.success(value=1000)

API Example

from taskbadger import Task, Action, EmailIntegration, WebhookIntegration

# create a new task with custom data and an action definition
task = Task.create(
    "task name",
    data={
        "custom": "data"
    },
    actions=[
        Action("*/10%,success,error", integration=EmailIntegration(to="me@example.com")),
        Action("cancelled", integration=WebhookIntegration(id="webhook:demo")),
    ]
)

# update the task status to 'processing' and set the value to 0
task.started()
try:
   for i in range(100):
      do_something(i)
      if i!= 0 and i % 10 == 0:
         # update the progress of the task
         task.update_progress(i)
except Exception as e:
    # record task errors
    task.error(data={
        "error": str(e)
    })
    raise

# record task success
task.success()

CLI USage

Configuration

$ taskbadger configure

Organization slug: my-org
Project slug: project-x
API Key: XYZ.ABC

Config written to ~/.config/taskbadger/config

Usage Examples

The CLI run command executes your command whilst creating and updating a Task Badger task.

$ taskbadger run "demo task" --action error email to:me@test.com -- path/to/script.sh

Task created: https://taskbadger.net/public/tasks/xyz/

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

taskbadger-1.6.1.tar.gz (30.7 kB view details)

Uploaded Source

Built Distribution

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

taskbadger-1.6.1-py3-none-any.whl (59.1 kB view details)

Uploaded Python 3

File details

Details for the file taskbadger-1.6.1.tar.gz.

File metadata

  • Download URL: taskbadger-1.6.1.tar.gz
  • Upload date:
  • Size: 30.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.4

File hashes

Hashes for taskbadger-1.6.1.tar.gz
Algorithm Hash digest
SHA256 08271e8c480d7557579d72e7f029cb0167b6f5617c8cd5071c62b8a750d8fbf6
MD5 7eb48f0d251059b133338962caf3d2c4
BLAKE2b-256 fc79be8907f313cbfcb21df56876b0cb9b2a3c3cd9ccbc312b03d3f83925af08

See more details on using hashes here.

File details

Details for the file taskbadger-1.6.1-py3-none-any.whl.

File metadata

File hashes

Hashes for taskbadger-1.6.1-py3-none-any.whl
Algorithm Hash digest
SHA256 49c61602bc733ffc83e84ea942a025e04a449448af11ad323b49d2a14514ca56
MD5 383cc09a0f044f9649f883b6be706a7c
BLAKE2b-256 6bfad93f97dca2f208d1a7e7f7a0b0d11ea7d0d638d6a654b8d5a409e4a32c33

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