Skip to main content

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] [--file-output FILE_OUTPUT] 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, ...)
#   --file-output FILE_OUTPUT
#                         Log tasks output to files, one per task. This option lets you specify the directory of the log files

jorun ./conf.yml

Configuration

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. The first tasks to run are the ones without dependencies. If you declare one or more dependencies, the task will not run until all the dependencies are either:

  • completed (i.e. the task finished executing), by default
  • the completion pattern is matched (the regex pattern matched a line of the task output), if you set a completion_pattern
  • launched, if you set the run_mode to indefinite

Reference

The options in bold are mandatory, while the others can be omitted.

YAML Configuration file

Option Description
tasks a mapping between task names and the task configuration

Task configuration

Option Description
type (string) the task type (shell, docker or group)
shell (object) if type is shell, the shell configuration
docker (object) if type is docker, the docker configuration
depends (array) an optional list of task names this task depends on
run_mode (string) wait_completion (default) will wait for the task to finish before launching the next one, indefinite will launch the next one immediately
completion_pattern (string) if the run_mode is wait_completion, a regex pattern that if matched with a line will start the next dependent task(s)
pattern_in_stderr (boolean) if completion_pattern is specified, whether to search for the pattern in the error output

Shell configuration

Option Description
command (string or array) the command to run, can be a string or a list of command arguments
working_directory (string) the working directory of the command
environment (object) a mapping describing the environment variables to pass to the command

Docker configuration

Option Description
container_name (string) the name to give to the container
image (string) the docker image to run
docker_arguments (array) any additional arguments for the docker run command, to be inserted before the image name
docker_command (array) any arguments to be appended after the image name
environment (object) env variables to be passed to the docker container
working_directory (string) a working directory for the docker command to be run from
stop_at_exit (boolean) will stop the container when the task is closed

Project details


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.11.tar.gz (8.1 kB view hashes)

Uploaded Source

Built Distribution

jorun-0.0.11-py3-none-any.whl (12.0 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page