6 releases

new 0.1.9 Jun 6, 2023
0.1.8 May 23, 2023
0.1.6 Feb 20, 2023

#69 in Caching

Download history 60/week @ 2023-02-18 12/week @ 2023-02-25 6/week @ 2023-03-25 7/week @ 2023-04-01 6/week @ 2023-04-15 29/week @ 2023-05-06 4/week @ 2023-05-13 50/week @ 2023-05-20 11/week @ 2023-05-27

94 downloads per month

MIT license

225KB
5.5K SLoC

Rust 5K SLoC // 0.0% comments TypeScript 423 SLoC // 0.0% comments Python 376 SLoC // 0.0% comments Shell 54 SLoC // 0.2% comments C 6 SLoC

Razel

Rust MIT CI

Deno module Python module Rust crate

A command executor with caching. It is:

  • Fast: caching avoids repeated execution of commands which haven't changed
  • Reliable: commands are executed in a sandbox to detect missing dependencies
  • Easy to use: commands are specified using a high-level TypeScript or Python API and convenience functions/tasks are built-in
  • Made for: data processing pipelines with executables working on files and many dependencies between those

Razel is not the best choice for building software, especially there's no built-in support for compiler setup and header dependencies.

Getting Started

The native input format for Razel is a razel.jsonl file, see the example test/razel.jsonl. It can be run with razel exec -f test/razel.jsonl.

The preferred way is to use one of the high-level APIs. Both allow specifying the commands in an object-oriented style and provide a run() function which creates the razel.jsonl file, downloads the native razel binary and uses it to execute the commands.

Output files are created in <cwd>/razel-out.

TypeScript API

Install Deno to use the TypeScript API. Run the example Deno script:

deno run -A --check test/deno.ts -- -v

Python API

The Python API requires Python >= 3.8. Install the package and run the example Python script:

pip install razel
python test/python.py -v

Batch file

In addition to razel.jsonl, Razel can directly execute a batch file containing commands. Input and output files need to be specified, which is WIP.

Execute the example test/batch.sh with Razel:

razel exec -f test/batch.sh

Building Razel from source

Use rustup to install Rust. Install protobuf-compiler. Then run cargo install razel.

Project Status

Razel is in active development and not ready for production. CLI and format of razel.jsonl will likely change.

OS Status Note
Linux stable, main development platform
Mac used and tested in CI
Windows (✓) tested in CI only
Feature Status Note
command execution in sandbox
multithreaded execution
local caching
remote caching WIP
remote execution TODO
OOM handling: retry with less concurrency ✓ Linux requires sudo cgcreate -a $USER -t $USER -g memory:razel

Why not ...?

  • Bazel is a multi-language build tool. However, for the use case Razel targets, there are some issues:
    • additional launcher script required for some simple tasks
      • using stdout of action as input for another action
      • parsing measurements from stdout of action
      • CTest features like FAIL_REGULAR_EXPRESSION, WILL_FAIL
    • difficult to get command lines for debugging
    • no automatic disk usage limit/cleanup for local cache - all temp output needs to fit on disk
    • no native support for response files
    • resources cannot be reserved to run real-time critical tests
    • content of bazel-bin/out directories is not defined (contains mixture of current build and cache)
  • CTest is nice for building C/C++ code and CTest can be used for testing, but it does not support caching and managing dependencies between tests is difficult.

Features

Measurements

Razel parses the stdout of executed commands to capture runtime measurements and writes them to razel-out/razel-metadata/measurements.csv. Currently, the <CTestMeasurement> and <DartMeasurement> tags as used by CTest/CDash are supported:

<CTestMeasurement type="numeric/double" name="score">12.3</CTestMeasurement>
<CTestMeasurement type="text/string" name="result">ok</CTestMeasurement>

Supporting custom formats is planned.

Tags

Tags can be set on commands. Any custom string can be used as tag, a colon should be used for grouping. The tags are added to razel-out/razel-metadata/execution_times.json. Using tags for filtering commands and creating reports is planned.

Tags with razel: prefix are reserved and have special meaning:

  • razel:quiet: don't be verbose if command succeeded
  • razel:verbose: always show verbose output

Param/Response files

Commands with huge number of arguments might result in command lines which are too long to be executed by the OS. Razel detects those cases and replaces the arguments with a response file. The filename starts with @.

Acknowledgements

The idea to build fast and correct is based on Bazel. Razel uses data structures from the Bazel Remote Execution API for caching.

Dependencies

~33–69MB
~1.5M SLoC