Metadata-Version: 2.4
Name: taskbadger
Version: 1.6.1
Summary: The official Python SDK for Task Badger
Project-URL: Changelog, https://github.com/taskbadger/taskbadger-python/releases
Project-URL: homepage, https://taskbadger.net/
Project-URL: repository, https://github.com/taskbadger/taskbadger-python
Project-URL: documentation, https://docs.taskbadger.net/
License-File: LICENSE
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: Web Environment
Classifier: Intended Audience :: Developers
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.9
Requires-Dist: attrs>=21.3.0
Requires-Dist: httpx<0.28.0,>=0.20.0
Requires-Dist: importlib-metadata>=1.0; python_version < '3.8'
Requires-Dist: python-dateutil>=2.8.0
Requires-Dist: tomlkit>=0.12.5
Requires-Dist: typer[all]<0.10.0
Requires-Dist: typing-extensions>=4.7.1; python_version <= '3.9'
Provides-Extra: celery
Requires-Dist: celery<6.0.0,>=4.0.0; extra == 'celery'
Description-Content-Type: text/markdown

# Task Badger Python Client

This is the official Python SDK for [Task Badger](https://taskbadger.net/).

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

![Integration Tests](https://github.com/taskbadger/taskbadger-python/actions/workflows/integration_tests.yml/badge.svg)

---

## Getting Started

### Install

```bash
pip install --upgrade taskbadger
```

### Client Usage

#### Configuration

```python
import taskbadger

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

#### Usage with Celery

```python
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

```python
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

```shell
$ 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.

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

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