Crates.io | razel |
lib.rs | razel |
version | |
source | src |
created_at | 2023-02-18 20:12:49.818553 |
updated_at | 2024-12-09 09:52:11.558856 |
description | a command executor with caching for data processing pipelines |
homepage | https://github.com/reu-dev/razel |
repository | https://github.com/reu-dev/razel |
max_upload_size | |
id | 788426 |
Cargo.toml error: | TOML parse error at line 19, column 1 | 19 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include` |
size | 0 |
A command executor with caching. It is:
Razel is not the best choice for building software, especially there's no built-in support for compiler setup and header dependencies.
The native input format for Razel is a razel.jsonl
file, see the example examples/razel.jsonl.
It can be run with razel exec -f examples/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.
Paths of inputs files are relative to the workspace (directory of razel.jsonl
). Output files are created
in <cwd>/razel-out
. Additional metadata is written to <cwd>/razel-out/razel-metadata
.
Install Deno to use the TypeScript API. Run the example Deno script:
deno run -A --check examples/deno.ts -- -v
The Python API requires Python >= 3.8. Install the package and run the example Python script:
pip install --upgrade razel
python examples/python.py -v
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 examples/batch.sh with Razel:
razel exec -f examples/batch.sh
The workspace directory can be mounted into a container:
podman run -t -v $PWD:$PWD -w $PWD denoland/deno deno run -A examples/deno.ts
Use rustup to install Rust. Install protobuf-compiler
. Then run cargo install --locked razel
.
Razel is in active development and used in production.
CLI and format of razel.jsonl
will likely change, same for output in razel-out/razel-metadata
.
While Linux is the main development platform, Razel is also tested on Mac and Windows.
Razel parses the stdout of executed commands to capture runtime measurements and writes them
to razel-out/razel-metadata/log.json
and 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 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 succeededrazel:verbose
: always show verbose outputrazel:condition
: keep running and don't be verbose if command failedrazel:timeout:<seconds>
: kill command after the specified number of secondsrazel:no-cache
: always execute a command without cachingrazel:no-remote-cache
: don't use remote cacherazel:no-sandbox
: disable sandbox and also cache - for commands with unspecified input/output filesCommands can be skipped based on the execution result of another command. Set the razel:condition
tag on a command
and use that one as dependency for other commands.
Razel has a WebAssembly runtime integrated and can directly execute WASM modules using WebAssembly System Interface (WASI).
WebAssembly is a perfect fit to create portable data processing pipelines with Razel. Just a single WebAssembly module is needed to run - and create bit-exact output - on all platforms. WebAssembly execution is slower than native binaries, but startup time might be faster (no process overhead).
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 @.
If a process is killed by the OS, the command and similar ones will be retried with less concurrency to reduce the total memory usage. (Doesn't work in K8s because the whole pod is killed.)
Commands are executed in a temporary directory which contains symlinks to the input files specific to one command. This allows detecting unspecified dependencies which would break caching.
The sandbox is not meant for executing untrusted code.
The local cache is enabled by default and stores information about previously executed commands and output files.
The output directory razel-out
contains symlinks to files stored in the local cache.
Use razel exec --info
to get the default cache directory and --cache-dir
(env: RAZEL_CACHE_DIR
) to move it.
Razel supports remote caching compatible to Bazel Remote Execution API. Remote execution is not yet implemented.
Use --remote-cache
(env: RAZEL_REMOTE_CACHE
) to specify a comma seperated list of remote cache URLs.
The first available one will be used.
Optionally --remote-cache-threshold
(REMOTE_CACHE_THRESHOLD
) can be set to only cache commands with
outputSize / execTime < threshold [kilobyte / s]
. If your remote cache doesn't have unlimited storage capacity,
this can drastically speed up execution because quick commands with large output files will no longer be cached,
providing more storage for expensive commands.
The following remote cache implementations are tested with Razel:
podman run -p 9092:9092 buchgr/bazel-remote-cache --max_size 10
RAZEL_REMOTE_CACHE=grpc://localhost:9092
main
on port 50051:
mkdir -p nativelink-config
curl https://raw.githubusercontent.com/TraceMachina/nativelink/main/nativelink-config/examples/basic_cas.json --output nativelink-config/basic_cas.json
podman run -p 50051:50051 -v $PWD/nativelink-config:/nativelink-config:ro ghcr.io/tracemachina/nativelink:v0.2.0 /nativelink-config/basic_cas.json
RAZEL_REMOTE_CACHE=grpc://localhost:50051/main
Use razel exec -h
to list the configuration options for execution.
Some options can also be set as environment variables and those are loaded from .env
files.
The following sources are used in order, overwriting previous values:
.env
file in current directory or its parents.env.local
file in current directory or its parentsThe idea to build fast and correct is based on Bazel.