Git Product home page Git Product logo

qik's Introduction

Qik

Qik (quick) is a command runner that understands the import graph. Like make, but with hash-based caching and advanced dependencies such as globs, imports, external packages, and more.

Qik's command caching ensures you never do redundant work. Parametrize commands across modules, watch and re-run them reactively, or filter commands since a git hash. Qik can dramatically improve CI and development time.

Although qik has special functionality with Python projects, any git-based repo can use qik as a command runner.

Read the qik docs here or this blog post on why I built Qik.

Installation

pip install qik

For local development, we recommend installing most optional dependencies with:

pip install "qik[dev]"

Qik is compatible with Python 3.10 - 3.12, Linux, OSX, and WSL. It requires git.

Quick Start

File and Glob Dependencies

Here we use the pip-compile executable from pip-tools to lock PyPI distributions. Create qik.toml with the following:

[commands.lock]
exec = "pip-compile > requirements.txt"
deps = ["requirements.in"]
cache = "repo"

Running qik lock executes pip-compile > requirements.txt. Results are cached in your repo until requirements.in changes.

Distribution Dependencies

Change deps to re-run this command if we upgrade pip-tools:

deps = ["requirements.in", {type = "pydist", name = "pip-tools"}]

Installing a different version of pip-tools will break the command cache.

Modular Commands

Parametrize commands over modules, for example, running the ruff code formatter:

modules = ["a_module", "b_module", "c_module"]

[commands.format]
exec = "ruff format {module.dir}"
deps = ["{module.dir}/**.py"]
cache = "repo"

Running qik format will parametrize ruff format in parallel over all available threads and configured modules. Use -n to adjust the number of threads and -m to supply modules:

qik format -n 2 -m b_module -m c_module

Import Graph Dependencies

Some commands, such as pyright type checking, should re-run whenever module files, imported code, or third-party dependencies change. Here we cache this command based on my.module files or dependencies:

plugins = ["qik.pygraph"]

[commands.check-types]
exec = "pyright my/module"
deps = [{type = "pygraph", pyimport = "my.module"}]
cache = "repo"

Parametrize this command over multiple modules:

modules = ["a_module", "b_module", "c_module"]
plugins = ["qik.pygraph"]

[commands.check-types]
exec = "pyright {module.dir}"
deps = [{type = "pygraph", pyimport = "{module.pyimport}"}]
cache = "repo"

We use the qik.pygraph plugin, which provides commands that lock the python import graph.

Command Dependencies

Command dependencies help order execution. For example, change deps of command.check-types to run type checking only after code has been successfully formatted:

deps = [
    {type = "pygraph", pyimport = "{module.pyimport}"},
    {type = "command", name = "format"}
]

Caching

We've shown examples of the repo cache, which stores metadata of the most recent runs in the repo. Qik also offers local and remote caches. To use a remote cache, define command artifacts. For example, the lock command generates a requirements.txt file:

[commands.lock]
exec = "pip-compile > requirements.txt"
deps = ["requirements.in"]
artifacts = ["requirements.txt"]
cache = "s3"

Above we're using the AWS S3 cache. See this section for a deep dive on how caching works, along with how to configure remote caching.

Command Line Interface

The core CLI functionality is as follows:

  • qik to run all commands.
  • qik <cmd_name> <cmd_name> to run specific commands.
  • --watch to reactively run selected commands.
  • --since to select commands based on changes since a git reference.
  • -f to run without the cache.
  • -m to run against specific modules.
  • -n to set the number of threads.
  • --ls to list commands instead of running them.

See the command runner section for other advanced options, such as selecting commands based on cache status and setting the default context profile.

Next Steps

Read the following guide to become a qik expert:

  • Commands: Configuring and running commands. Learn about all the dependencies, selectors, and runtime behavior.
  • Context: Using environment-based context and runtime profiles.
  • Caching: How caching works and how to configure all cache types, including S3.
  • CI/CD: Patterns for optimizing CI/CD time.

After this, read the:

  • Cookbook for command and CLI snippets.
  • Roadmap for all the exciting upcoming features.
  • Blog for updates, how-tos, and other articles.

Disclaimer

Qik is currently in beta. Bumping the minor version (e.g. 0.1.0 to 0.2.0) will indicate an API break until we release version 1.0.0.

Be diligent when using qik in your CI/CD. We recommend including a global dependency in your commands to regularly break the cache. We also recommend understanding how the import graph is built when using import graph dependencies.

qik's People

Contributors

wesleykendall avatar

Stargazers

 avatar Eureka avatar st01cs avatar Vladislav Sorokin avatar Or Carmi  avatar Marc G avatar Alexis Gentilhomme avatar Andrew Lange avatar Victor Shepelev  avatar Filipp Frizzy avatar Koki Nishihara avatar Kamil Chmielewski avatar Connor Adams avatar Ülgen Sarıkavak avatar Elio Esteves Duarte avatar  avatar Stephen Brown-Bourne avatar Balaji Hariharan avatar Olatunji Joshua Kayode avatar Joshua Gourneau avatar Caelean Barnes avatar Jack Paparian avatar Tómas Árni Jónasson avatar Ryan Bales avatar  avatar Michael Chrisco avatar Max Muoto avatar

Watchers

 avatar Balaji Hariharan avatar

Forkers

sorokinvld

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.