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.3.1.tar.gz (30.4 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.3.1-py3-none-any.whl (57.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: taskbadger-1.3.1.tar.gz
  • Upload date:
  • Size: 30.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.0 CPython/3.9.18 Linux/6.2.0-1015-azure

File hashes

Hashes for taskbadger-1.3.1.tar.gz
Algorithm Hash digest
SHA256 82bee6a18848f27d29c21e09eaaf53663ae02f9f004e6ded2e5d0c70caf95119
MD5 d0115cb65bf519262cd289c56f1d1fcc
BLAKE2b-256 dc45e217153ddb2bba12fc2ef184a02f0b599f9cab9fb69392482a179169ba5b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: taskbadger-1.3.1-py3-none-any.whl
  • Upload date:
  • Size: 57.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.0 CPython/3.9.18 Linux/6.2.0-1015-azure

File hashes

Hashes for taskbadger-1.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 711cd150a29d7fe0dae39cb44ab12445c833b361cf41d2ac691a31e6f71cc98b
MD5 75bb91198d936e9384d0edd6dd8a2e35
BLAKE2b-256 cb4b2b6477d4b99834bfcb786b94ebfd9dc419548ed5208eb0b929da6d8a04e3

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