taskbadger 1.7.0__tar.gz → 2.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- taskbadger-2.0.0/PKG-INFO +75 -0
- taskbadger-2.0.0/README.md +43 -0
- {taskbadger-1.7.0 → taskbadger-2.0.0}/pyproject.toml +12 -10
- {taskbadger-1.7.0 → taskbadger-2.0.0}/taskbadger/__init__.py +3 -7
- {taskbadger-1.7.0 → taskbadger-2.0.0}/taskbadger/celery.py +1 -1
- {taskbadger-1.7.0 → taskbadger-2.0.0}/taskbadger/cli/utils.py +2 -2
- taskbadger-2.0.0/taskbadger/cli_main.py +107 -0
- {taskbadger-1.7.0 → taskbadger-2.0.0}/taskbadger/mug.py +4 -4
- {taskbadger-1.7.0 → taskbadger-2.0.0}/taskbadger/safe_sdk.py +3 -8
- {taskbadger-1.7.0 → taskbadger-2.0.0}/taskbadger/sdk.py +0 -16
- {taskbadger-1.7.0 → taskbadger-2.0.0}/taskbadger/utils.py +1 -1
- taskbadger-1.7.0/PKG-INFO +0 -140
- taskbadger-1.7.0/README.md +0 -109
- taskbadger-1.7.0/taskbadger/cli_main.py +0 -99
- {taskbadger-1.7.0 → taskbadger-2.0.0}/.gitignore +0 -0
- {taskbadger-1.7.0 → taskbadger-2.0.0}/LICENSE +0 -0
- {taskbadger-1.7.0 → taskbadger-2.0.0}/taskbadger/cli/__init__.py +0 -0
- {taskbadger-1.7.0 → taskbadger-2.0.0}/taskbadger/cli/basics.py +0 -0
- {taskbadger-1.7.0 → taskbadger-2.0.0}/taskbadger/cli/list_tasks.py +0 -0
- {taskbadger-1.7.0 → taskbadger-2.0.0}/taskbadger/cli/wrapper.py +0 -0
- {taskbadger-1.7.0 → taskbadger-2.0.0}/taskbadger/config.py +0 -0
- {taskbadger-1.7.0 → taskbadger-2.0.0}/taskbadger/decorators.py +0 -0
- {taskbadger-1.7.0 → taskbadger-2.0.0}/taskbadger/exceptions.py +0 -0
- {taskbadger-1.7.0 → taskbadger-2.0.0}/taskbadger/integrations.py +0 -0
- {taskbadger-1.7.0 → taskbadger-2.0.0}/taskbadger/internal/__init__.py +0 -0
- {taskbadger-1.7.0 → taskbadger-2.0.0}/taskbadger/internal/api/__init__.py +0 -0
- {taskbadger-1.7.0 → taskbadger-2.0.0}/taskbadger/internal/api/action_endpoints/__init__.py +0 -0
- {taskbadger-1.7.0 → taskbadger-2.0.0}/taskbadger/internal/api/action_endpoints/action_cancel.py +0 -0
- {taskbadger-1.7.0 → taskbadger-2.0.0}/taskbadger/internal/api/action_endpoints/action_create.py +0 -0
- {taskbadger-1.7.0 → taskbadger-2.0.0}/taskbadger/internal/api/action_endpoints/action_get.py +0 -0
- {taskbadger-1.7.0 → taskbadger-2.0.0}/taskbadger/internal/api/action_endpoints/action_list.py +0 -0
- {taskbadger-1.7.0 → taskbadger-2.0.0}/taskbadger/internal/api/action_endpoints/action_partial_update.py +0 -0
- {taskbadger-1.7.0 → taskbadger-2.0.0}/taskbadger/internal/api/action_endpoints/action_update.py +0 -0
- {taskbadger-1.7.0 → taskbadger-2.0.0}/taskbadger/internal/api/task_endpoints/__init__.py +0 -0
- {taskbadger-1.7.0 → taskbadger-2.0.0}/taskbadger/internal/api/task_endpoints/task_cancel.py +0 -0
- {taskbadger-1.7.0 → taskbadger-2.0.0}/taskbadger/internal/api/task_endpoints/task_create.py +0 -0
- {taskbadger-1.7.0 → taskbadger-2.0.0}/taskbadger/internal/api/task_endpoints/task_get.py +0 -0
- {taskbadger-1.7.0 → taskbadger-2.0.0}/taskbadger/internal/api/task_endpoints/task_list.py +0 -0
- {taskbadger-1.7.0 → taskbadger-2.0.0}/taskbadger/internal/api/task_endpoints/task_partial_update.py +0 -0
- {taskbadger-1.7.0 → taskbadger-2.0.0}/taskbadger/internal/api/task_endpoints/task_update.py +0 -0
- {taskbadger-1.7.0 → taskbadger-2.0.0}/taskbadger/internal/client.py +0 -0
- {taskbadger-1.7.0 → taskbadger-2.0.0}/taskbadger/internal/errors.py +0 -0
- {taskbadger-1.7.0 → taskbadger-2.0.0}/taskbadger/internal/models/__init__.py +0 -0
- {taskbadger-1.7.0 → taskbadger-2.0.0}/taskbadger/internal/models/action.py +0 -0
- {taskbadger-1.7.0 → taskbadger-2.0.0}/taskbadger/internal/models/action_request.py +0 -0
- {taskbadger-1.7.0 → taskbadger-2.0.0}/taskbadger/internal/models/paginated_task_list.py +0 -0
- {taskbadger-1.7.0 → taskbadger-2.0.0}/taskbadger/internal/models/patched_action_request.py +0 -0
- {taskbadger-1.7.0 → taskbadger-2.0.0}/taskbadger/internal/models/patched_task_request.py +0 -0
- {taskbadger-1.7.0 → taskbadger-2.0.0}/taskbadger/internal/models/patched_task_request_tags.py +0 -0
- {taskbadger-1.7.0 → taskbadger-2.0.0}/taskbadger/internal/models/status_enum.py +0 -0
- {taskbadger-1.7.0 → taskbadger-2.0.0}/taskbadger/internal/models/task.py +0 -0
- {taskbadger-1.7.0 → taskbadger-2.0.0}/taskbadger/internal/models/task_request.py +0 -0
- {taskbadger-1.7.0 → taskbadger-2.0.0}/taskbadger/internal/models/task_request_tags.py +0 -0
- {taskbadger-1.7.0 → taskbadger-2.0.0}/taskbadger/internal/models/task_tags.py +0 -0
- {taskbadger-1.7.0 → taskbadger-2.0.0}/taskbadger/internal/py.typed +0 -0
- {taskbadger-1.7.0 → taskbadger-2.0.0}/taskbadger/internal/types.py +0 -0
- {taskbadger-1.7.0 → taskbadger-2.0.0}/taskbadger/process.py +0 -0
- {taskbadger-1.7.0 → taskbadger-2.0.0}/taskbadger/systems/__init__.py +0 -0
- {taskbadger-1.7.0 → taskbadger-2.0.0}/taskbadger/systems/celery.py +0 -0
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: taskbadger
|
|
3
|
+
Version: 2.0.0
|
|
4
|
+
Summary: The official Python SDK for Task Badger
|
|
5
|
+
Project-URL: Changelog, https://github.com/taskbadger/taskbadger-python/releases
|
|
6
|
+
Project-URL: homepage, https://taskbadger.net/
|
|
7
|
+
Project-URL: repository, https://github.com/taskbadger/taskbadger-python
|
|
8
|
+
Project-URL: documentation, https://docs.taskbadger.net/
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Classifier: Development Status :: 4 - Beta
|
|
11
|
+
Classifier: Environment :: Web Environment
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: Operating System :: OS Independent
|
|
14
|
+
Classifier: Programming Language :: Python
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
20
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
21
|
+
Requires-Python: >=3.10
|
|
22
|
+
Requires-Dist: attrs>=21.3.0
|
|
23
|
+
Requires-Dist: httpx>=0.20.0
|
|
24
|
+
Requires-Dist: python-dateutil>=2.8.0
|
|
25
|
+
Requires-Dist: tomlkit>=0.12.5
|
|
26
|
+
Provides-Extra: celery
|
|
27
|
+
Requires-Dist: celery<6.0.0,>=4.0.0; extra == 'celery'
|
|
28
|
+
Provides-Extra: cli
|
|
29
|
+
Requires-Dist: rich>=13.0; extra == 'cli'
|
|
30
|
+
Requires-Dist: typer>=0.12; extra == 'cli'
|
|
31
|
+
Description-Content-Type: text/markdown
|
|
32
|
+
|
|
33
|
+
# Task Badger Python Client
|
|
34
|
+
|
|
35
|
+
This is the official Python SDK for [Task Badger](https://taskbadger.net/).
|
|
36
|
+
|
|
37
|
+
For full documentation go to https://docs.taskbadger.net/python/.
|
|
38
|
+
|
|
39
|
+

|
|
40
|
+
|
|
41
|
+
---
|
|
42
|
+
|
|
43
|
+
## Getting Started
|
|
44
|
+
|
|
45
|
+
### Install
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
pip install taskbadger
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
To use the `taskbadger` command-line tool, install the `cli` extra:
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
pip install 'taskbadger[cli]'
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### Client Usage
|
|
58
|
+
|
|
59
|
+
```python
|
|
60
|
+
import taskbadger
|
|
61
|
+
from taskbadger.systems import CelerySystemIntegration
|
|
62
|
+
|
|
63
|
+
taskbadger.init(
|
|
64
|
+
token="***",
|
|
65
|
+
systems=[CelerySystemIntegration()],
|
|
66
|
+
tags={"environment": "production"}
|
|
67
|
+
)
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### CLI Usage
|
|
71
|
+
|
|
72
|
+
```shell
|
|
73
|
+
$ export TASKBADGER_API_KEY=***
|
|
74
|
+
$ taskbadger run "nightly-backup" -- ./backup.sh
|
|
75
|
+
```
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# Task Badger Python Client
|
|
2
|
+
|
|
3
|
+
This is the official Python SDK for [Task Badger](https://taskbadger.net/).
|
|
4
|
+
|
|
5
|
+
For full documentation go to https://docs.taskbadger.net/python/.
|
|
6
|
+
|
|
7
|
+

|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## Getting Started
|
|
12
|
+
|
|
13
|
+
### Install
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
pip install taskbadger
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
To use the `taskbadger` command-line tool, install the `cli` extra:
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
pip install 'taskbadger[cli]'
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
### Client Usage
|
|
26
|
+
|
|
27
|
+
```python
|
|
28
|
+
import taskbadger
|
|
29
|
+
from taskbadger.systems import CelerySystemIntegration
|
|
30
|
+
|
|
31
|
+
taskbadger.init(
|
|
32
|
+
token="***",
|
|
33
|
+
systems=[CelerySystemIntegration()],
|
|
34
|
+
tags={"environment": "production"}
|
|
35
|
+
)
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### CLI Usage
|
|
39
|
+
|
|
40
|
+
```shell
|
|
41
|
+
$ export TASKBADGER_API_KEY=***
|
|
42
|
+
$ taskbadger run "nightly-backup" -- ./backup.sh
|
|
43
|
+
```
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "taskbadger"
|
|
3
|
-
version = "
|
|
3
|
+
version = "2.0.0"
|
|
4
4
|
description = "The official Python SDK for Task Badger"
|
|
5
|
-
requires-python = ">=3.
|
|
5
|
+
requires-python = ">=3.10"
|
|
6
6
|
authors = []
|
|
7
7
|
readme = "README.md"
|
|
8
8
|
classifiers = [
|
|
@@ -11,10 +11,11 @@ classifiers = [
|
|
|
11
11
|
"Intended Audience :: Developers",
|
|
12
12
|
"Operating System :: OS Independent",
|
|
13
13
|
"Programming Language :: Python",
|
|
14
|
-
"Programming Language :: Python :: 3.9",
|
|
15
14
|
"Programming Language :: Python :: 3.10",
|
|
16
15
|
"Programming Language :: Python :: 3.11",
|
|
17
16
|
"Programming Language :: Python :: 3.12",
|
|
17
|
+
"Programming Language :: Python :: 3.13",
|
|
18
|
+
"Programming Language :: Python :: 3.14",
|
|
18
19
|
"Topic :: Software Development :: Libraries :: Python Modules",
|
|
19
20
|
]
|
|
20
21
|
|
|
@@ -22,10 +23,7 @@ dependencies = [
|
|
|
22
23
|
"httpx >=0.20.0",
|
|
23
24
|
"attrs >=21.3.0",
|
|
24
25
|
"python-dateutil >=2.8.0",
|
|
25
|
-
"typer[all] <0.10.0",
|
|
26
26
|
"tomlkit >=0.12.5",
|
|
27
|
-
"importlib-metadata >=1.0; python_version < '3.8'",
|
|
28
|
-
"typing-extensions >=4.7.1; python_version <= '3.9'",
|
|
29
27
|
]
|
|
30
28
|
|
|
31
29
|
[build-system]
|
|
@@ -42,6 +40,10 @@ include = [
|
|
|
42
40
|
celery = [
|
|
43
41
|
"celery>=4.0.0,<6.0.0",
|
|
44
42
|
]
|
|
43
|
+
cli = [
|
|
44
|
+
"typer >=0.12",
|
|
45
|
+
"rich >=13.0",
|
|
46
|
+
]
|
|
45
47
|
|
|
46
48
|
[tool.uv]
|
|
47
49
|
package = true
|
|
@@ -55,8 +57,6 @@ documentation = "https://docs.taskbadger.net/"
|
|
|
55
57
|
|
|
56
58
|
[dependency-groups]
|
|
57
59
|
dev = [
|
|
58
|
-
"black",
|
|
59
|
-
"isort",
|
|
60
60
|
"pre-commit",
|
|
61
61
|
"pytest",
|
|
62
62
|
"pytest-httpx",
|
|
@@ -64,6 +64,7 @@ dev = [
|
|
|
64
64
|
"pytest-celery",
|
|
65
65
|
"redis",
|
|
66
66
|
"openapi-python-client",
|
|
67
|
+
"taskbadger[cli]",
|
|
67
68
|
]
|
|
68
69
|
|
|
69
70
|
[project.scripts]
|
|
@@ -82,7 +83,7 @@ exclude = [
|
|
|
82
83
|
]
|
|
83
84
|
line-length = 120
|
|
84
85
|
indent-width = 4
|
|
85
|
-
target-version = "
|
|
86
|
+
target-version = "py310"
|
|
86
87
|
|
|
87
88
|
[tool.ruff.lint]
|
|
88
89
|
select = ["E", "F", "I", "UP", "DJ", "PT"]
|
|
@@ -97,4 +98,5 @@ skip-magic-trailing-comma = false
|
|
|
97
98
|
line-ending = "auto"
|
|
98
99
|
|
|
99
100
|
[tool.ruff.lint.per-file-ignores]
|
|
100
|
-
|
|
101
|
+
# taskbadger/internal/ is generated by openapi-python-client; lint is best-effort
|
|
102
|
+
"taskbadger/internal/*" = ["E501", "UP", "F"]
|
|
@@ -23,15 +23,11 @@ __all__ = [
|
|
|
23
23
|
"update_task",
|
|
24
24
|
]
|
|
25
25
|
|
|
26
|
-
|
|
27
|
-
import importlib.metadata as importlib_metadata
|
|
28
|
-
except ModuleNotFoundError:
|
|
29
|
-
import importlib_metadata
|
|
30
|
-
|
|
26
|
+
from importlib.metadata import PackageNotFoundError, version
|
|
31
27
|
|
|
32
28
|
try:
|
|
33
|
-
__version__ =
|
|
34
|
-
except
|
|
29
|
+
__version__ = version(__name__)
|
|
30
|
+
except PackageNotFoundError:
|
|
35
31
|
__version__ = "dev"
|
|
36
32
|
|
|
37
33
|
|
|
@@ -263,7 +263,7 @@ def _maybe_create_task(signal_sender):
|
|
|
263
263
|
inner_task = celery.current_app.tasks.get(task_name)
|
|
264
264
|
items = signal_sender.request.kwargs.get("it", [])
|
|
265
265
|
# Convert to list if needed for counting and potential recording
|
|
266
|
-
items_list = list(items) if not isinstance(items,
|
|
266
|
+
items_list = list(items) if not isinstance(items, list | tuple) else items
|
|
267
267
|
item_count = len(items_list)
|
|
268
268
|
# Append canvas type and item count to task name
|
|
269
269
|
task_name = f"{task_name} ({canvas_type} {item_count})"
|
|
@@ -28,9 +28,9 @@ def get_actions(action_def: tuple[str, str, str]) -> list[Action]:
|
|
|
28
28
|
return []
|
|
29
29
|
|
|
30
30
|
|
|
31
|
-
def merge_kv_json(metadata_kv: list[str], metadata_json: str) -> dict:
|
|
31
|
+
def merge_kv_json(metadata_kv: list[str] | None, metadata_json: str) -> dict:
|
|
32
32
|
metadata = {}
|
|
33
|
-
for kv in metadata_kv:
|
|
33
|
+
for kv in metadata_kv or []:
|
|
34
34
|
k, v = kv.strip().split("=", 1)
|
|
35
35
|
metadata[k] = v
|
|
36
36
|
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import sys
|
|
2
|
+
from typing import Optional
|
|
3
|
+
|
|
4
|
+
try:
|
|
5
|
+
import typer
|
|
6
|
+
from rich import print
|
|
7
|
+
except ImportError as exc:
|
|
8
|
+
_missing = exc.name or "typer"
|
|
9
|
+
|
|
10
|
+
def app() -> None:
|
|
11
|
+
sys.stderr.write(
|
|
12
|
+
f"The Task Badger CLI requires the '{_missing}' package, which is not installed.\n"
|
|
13
|
+
"Install the CLI extras with:\n\n"
|
|
14
|
+
" pip install 'taskbadger[cli]'\n"
|
|
15
|
+
)
|
|
16
|
+
sys.exit(1)
|
|
17
|
+
else:
|
|
18
|
+
from taskbadger import __version__
|
|
19
|
+
from taskbadger.cli import create, get, list_tasks_command, run, update
|
|
20
|
+
from taskbadger.config import get_config, write_config
|
|
21
|
+
from taskbadger.sdk import _parse_token
|
|
22
|
+
|
|
23
|
+
app = typer.Typer(
|
|
24
|
+
rich_markup_mode="rich",
|
|
25
|
+
context_settings={"help_option_names": ["-h", "--help"]},
|
|
26
|
+
)
|
|
27
|
+
|
|
28
|
+
app.command(context_settings={"allow_extra_args": True, "ignore_unknown_options": False})(run)
|
|
29
|
+
app.command(context_settings={"ignore_unknown_options": False})(get)
|
|
30
|
+
app.command(context_settings={"ignore_unknown_options": False})(create)
|
|
31
|
+
app.command(context_settings={"ignore_unknown_options": False})(update)
|
|
32
|
+
app.command("list", context_settings={"ignore_unknown_options": False})(list_tasks_command)
|
|
33
|
+
|
|
34
|
+
def version_callback(value: bool):
|
|
35
|
+
if value:
|
|
36
|
+
print(f"Task Badger CLI Version: {__version__}")
|
|
37
|
+
raise typer.Exit()
|
|
38
|
+
|
|
39
|
+
@app.command()
|
|
40
|
+
def configure(ctx: typer.Context):
|
|
41
|
+
"""Update CLI configuration."""
|
|
42
|
+
config = ctx.meta["tb_config"]
|
|
43
|
+
token = typer.prompt("API Key", default=config.token)
|
|
44
|
+
parsed = _parse_token(token)
|
|
45
|
+
if parsed:
|
|
46
|
+
org_slug, project_slug, api_key = parsed
|
|
47
|
+
print(
|
|
48
|
+
f"Project key detected — organization: [green]{org_slug}[/green], "
|
|
49
|
+
f"project: [green]{project_slug}[/green]"
|
|
50
|
+
)
|
|
51
|
+
config.organization_slug = org_slug
|
|
52
|
+
config.project_slug = project_slug
|
|
53
|
+
config.token = token
|
|
54
|
+
else:
|
|
55
|
+
config.organization_slug = typer.prompt("Organization slug", default=config.organization_slug)
|
|
56
|
+
config.project_slug = typer.prompt("Project slug", default=config.project_slug)
|
|
57
|
+
config.token = token
|
|
58
|
+
path = write_config(config)
|
|
59
|
+
print(f"Config written to [green]{path}[/green]")
|
|
60
|
+
|
|
61
|
+
@app.command()
|
|
62
|
+
def docs():
|
|
63
|
+
"""Open Task Badger docs in a browser."""
|
|
64
|
+
typer.launch("https://docs.taskbadger.net")
|
|
65
|
+
|
|
66
|
+
@app.command()
|
|
67
|
+
def info(ctx: typer.Context):
|
|
68
|
+
"""Show CLI configuration."""
|
|
69
|
+
config = ctx.meta["tb_config"]
|
|
70
|
+
print(str(config))
|
|
71
|
+
|
|
72
|
+
@app.callback()
|
|
73
|
+
def main(
|
|
74
|
+
ctx: typer.Context,
|
|
75
|
+
org: str | None = typer.Option(
|
|
76
|
+
None,
|
|
77
|
+
"--org",
|
|
78
|
+
"-o",
|
|
79
|
+
metavar="TASKBADGER_ORG",
|
|
80
|
+
show_default=False,
|
|
81
|
+
help="Organization Slug. This will override values from the config file and environment variables.",
|
|
82
|
+
),
|
|
83
|
+
project: str | None = typer.Option(
|
|
84
|
+
None,
|
|
85
|
+
"--project",
|
|
86
|
+
"-p",
|
|
87
|
+
show_envvar=False,
|
|
88
|
+
metavar="TASKBADGER_PROJECT",
|
|
89
|
+
show_default=False,
|
|
90
|
+
help="Project Slug. This will override values from the config file and environment variables.",
|
|
91
|
+
),
|
|
92
|
+
version: Optional[bool] = typer.Option( # noqa
|
|
93
|
+
None,
|
|
94
|
+
"--version",
|
|
95
|
+
callback=version_callback,
|
|
96
|
+
is_eager=True,
|
|
97
|
+
help="Show CLI Version",
|
|
98
|
+
),
|
|
99
|
+
):
|
|
100
|
+
"""
|
|
101
|
+
Task Badger CLI
|
|
102
|
+
"""
|
|
103
|
+
config = get_config(org=org, project=project)
|
|
104
|
+
ctx.meta["tb_config"] = config
|
|
105
|
+
|
|
106
|
+
if __name__ == "__main__":
|
|
107
|
+
app()
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import dataclasses
|
|
2
|
+
from collections.abc import Callable
|
|
2
3
|
from contextlib import ContextDecorator
|
|
3
4
|
from contextvars import ContextVar
|
|
4
5
|
from copy import deepcopy
|
|
5
|
-
from typing import Callable, Optional, Union
|
|
6
6
|
|
|
7
7
|
from taskbadger.internal import AuthenticatedClient
|
|
8
8
|
from taskbadger.systems import System
|
|
@@ -10,7 +10,7 @@ from taskbadger.systems import System
|
|
|
10
10
|
_local = ContextVar("taskbadger_client")
|
|
11
11
|
|
|
12
12
|
|
|
13
|
-
Callback =
|
|
13
|
+
Callback = str | Callable[[dict], dict | None]
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
@dataclasses.dataclass
|
|
@@ -47,7 +47,7 @@ class Session(ContextDecorator):
|
|
|
47
47
|
def __init__(self):
|
|
48
48
|
self._session = None
|
|
49
49
|
|
|
50
|
-
def __enter__(self) ->
|
|
50
|
+
def __enter__(self) -> AuthenticatedClient | None:
|
|
51
51
|
if Badger.is_configured():
|
|
52
52
|
self._session = Badger.current.session()
|
|
53
53
|
return self._session.__enter__()
|
|
@@ -144,7 +144,7 @@ class Badger(metaclass=MugMeta):
|
|
|
144
144
|
def scope(self) -> Scope:
|
|
145
145
|
return self._scope
|
|
146
146
|
|
|
147
|
-
def call_before_create(self, task: dict) ->
|
|
147
|
+
def call_before_create(self, task: dict) -> dict | None:
|
|
148
148
|
if self.settings and self.settings.before_create:
|
|
149
149
|
return self.settings.before_create(task)
|
|
150
150
|
return task
|
|
@@ -1,10 +1,5 @@
|
|
|
1
1
|
import logging
|
|
2
|
-
from typing import
|
|
3
|
-
|
|
4
|
-
try:
|
|
5
|
-
from typing import ParamSpec
|
|
6
|
-
except ImportError:
|
|
7
|
-
from typing_extensions import ParamSpec
|
|
2
|
+
from typing import ParamSpec
|
|
8
3
|
|
|
9
4
|
from .mug import Badger
|
|
10
5
|
from .sdk import Task, create_task, update_task
|
|
@@ -14,7 +9,7 @@ P = ParamSpec("P")
|
|
|
14
9
|
log = logging.getLogger("taskbadger")
|
|
15
10
|
|
|
16
11
|
|
|
17
|
-
def create_task_safe(name: str, **kwargs: P.kwargs) ->
|
|
12
|
+
def create_task_safe(name: str, **kwargs: P.kwargs) -> Task | None:
|
|
18
13
|
"""Safely create a task. Any errors are handled and logged.
|
|
19
14
|
|
|
20
15
|
Arguments:
|
|
@@ -33,7 +28,7 @@ def create_task_safe(name: str, **kwargs: P.kwargs) -> Optional[Task]:
|
|
|
33
28
|
log.warning("Error creating task '%s': %s", name, e)
|
|
34
29
|
|
|
35
30
|
|
|
36
|
-
def update_task_safe(task_id: str, **kwargs: P.kwargs) ->
|
|
31
|
+
def update_task_safe(task_id: str, **kwargs: P.kwargs) -> Task | None:
|
|
37
32
|
"""Safely update a task. Any errors are handled and logged.
|
|
38
33
|
|
|
39
34
|
Arguments:
|
|
@@ -367,14 +367,6 @@ class Task:
|
|
|
367
367
|
"""Update the task status"""
|
|
368
368
|
self.update(status=status)
|
|
369
369
|
|
|
370
|
-
def increment_progress(self, amount: int):
|
|
371
|
-
warnings.warn(
|
|
372
|
-
"'task.increment_progress' will be removed in v1.7.0. Use 'task.increment_value' instead.",
|
|
373
|
-
DeprecationWarning,
|
|
374
|
-
stacklevel=2,
|
|
375
|
-
)
|
|
376
|
-
self.increment_value(amount)
|
|
377
|
-
|
|
378
370
|
def increment_value(self, amount: int):
|
|
379
371
|
"""Increment the task progress by adding the specified amount to the current value.
|
|
380
372
|
If the task value is not set it will be set to `amount`.
|
|
@@ -384,14 +376,6 @@ class Task:
|
|
|
384
376
|
new_amount = value_norm + amount
|
|
385
377
|
self.update(value=new_amount)
|
|
386
378
|
|
|
387
|
-
def update_progress(self, value: int, value_step: int = None, rate_limit: int = None):
|
|
388
|
-
warnings.warn(
|
|
389
|
-
"'task.update_progress' will be removed in v1.7.0. Use 'task.update_value' instead.",
|
|
390
|
-
DeprecationWarning,
|
|
391
|
-
stacklevel=2,
|
|
392
|
-
)
|
|
393
|
-
self.update_value(value, value_step, rate_limit)
|
|
394
|
-
|
|
395
379
|
def update_value(self, value: int, value_step: int = None, rate_limit: int = None) -> bool:
|
|
396
380
|
"""Update task progress.
|
|
397
381
|
|
|
@@ -5,7 +5,7 @@ def import_string(dotted_path):
|
|
|
5
5
|
try:
|
|
6
6
|
module_path, class_name = dotted_path.rsplit(".", 1)
|
|
7
7
|
except ValueError as err:
|
|
8
|
-
raise ImportError("
|
|
8
|
+
raise ImportError(f"{dotted_path} doesn't look like a module path") from err
|
|
9
9
|
|
|
10
10
|
module = import_module(module_path)
|
|
11
11
|
|
taskbadger-1.7.0/PKG-INFO
DELETED
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: taskbadger
|
|
3
|
-
Version: 1.7.0
|
|
4
|
-
Summary: The official Python SDK for Task Badger
|
|
5
|
-
Project-URL: Changelog, https://github.com/taskbadger/taskbadger-python/releases
|
|
6
|
-
Project-URL: homepage, https://taskbadger.net/
|
|
7
|
-
Project-URL: repository, https://github.com/taskbadger/taskbadger-python
|
|
8
|
-
Project-URL: documentation, https://docs.taskbadger.net/
|
|
9
|
-
License-File: LICENSE
|
|
10
|
-
Classifier: Development Status :: 4 - Beta
|
|
11
|
-
Classifier: Environment :: Web Environment
|
|
12
|
-
Classifier: Intended Audience :: Developers
|
|
13
|
-
Classifier: Operating System :: OS Independent
|
|
14
|
-
Classifier: Programming Language :: Python
|
|
15
|
-
Classifier: Programming Language :: Python :: 3.9
|
|
16
|
-
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
-
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
-
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
-
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
20
|
-
Requires-Python: >=3.9
|
|
21
|
-
Requires-Dist: attrs>=21.3.0
|
|
22
|
-
Requires-Dist: httpx>=0.20.0
|
|
23
|
-
Requires-Dist: importlib-metadata>=1.0; python_version < '3.8'
|
|
24
|
-
Requires-Dist: python-dateutil>=2.8.0
|
|
25
|
-
Requires-Dist: tomlkit>=0.12.5
|
|
26
|
-
Requires-Dist: typer[all]<0.10.0
|
|
27
|
-
Requires-Dist: typing-extensions>=4.7.1; python_version <= '3.9'
|
|
28
|
-
Provides-Extra: celery
|
|
29
|
-
Requires-Dist: celery<6.0.0,>=4.0.0; extra == 'celery'
|
|
30
|
-
Description-Content-Type: text/markdown
|
|
31
|
-
|
|
32
|
-
# Task Badger Python Client
|
|
33
|
-
|
|
34
|
-
This is the official Python SDK for [Task Badger](https://taskbadger.net/).
|
|
35
|
-
|
|
36
|
-
For full documentation go to https://docs.taskbadger.net/python/.
|
|
37
|
-
|
|
38
|
-

|
|
39
|
-
|
|
40
|
-
---
|
|
41
|
-
|
|
42
|
-
## Getting Started
|
|
43
|
-
|
|
44
|
-
### Install
|
|
45
|
-
|
|
46
|
-
```bash
|
|
47
|
-
pip install --upgrade taskbadger
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
### Client Usage
|
|
51
|
-
|
|
52
|
-
#### Configuration
|
|
53
|
-
|
|
54
|
-
```python
|
|
55
|
-
import taskbadger
|
|
56
|
-
|
|
57
|
-
taskbadger.init(
|
|
58
|
-
organization_slug="my-org",
|
|
59
|
-
project_slug="my-project",
|
|
60
|
-
token="***"
|
|
61
|
-
)
|
|
62
|
-
```
|
|
63
|
-
|
|
64
|
-
#### Usage with Celery
|
|
65
|
-
|
|
66
|
-
```python
|
|
67
|
-
import taskbadger
|
|
68
|
-
from celery import Celery
|
|
69
|
-
|
|
70
|
-
app = Celery("tasks")
|
|
71
|
-
|
|
72
|
-
@app.task(bind=True, base=taskbadger.Task)
|
|
73
|
-
def my_task(self):
|
|
74
|
-
task = self.taskbadger_task
|
|
75
|
-
for i in range(1000):
|
|
76
|
-
do_something(i)
|
|
77
|
-
if i % 100 == 0:
|
|
78
|
-
task.update(value=i, value_max=1000)
|
|
79
|
-
task.success(value=1000)
|
|
80
|
-
```
|
|
81
|
-
|
|
82
|
-
#### API Example
|
|
83
|
-
|
|
84
|
-
```python
|
|
85
|
-
from taskbadger import Task, Action, EmailIntegration, WebhookIntegration
|
|
86
|
-
|
|
87
|
-
# create a new task with custom data and an action definition
|
|
88
|
-
task = Task.create(
|
|
89
|
-
"task name",
|
|
90
|
-
data={
|
|
91
|
-
"custom": "data"
|
|
92
|
-
},
|
|
93
|
-
actions=[
|
|
94
|
-
Action("*/10%,success,error", integration=EmailIntegration(to="me@example.com")),
|
|
95
|
-
Action("cancelled", integration=WebhookIntegration(id="webhook:demo")),
|
|
96
|
-
]
|
|
97
|
-
)
|
|
98
|
-
|
|
99
|
-
# update the task status to 'processing' and set the value to 0
|
|
100
|
-
task.started()
|
|
101
|
-
try:
|
|
102
|
-
for i in range(100):
|
|
103
|
-
do_something(i)
|
|
104
|
-
if i!= 0 and i % 10 == 0:
|
|
105
|
-
# update the progress of the task
|
|
106
|
-
task.update_progress(i)
|
|
107
|
-
except Exception as e:
|
|
108
|
-
# record task errors
|
|
109
|
-
task.error(data={
|
|
110
|
-
"error": str(e)
|
|
111
|
-
})
|
|
112
|
-
raise
|
|
113
|
-
|
|
114
|
-
# record task success
|
|
115
|
-
task.success()
|
|
116
|
-
```
|
|
117
|
-
|
|
118
|
-
### CLI USage
|
|
119
|
-
|
|
120
|
-
#### Configuration
|
|
121
|
-
|
|
122
|
-
```shell
|
|
123
|
-
$ taskbadger configure
|
|
124
|
-
|
|
125
|
-
Organization slug: my-org
|
|
126
|
-
Project slug: project-x
|
|
127
|
-
API Key: XYZ.ABC
|
|
128
|
-
|
|
129
|
-
Config written to ~/.config/taskbadger/config
|
|
130
|
-
```
|
|
131
|
-
|
|
132
|
-
#### Usage Examples
|
|
133
|
-
|
|
134
|
-
The CLI `run` command executes your command whilst creating and updating a Task Badger task.
|
|
135
|
-
|
|
136
|
-
```shell
|
|
137
|
-
$ taskbadger run "demo task" --action error email to:me@test.com -- path/to/script.sh
|
|
138
|
-
|
|
139
|
-
Task created: https://taskbadger.net/public/tasks/xyz/
|
|
140
|
-
```
|
taskbadger-1.7.0/README.md
DELETED
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
# Task Badger Python Client
|
|
2
|
-
|
|
3
|
-
This is the official Python SDK for [Task Badger](https://taskbadger.net/).
|
|
4
|
-
|
|
5
|
-
For full documentation go to https://docs.taskbadger.net/python/.
|
|
6
|
-
|
|
7
|
-

|
|
8
|
-
|
|
9
|
-
---
|
|
10
|
-
|
|
11
|
-
## Getting Started
|
|
12
|
-
|
|
13
|
-
### Install
|
|
14
|
-
|
|
15
|
-
```bash
|
|
16
|
-
pip install --upgrade taskbadger
|
|
17
|
-
```
|
|
18
|
-
|
|
19
|
-
### Client Usage
|
|
20
|
-
|
|
21
|
-
#### Configuration
|
|
22
|
-
|
|
23
|
-
```python
|
|
24
|
-
import taskbadger
|
|
25
|
-
|
|
26
|
-
taskbadger.init(
|
|
27
|
-
organization_slug="my-org",
|
|
28
|
-
project_slug="my-project",
|
|
29
|
-
token="***"
|
|
30
|
-
)
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
#### Usage with Celery
|
|
34
|
-
|
|
35
|
-
```python
|
|
36
|
-
import taskbadger
|
|
37
|
-
from celery import Celery
|
|
38
|
-
|
|
39
|
-
app = Celery("tasks")
|
|
40
|
-
|
|
41
|
-
@app.task(bind=True, base=taskbadger.Task)
|
|
42
|
-
def my_task(self):
|
|
43
|
-
task = self.taskbadger_task
|
|
44
|
-
for i in range(1000):
|
|
45
|
-
do_something(i)
|
|
46
|
-
if i % 100 == 0:
|
|
47
|
-
task.update(value=i, value_max=1000)
|
|
48
|
-
task.success(value=1000)
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
#### API Example
|
|
52
|
-
|
|
53
|
-
```python
|
|
54
|
-
from taskbadger import Task, Action, EmailIntegration, WebhookIntegration
|
|
55
|
-
|
|
56
|
-
# create a new task with custom data and an action definition
|
|
57
|
-
task = Task.create(
|
|
58
|
-
"task name",
|
|
59
|
-
data={
|
|
60
|
-
"custom": "data"
|
|
61
|
-
},
|
|
62
|
-
actions=[
|
|
63
|
-
Action("*/10%,success,error", integration=EmailIntegration(to="me@example.com")),
|
|
64
|
-
Action("cancelled", integration=WebhookIntegration(id="webhook:demo")),
|
|
65
|
-
]
|
|
66
|
-
)
|
|
67
|
-
|
|
68
|
-
# update the task status to 'processing' and set the value to 0
|
|
69
|
-
task.started()
|
|
70
|
-
try:
|
|
71
|
-
for i in range(100):
|
|
72
|
-
do_something(i)
|
|
73
|
-
if i!= 0 and i % 10 == 0:
|
|
74
|
-
# update the progress of the task
|
|
75
|
-
task.update_progress(i)
|
|
76
|
-
except Exception as e:
|
|
77
|
-
# record task errors
|
|
78
|
-
task.error(data={
|
|
79
|
-
"error": str(e)
|
|
80
|
-
})
|
|
81
|
-
raise
|
|
82
|
-
|
|
83
|
-
# record task success
|
|
84
|
-
task.success()
|
|
85
|
-
```
|
|
86
|
-
|
|
87
|
-
### CLI USage
|
|
88
|
-
|
|
89
|
-
#### Configuration
|
|
90
|
-
|
|
91
|
-
```shell
|
|
92
|
-
$ taskbadger configure
|
|
93
|
-
|
|
94
|
-
Organization slug: my-org
|
|
95
|
-
Project slug: project-x
|
|
96
|
-
API Key: XYZ.ABC
|
|
97
|
-
|
|
98
|
-
Config written to ~/.config/taskbadger/config
|
|
99
|
-
```
|
|
100
|
-
|
|
101
|
-
#### Usage Examples
|
|
102
|
-
|
|
103
|
-
The CLI `run` command executes your command whilst creating and updating a Task Badger task.
|
|
104
|
-
|
|
105
|
-
```shell
|
|
106
|
-
$ taskbadger run "demo task" --action error email to:me@test.com -- path/to/script.sh
|
|
107
|
-
|
|
108
|
-
Task created: https://taskbadger.net/public/tasks/xyz/
|
|
109
|
-
```
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
from typing import Optional
|
|
2
|
-
|
|
3
|
-
import typer
|
|
4
|
-
from rich import print
|
|
5
|
-
|
|
6
|
-
from taskbadger import __version__
|
|
7
|
-
from taskbadger.cli import create, get, list_tasks_command, run, update
|
|
8
|
-
from taskbadger.config import get_config, write_config
|
|
9
|
-
from taskbadger.sdk import _parse_token
|
|
10
|
-
|
|
11
|
-
app = typer.Typer(
|
|
12
|
-
rich_markup_mode="rich",
|
|
13
|
-
context_settings={"help_option_names": ["-h", "--help"]},
|
|
14
|
-
)
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
app.command(context_settings={"allow_extra_args": True, "ignore_unknown_options": False})(run)
|
|
18
|
-
app.command(context_settings={"ignore_unknown_options": False})(get)
|
|
19
|
-
app.command(context_settings={"ignore_unknown_options": False})(create)
|
|
20
|
-
app.command(context_settings={"ignore_unknown_options": False})(update)
|
|
21
|
-
app.command("list", context_settings={"ignore_unknown_options": False})(list_tasks_command)
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
def version_callback(value: bool):
|
|
25
|
-
if value:
|
|
26
|
-
print(f"Task Badger CLI Version: {__version__}")
|
|
27
|
-
raise typer.Exit()
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
@app.command()
|
|
31
|
-
def configure(ctx: typer.Context):
|
|
32
|
-
"""Update CLI configuration."""
|
|
33
|
-
config = ctx.meta["tb_config"]
|
|
34
|
-
token = typer.prompt("API Key", default=config.token)
|
|
35
|
-
parsed = _parse_token(token)
|
|
36
|
-
if parsed:
|
|
37
|
-
org_slug, project_slug, api_key = parsed
|
|
38
|
-
print(f"Project key detected — organization: [green]{org_slug}[/green], project: [green]{project_slug}[/green]")
|
|
39
|
-
config.organization_slug = org_slug
|
|
40
|
-
config.project_slug = project_slug
|
|
41
|
-
config.token = token
|
|
42
|
-
else:
|
|
43
|
-
config.organization_slug = typer.prompt("Organization slug", default=config.organization_slug)
|
|
44
|
-
config.project_slug = typer.prompt("Project slug", default=config.project_slug)
|
|
45
|
-
config.token = token
|
|
46
|
-
path = write_config(config)
|
|
47
|
-
print(f"Config written to [green]{path}[/green]")
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
@app.command()
|
|
51
|
-
def docs():
|
|
52
|
-
"""Open Task Badger docs in a browser."""
|
|
53
|
-
typer.launch("https://docs.taskbadger.net")
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
@app.command()
|
|
57
|
-
def info(ctx: typer.Context):
|
|
58
|
-
"""Show CLI configuration."""
|
|
59
|
-
config = ctx.meta["tb_config"]
|
|
60
|
-
print(str(config))
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
@app.callback()
|
|
64
|
-
def main(
|
|
65
|
-
ctx: typer.Context,
|
|
66
|
-
org: Optional[str] = typer.Option(
|
|
67
|
-
None,
|
|
68
|
-
"--org",
|
|
69
|
-
"-o",
|
|
70
|
-
metavar="TASKBADGER_ORG",
|
|
71
|
-
show_default=False,
|
|
72
|
-
help="Organization Slug. This will override values from the config file and environment variables.",
|
|
73
|
-
),
|
|
74
|
-
project: Optional[str] = typer.Option(
|
|
75
|
-
None,
|
|
76
|
-
"--project",
|
|
77
|
-
"-p",
|
|
78
|
-
show_envvar=False,
|
|
79
|
-
metavar="TASKBADGER_PROJECT",
|
|
80
|
-
show_default=False,
|
|
81
|
-
help="Project Slug. This will override values from the config file and environment variables.",
|
|
82
|
-
),
|
|
83
|
-
version: Optional[bool] = typer.Option( # noqa
|
|
84
|
-
None,
|
|
85
|
-
"--version",
|
|
86
|
-
callback=version_callback,
|
|
87
|
-
is_eager=True,
|
|
88
|
-
help="Show CLI Version",
|
|
89
|
-
),
|
|
90
|
-
):
|
|
91
|
-
"""
|
|
92
|
-
Task Badger CLI
|
|
93
|
-
"""
|
|
94
|
-
config = get_config(org=org, project=project)
|
|
95
|
-
ctx.meta["tb_config"] = config
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
if __name__ == "__main__":
|
|
99
|
-
app()
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{taskbadger-1.7.0 → taskbadger-2.0.0}/taskbadger/internal/api/action_endpoints/action_cancel.py
RENAMED
|
File without changes
|
{taskbadger-1.7.0 → taskbadger-2.0.0}/taskbadger/internal/api/action_endpoints/action_create.py
RENAMED
|
File without changes
|
{taskbadger-1.7.0 → taskbadger-2.0.0}/taskbadger/internal/api/action_endpoints/action_get.py
RENAMED
|
File without changes
|
{taskbadger-1.7.0 → taskbadger-2.0.0}/taskbadger/internal/api/action_endpoints/action_list.py
RENAMED
|
File without changes
|
|
File without changes
|
{taskbadger-1.7.0 → taskbadger-2.0.0}/taskbadger/internal/api/action_endpoints/action_update.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{taskbadger-1.7.0 → taskbadger-2.0.0}/taskbadger/internal/api/task_endpoints/task_partial_update.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{taskbadger-1.7.0 → taskbadger-2.0.0}/taskbadger/internal/models/patched_task_request_tags.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|