An opinionated, TOML based task runner
Project description
doot
Version : 1.1.1
Author : John Grey
Date : 2022-12-09
Overview
This started out as an opinionated rewrite of the doit task runner. For other, more mature alternatives, see Luigi, and SnakeMake and, of course, GNU Make.
Mainly, I found the process of authoring tasks and reusing them to be convoluted. Doot is an attempt to simplify matters. Settings and tasks are specified in toml files, which the doot program assists in writing. More complicated logic is written in normal python, either as a library (eg: Dootle, or as local task specific code.
To use doot, call doot help.
Examples and details can be found in the Wiki
doot.toml
The doot.toml file provides a place for marking where doot considers the current working directory,
and lets you control general settings.
It is created from a default template by just running doot, if no doot.toml file exists.
If you don't want a separate file, everything can be added to pyproject.toml by prepending tool.doot to sections.
eg:
# -*- mode:conf-toml; -*-
[startup]
loaders = { commands="default", task="default", parser="default"}
location_check = { make_missing = true }
sources = {tasks=[".tasks"], code=[]}
sleep = { task=0.2, subtask=1, batch=1 }
[shutdown]
notify = { speak=false }
defaulted_values = { write=false, path=".defaulted_values.toml" }
[logging]
stream = { level="WARNING", allow=["doot"], format="{levelname:<8} : {message}", colour=true }
file = { level="DEBUG", allow=["doot"], format="{levelname:<8} : {message:<20} :|: (module:{module} line:{lineno} fn:{funcName})" }
printer = { level="INFO", colour=true}
[plugins]
# Allows for defining shorthands
command = { other-run = "doot.cmds.run_cmd:RunCmd", tasks = "doot.cmds.list_cmd:ListCmd" }
report-line = {}
reporter = {}
action = {}
task = {}
[commands]
run = { tracker = "default", runner = "default", reporter= "default", report-line = []}
[[locations]]
temp = ".temp"
desktop = "~/Desktop"
Tasks
Tasks are specified in toml, by default in the doot.toml file, or toml files in a .tasks directory, but that can be changed in doot.toml:settings.tasks.sources.
The easiest way to write one is to use doot stub.
eg: doot stub mygroup::mytask produces:
[[tasks.mygroup]] # mygroup is the group this task is part of
name = "mytask" # combined together, this means this specific task is `mygroup::mytask`
version = "0.1" # <str>
ctor = "task" # <type> the python class this task uses. See the plugins listed in 'doot plugins'
doc = ["Text to help understand what this task does"] # <list[str]>
required_for = [] # <list[TaskArtifact]> see below
depends_on = [] # <list[TaskArtifact]> see below
actions = [] # <list[Any]> See below
You can see what tasks are available by calling doot list.
You can get help on a specific task by calling doot {task} --help or doot help {task}.
You can run a task by calling doot {task} or doot run {task}.
eg: doot mygroup::mytask
Actions
Tasks run a sequence of actions, specified in the following form. the argument to do can be an import specifier,
or an alias from the actions section of doot plugins:
{ do="write!", args=[], aKwd="val" },
{ do="doot.actions.io:WriteAction", args=[], aKwd="val" },
You can get help on writing an action using doot stub --Actions {action}. eg: doot stub --A write! will print:
- Action write! : doot.actions.io:WriteAction
-- Declared kwargs for action: ['from_', 'to']
-- Toml Form:
{ do="write!", args=[] }
- For Custom Python Actions, implement the following in the .tasks director
def custom_action(spec:ActionSpec, task_state:dict) -> None|bool|dict:...
When specifying values in toml you can use direct keys, or indirect keys. For example, the action:
{ do="log", msg="This is a test", level="INFO" }
will log that exact message, at that exact logging level. Meanwhile the action:
{ do="log", msg_="gen_msg", level="INFO" }
Will use the string stored in the task state's 'gen_msg' variable, assuming that variable has been set by a prior action, or the toml spec of the task. This also allows you to specify the key to put information into:
{ do="read!", from="{data}/names.txt", update_="names" }
This reads from the names.txt file, and adds it to the task state in the key names.
Task Dependencies
Tasks can depend on other tasks, or artifacts like files.
These can be specified in the required_for and depends_on fields of a task spec.
To depend on a task, use its full name. eg: examples::basic.
To depend on a file, specify it with the prefix file:>. eg: file:>./doot.toml.
String and Path expansion
To simplify using locations, both doot.toml and task toml files can have [[locations]] tables.
eg:
[[locations]]
tasks = ".tasks"
home = "~" # will be made into an absolute path when a task uses the {home} key in a path.
data = "doot/data" # A relative path, will be made absolute, according to cwd.
other = "/somewhere/else" # Absolute paths can also be used.
subdata = "{data}/blah" # {data} will expand to doot/data at runtime
Expansion of arguments is relatively straight forward, and is basically python string expansion. Actions will expand parameters they support. eg:
actions = [
# This will write from the task state['data'] into the path "doot/data/example.txt":
{do="write!", from_="data", to="{data}/example.txt" },
# This will print to stdout the task state['data']:
{do="log", msg="The data is: {data}" }
]
Entry Points / Plugins
Entry Points for doot to automatically recognise system installed packages are supported. Eg:
# From dootle's pyproject.toml
[project.entry-points."doot.plugins.command"]
example = "dootle.cmds.example_cmd:ExampleCmd"
[project-entry-points."doot.plugins.action"]
an_action = "..."
Plugins are specified in the pyproject.toml table [project.entry-points."doot.plugins.TYPE"],
where TYPE is one of the forms defined in variables found in doot.constants:
FRONTEND_PLUGIN_TYPES: "command", "reporter", "report-line",BACKEND_PLUGIN_TYPES: "tracker", "runner", "command-loader", "task-loader", "parser", "action", "job", "database"
Currently available plugins are listed with the command doot plugins.
They can be filtered with a simple pattern (pattern:str in plugin.fullname:str essentially).
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 doot-1.1.1.tar.gz.
File metadata
- Download URL: doot-1.1.1.tar.gz
- Upload date:
- Size: 167.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
15f8db950c87b2ea285b70b3074d1efe8425daecfbeba3f4bb4763b9fb59e534
|
|
| MD5 |
8d2125b41185db901197c918e92f2df5
|
|
| BLAKE2b-256 |
9f923d417ec830b90e875594d0bae92bc995af538762f81391ced77e226478ee
|
Provenance
The following attestation bundles were made for doot-1.1.1.tar.gz:
Publisher:
python-publish.yml on jgrey4296/doot
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
doot-1.1.1.tar.gz -
Subject digest:
15f8db950c87b2ea285b70b3074d1efe8425daecfbeba3f4bb4763b9fb59e534 - Sigstore transparency entry: 201460603
- Sigstore integration time:
-
Permalink:
jgrey4296/doot@3dde58c3eeacbfec3814a431ff16cf52169782ca -
Branch / Tag:
refs/tags/1.1.1 - Owner: https://github.com/jgrey4296
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@3dde58c3eeacbfec3814a431ff16cf52169782ca -
Trigger Event:
release
-
Statement type:
File details
Details for the file doot-1.1.1-py3-none-any.whl.
File metadata
- Download URL: doot-1.1.1-py3-none-any.whl
- Upload date:
- Size: 254.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
819649496e8b4e239d99b7f4ec75b2a6bdba058838bea87bf38e289edf7f2af8
|
|
| MD5 |
7882ce9aa0a477fd17b299e1d09a612b
|
|
| BLAKE2b-256 |
9750220a41d9303532dc61660a75e572971592d3e60745ea1020a1272880ffff
|
Provenance
The following attestation bundles were made for doot-1.1.1-py3-none-any.whl:
Publisher:
python-publish.yml on jgrey4296/doot
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
doot-1.1.1-py3-none-any.whl -
Subject digest:
819649496e8b4e239d99b7f4ec75b2a6bdba058838bea87bf38e289edf7f2af8 - Sigstore transparency entry: 201460606
- Sigstore integration time:
-
Permalink:
jgrey4296/doot@3dde58c3eeacbfec3814a431ff16cf52169782ca -
Branch / Tag:
refs/tags/1.1.1 - Owner: https://github.com/jgrey4296
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@3dde58c3eeacbfec3814a431ff16cf52169782ca -
Trigger Event:
release
-
Statement type: