Skip to main content

Simple task runner for applications set up with docker and kubernetes

Project description

tuliptask

Simple task runner supports running multiple tasks in parallel.

Installation

pip install tuliptask

Basic Usage

  • Create a tulip task file: tulipfile.py
  • Add a simple task
from tuliptask import TulipTask

@TulipTask.task("dev") # use decorator to define a task
class Dev:
    def run(self, args): # tuliptask will call `run()` function to run the task.
        print("start development")

TulipTask.start()
  • run the command in terminal:
tulip dev

add arguments to the task

from tuliptask import TulipTask

@TulipTask.task("dev")
class Dev:
    def setup(self, parser): # tuliptask will call `setup()` function to add arguments.
        parser.add_argument("--container") # use Python built-in `argparse` to add arguments

    def run(self, args):
        print(f"start development for container: {args.container}")

TulipTask.start()

run shell command

def run(self, args):
    tulip.proc.run("docker build")
    # or use docker command shortcut
    tulip.proc.d("build")

available command shortcuts:

  • proc.d() = proc.run("docker")
  • proc.dc() = proc.run("docker-compose")
  • proc.k() = proc.run("kubectl")
  • proc.mk() = proc.run("minikube")

extend base task

Tuliptask provides several base tasks for convenience.

from tuliptask import TulipTask
from tuliptask.tasks import KubeTask

@TulipTask.task("dev")
class Dev(KubeTask):
    def setup(setup, parser):
        super().setup(parser)

    def run(self, args):
        super().run(args)
        print("start development")

TulipTask.start()

base task will add base setup(), run() and other convenient functions.

KubeTask

  • setup(parser):
    • --context: kubernetes context
    • --namespace: kubernetes namespace
  • k(cmdstr, **kwargs): kubectl command shortcut with --context and --namespace args appended if available
  • kube_info(): print namespace and context info

multi-run

When we have multiple tasks or services that do not depend on each other, it's waste of time to run them in serial. For example, if you need to build backend and frontend images, they can be run in parallel to speed up the process.

from tuliptask import TulipTask, MultiRun, proc

@TulipTask.task("dev")
class Dev:
    def run(self, args):
        mr = MultiRun()
        mr.add(proc.d, args=("build api", ))
        mr.add(proc.d, args=("build ui", ))
        mr.run()

TulipTask.start()

WIP

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

tuliptask-0.0.2.tar.gz (4.4 kB view details)

Uploaded Source

File details

Details for the file tuliptask-0.0.2.tar.gz.

File metadata

  • Download URL: tuliptask-0.0.2.tar.gz
  • Upload date:
  • Size: 4.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.4

File hashes

Hashes for tuliptask-0.0.2.tar.gz
Algorithm Hash digest
SHA256 dd9d7572993837ae0fbe0c8211757c2881a6daf3c511372b7aa270625699053f
MD5 c7fd10898f21329725b1a12ecfcf3304
BLAKE2b-256 649b90ae706354a7f84cf3eac46753bedd851a6b3d753f2b54c1675ab52dc068

See more details on using hashes here.

Supported by

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