A set of extended APIs for PyInvoke for composable scripts, plugins and richer output
Project description
invoke-toolkit
A set of extensions for rich output, more options in collection/config discovery through entry-points.
This extends the Collection from Invoke so it can create automatically collections.
Table of Contents
Features
- Task discovery by namespace for extendable/composable CLIs
- Discovery to plain old tasks.py (or any other name)
- Local tasks discovery from
local_tasks.pyin the current directory - Integration with stand alone binaries for specific tasks
- Task result caching with TTL support via
diskcache(optional) - Future Download binaries
Do I need this package
If you have...
- Used
invokefor a while and... - Have a large
tasks.pythat needs to be modularized - Have a lot of copy/pasted code in multiple
tasks.pyacross multiple repos. - Have exceeded the approach of a repository cloned as
~/tasks/with more .py files that you want to manage. - Or you want to combine various tasks defined in multiple directories
- You want to create a zipped (shiv) redistribute script for container environments like Kubernetes based CI environments with only requiring the Python interpreter.
Installation
pip install invoke-toolkit
Quick Start
Using Local Tasks
Create a local_tasks.py file in your project directory with your tasks:
from invoke_toolkit import task
@task()
def my_task(ctx):
"""Do something useful"""
print("Hello from local tasks!")
Then run it with:
intk local.my-task
Local tasks are automatically discovered and added to the local namespace, allowing you to keep project-specific tasks separate from your main task collection.
Using Task Caching
Cache expensive task results with the cache parameter:
from invoke_toolkit import task
# Simple caching (no expiration)
@task(cache=True)
def expensive_task(ctx, param: str) -> str:
"""Results are cached across invocations."""
return do_expensive_computation(param)
# Caching with TTL (1 hour)
@task(cache={"ttl": 3600})
def cached_task(ctx, name: str) -> dict:
"""Results cached for 1 hour."""
return fetch_data(name)
# Caching with ignored arguments
@task(cache={"ttl": 600, "ignore_args": ["verbose"]})
def cached_with_options(ctx, query: str, verbose: bool = False) -> list:
"""Cache key ignores verbose flag."""
return search(query, verbose=verbose)
Cache features:
- Cache location is computed from git repository root + platformdirs
- Debug logging (
-dflag) shows cache hits/misses - Graceful degradation when
diskcacheis not installed
To enable caching, install with the cache extra:
pip install invoke-toolkit[cache]
Development
This project utilizes the pre-commit framework, make sure you run:
pre-commit install
With uvx:
uvx --with pre-commit-uv pre-commit install
License
invoke-toolkit is distributed under the terms of the MIT license.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file invoke_toolkit-0.0.60.tar.gz.
File metadata
- Download URL: invoke_toolkit-0.0.60.tar.gz
- Upload date:
- Size: 156.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
69a82d58e4bad45cbf84ef2c1c39a84722d81dc47b7fde32e84be9c40babe8d9
|
|
| MD5 |
fbdebb3cacbf99ae79d78071578c6cb7
|
|
| BLAKE2b-256 |
f999761bd3a769de97175836606fd4d24bcf18c0e6c01734e9b204de23fa0557
|
Provenance
The following attestation bundles were made for invoke_toolkit-0.0.60.tar.gz:
Publisher:
publish-releases.yaml on D3f0/invoke-toolkit
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
invoke_toolkit-0.0.60.tar.gz -
Subject digest:
69a82d58e4bad45cbf84ef2c1c39a84722d81dc47b7fde32e84be9c40babe8d9 - Sigstore transparency entry: 1439857963
- Sigstore integration time:
-
Permalink:
D3f0/invoke-toolkit@f512b61a47b07d64df3c1f1687b8d8ce399fa289 -
Branch / Tag:
refs/tags/v0.0.60 - Owner: https://github.com/D3f0
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-releases.yaml@f512b61a47b07d64df3c1f1687b8d8ce399fa289 -
Trigger Event:
release
-
Statement type:
File details
Details for the file invoke_toolkit-0.0.60-py3-none-any.whl.
File metadata
- Download URL: invoke_toolkit-0.0.60-py3-none-any.whl
- Upload date:
- Size: 100.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
93a562672abd254b45f978d5b942e392e62e56fd7bef1d549c854e6cfc75681f
|
|
| MD5 |
e52fba70515df69a259ce1ebc2086f53
|
|
| BLAKE2b-256 |
c819da6ce14e591217045ce6f862910c7202de6df51840ba4502959940d54ac3
|
Provenance
The following attestation bundles were made for invoke_toolkit-0.0.60-py3-none-any.whl:
Publisher:
publish-releases.yaml on D3f0/invoke-toolkit
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
invoke_toolkit-0.0.60-py3-none-any.whl -
Subject digest:
93a562672abd254b45f978d5b942e392e62e56fd7bef1d549c854e6cfc75681f - Sigstore transparency entry: 1439857977
- Sigstore integration time:
-
Permalink:
D3f0/invoke-toolkit@f512b61a47b07d64df3c1f1687b8d8ce399fa289 -
Branch / Tag:
refs/tags/v0.0.60 - Owner: https://github.com/D3f0
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-releases.yaml@f512b61a47b07d64df3c1f1687b8d8ce399fa289 -
Trigger Event:
release
-
Statement type: