A customizable task runner
Project description
Jorun
Jorun is a task runner written in python, supporting windows and linux and configurable through a YML file
Install and run
pip install jorun
Usage
# usage: jorun [-h] [--level LEVEL] configuration_file
#
# A smart task runner
#
# positional arguments:
# configuration_file The yml configuration file to run
#
# options:
# -h, --help show this help message and exit
# --level LEVEL The log level (DEBUG, INFO, ...)
jorun ./conf.yml
Configuration
main_task: db
tasks:
db:
type: docker
docker:
container_name: test
image: postgres
docker_arguments:
- "--rm"
stop_at_exit: true
environment:
POSTGRES_PASSWORD: test
completion_pattern: .*database system is ready to accept connections.*
pattern_in_stderr: true
redis:
type: docker
docker:
container_name: rds
image: redis
docker_arguments:
- "--rm"
stop_at_exit: true
completion_pattern: .*Ready to accept connections.*
pattern_in_stderr: true
depends:
- db
test:
type: group
depends:
- redis
test_1:
type: shell
shell:
command: echo TEST 1
depends:
- test
test_2:
type: shell
shell:
command: echo TEST 2
depends:
- test
test_3:
type: shell
shell:
command: echo TEST 3
depends:
- test
This sample YML file shows two task types you can run:
- Shell: a task launching a shell command
- Docker: a task optimized for docker containers
- Group: a task that groups other tasks (for parallel execution)
The task runner supports searching for a pattern in the task output to signal its completion. This way you can start a dependent task after the pattern shows up in the task output.
Tasks are chained through dependencies. If you declare a task dependency on another task, it will wait for the first task to complete before launching the second task
Reference
YAML Configuration file
main_task: str
: the name of the task to be executedtasks: Dict[str, Task]
: a mapping between task names and the task configuration
Task configuration
type: Literal["shell", "docker", "group"]
: the task typeshell: Optional[ShellTask]
: if type is shell, the shell configurationdocker: Optional[DockerTask]
: if type is docker, the docker configurationdepends: Optional[List[str]]
: an optional list of task names this task depends upon
Shell configuration
command: Union[str, List[str]]
: the command to run, can be a string or a list of command argumentsrun_mode: Literal["wait_completion", "indefinite"]
: wait_completion will wait for the task to finish before launching the next one, indefinite will launch the next one immediatelycompletion_pattern: Optional[str]
: if the run_mode is wait_completion, a pattern that if matched with a line will start the next dependent task(s)pattern_in_stderr: Optional[bool]
: whether to search for the pattern in the error outputworking_directory: Optional[str]
: the working directory of the commandenvironment: Optional[Dict[str, str]]
: a mapping with the environment variables to pass to the command
Docker configuration
container_name: str
: the name to give to the containerimage: str
: the docker image to rundocker_arguments: Optional[List[str]]
: any additional arguments for the docker run command, to be inserted before the image namedocker_command: Optional[List[str]]
: any arguments to be appended after the image nameenvironment: Optional[Dict[str, str]]
: env variables to be passed to the docker containerworking_directory: Optional[str]
: a working directory for the docker command to be run fromstop_at_exit: bool
: will stop the container when the task is closedrun_mode: Literal["wait_completion", "indefinite"]
: wait_completion will wait for the task to finish before launching the next one, indefinite will launch the next one immediatelycompletion_pattern: Optional[str]
: if the run_mode is wait_completion, a pattern that if matched with a line will start the next dependent task(s)pattern_in_stderr: Optional[bool]
: whether to search for the pattern in the error output
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
jorun-0.0.10.tar.gz
(7.3 kB
view hashes)
Built Distribution
jorun-0.0.10-py3-none-any.whl
(11.2 kB
view hashes)