An example project for training a machine learning model with Bazel.
-
Either have Bazelisk installed or enter the nix flake from this repository.
-
Create a
user.bazelrcin this directory and paste the values from theQuickstartsection at https://app.nativelink.com into it:# user.bazelrc build --remote_cache=grpcs://TODO build --remote_header=x-nativelink-api-key=TODO build --bes_backend=grpcs://TODO build --bes_header=x-nativelink-api-key=TODO build --bes_results_url=https://app.nativelink.com/TODO build --remote_timeout=600 build --remote_executor=grpcs://TODO
Run a local invocation:
bazel run trainingNow run a remote invocation. The first time you do this it'll be slow (~15min) as the runner needs to spin up and fetch the various toolchains:
bazel test training --config=remote --test_output=allRun the above command a second time. Since the runner is now warm it'll immediately start the test (~5min).
The dependencies for this project are tracked in pyproject.toml and locked in
requirements_{linux±|macos}.lock via a Bazel-wrapped uv toolchain. To
regenerate the lockfiles:
# On linux
bazel run //:requirements_linux.update
# On macos
bazel run //:requirements_macos.updateOn darwin you might have to disable remote execution temporarily for this.
Use the flake if you develop on this code. Don't use local ruff installations as versions other than the one used in the flake might format code differently.
# Check lints
ruff check
# Format
ruff format