Skip to content

Commit 2d7123b

Browse files
authored
Auto-generate protobuf and Connect RPC files via hatch build hook (#3631)
Remove checked-in generated protobuf and Connect RPC files, replacing them with automatic generation via a hatch build hook. This eliminates the need to manually regenerate and commit these files when .proto sources change. The custom build hook (hatch_build.py) runs during package installation and wheel builds, regenerating all *_pb2.py, *_pb2.pyi, and *_connect.py files from their .proto sources if the sources are newer than the outputs. This ensures generated files are always in sync with their sources without requiring manual steps or git commits. Updated .gitignore to exclude the generated files, and removed the manual dashboard build fixture from conftest.py since the build hook now handles all code generation automatically.
1 parent 4f49462 commit 2d7123b

34 files changed

+274
-6653
lines changed

.github/workflows/iris-unit-tests.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@ jobs:
3131
with:
3232
python-version: ${{ matrix.python-version }}
3333

34+
- name: Set up Node.js
35+
uses: actions/setup-node@v4
36+
with:
37+
node-version: "22"
38+
3439
- name: Install uv
3540
uses: astral-sh/setup-uv@v7
3641
with:
@@ -58,6 +63,11 @@ jobs:
5863
with:
5964
python-version: ${{ matrix.python-version }}
6065

66+
- name: Set up Node.js
67+
uses: actions/setup-node@v4
68+
with:
69+
node-version: "22"
70+
6171
- name: Install uv
6272
uses: astral-sh/setup-uv@v7
6373
with:

.github/workflows/levanter-tests.yaml

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ jobs:
3030
python-version: ${{ matrix.python-version }}
3131
enable-cache: true
3232
working-directory: lib/levanter
33+
- name: Set up Node.js
34+
uses: actions/setup-node@v4
35+
with:
36+
node-version: "22"
3337
- name: Set up Python
3438
run: uv python install
3539
- name: Install dependencies
@@ -57,6 +61,10 @@ jobs:
5761
python-version: ${{ matrix.python-version }}
5862
enable-cache: true
5963
working-directory: lib/levanter
64+
- name: Set up Node.js
65+
uses: actions/setup-node@v4
66+
with:
67+
node-version: "22"
6068
- name: Set up Python
6169
run: uv python install
6270
- name: Install dependencies
@@ -83,6 +91,10 @@ jobs:
8391
python-version: ${{ matrix.python-version }}
8492
enable-cache: true
8593
working-directory: lib/levanter
94+
- name: Set up Node.js
95+
uses: actions/setup-node@v4
96+
with:
97+
node-version: "22"
8698
- name: Set up Python
8799
run: uv python install
88100
- name: Install dependencies
@@ -110,6 +122,10 @@ jobs:
110122
python-version: ${{ matrix.python-version }}
111123
enable-cache: true
112124
working-directory: lib/levanter
125+
- name: Set up Node.js
126+
uses: actions/setup-node@v4
127+
with:
128+
node-version: "22"
113129
- name: Set up Python
114130
run: uv python install
115131
- name: Install dependencies
@@ -201,4 +217,22 @@ jobs:
201217
-v /tmp/uv-cache:/tmp/uv-cache:rw \
202218
-w /workspace \
203219
$DOCKER_IMAGE \
204-
bash -c "cp -a /workspace-src/. /workspace/ && cd /workspace && timeout --kill-after=5 --signal=TERM 890 uv run --package levanter --frozen --group test --with 'jax[tpu]==$JAX_VERSION' pytest lib/levanter/tests -m 'not entry and not ray and not slow and not torch' --ignore=lib/levanter/tests/test_audio.py --ignore=lib/levanter/tests/test_new_cache.py --ignore=lib/levanter/tests/test_hf_checkpoints.py --ignore=lib/levanter/tests/test_hf_gpt2_serialize.py --ignore=lib/levanter/tests/test_gdn_layer.py -v --tb=short --log-cli-level=WARNING --durations=20"
220+
bash -c "\
221+
# Install Node.js in userspace if not present (needed for protobuf generation during uv sync)
222+
if ! command -v npx >/dev/null 2>&1; then \
223+
echo '::group::Installing Node.js in userspace'; \
224+
curl -fsSL https://nodejs.org/dist/v22.16.0/node-v22.16.0-linux-x64.tar.xz | tar -xJ -C /tmp && \
225+
export PATH=/tmp/node-v22.16.0-linux-x64/bin:\$PATH; \
226+
echo '::endgroup::'; \
227+
fi && \
228+
cp -a /workspace-src/. /workspace/ && cd /workspace && \
229+
timeout --kill-after=5 --signal=TERM 890 \
230+
uv run --package levanter --frozen --group test --with 'jax[tpu]==$JAX_VERSION' \
231+
pytest lib/levanter/tests \
232+
-m 'not entry and not ray and not slow and not torch' \
233+
--ignore=lib/levanter/tests/test_audio.py \
234+
--ignore=lib/levanter/tests/test_new_cache.py \
235+
--ignore=lib/levanter/tests/test_hf_checkpoints.py \
236+
--ignore=lib/levanter/tests/test_hf_gpt2_serialize.py \
237+
--ignore=lib/levanter/tests/test_gdn_layer.py \
238+
-v --tb=short --log-cli-level=WARNING --durations=20"

.github/workflows/marin-docs.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ jobs:
2424
python-version: "3.11"
2525
enable-cache: true
2626

27+
- name: Set up Node.js
28+
uses: actions/setup-node@v4
29+
with:
30+
node-version: "22"
31+
2732
- name: Set up Python
2833
run: uv python install
2934

.github/workflows/marin-itest.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@ jobs:
3131
with:
3232
python-version: ${{ matrix.python-version }}
3333

34+
- name: Set up Node.js
35+
uses: actions/setup-node@v4
36+
with:
37+
node-version: "22"
38+
3439
- name: Install uv
3540
uses: astral-sh/setup-uv@v7
3641
with:

.github/workflows/marin-lint-and-format.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,10 @@ jobs:
2424
python-version: "3.11"
2525
enable-cache: true
2626

27+
- name: Set up Node.js
28+
uses: actions/setup-node@v4
29+
with:
30+
node-version: '22'
31+
2732
- name: Run pre-commit checks
2833
run: ./infra/pre-commit.py --all-files

.github/workflows/marin-unit-tests.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ jobs:
3939
uv sync --package marin --extra cpu --extra dedup --group test --frozen
4040
4141
- name: Set up Node.js ${{ matrix.node-version }}
42-
uses: actions/setup-node@v3
42+
uses: actions/setup-node@v4
4343
with:
4444
node-version: ${{ matrix.node-version }}
4545

.github/workflows/zephyr-unit-tests.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@ jobs:
3131
with:
3232
python-version: ${{ matrix.python-version }}
3333

34+
- name: Set up Node.js
35+
uses: actions/setup-node@v4
36+
with:
37+
node-version: "22"
38+
3439
- name: Install uv
3540
uses: astral-sh/setup-uv@v6
3641
with:

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,3 +234,8 @@ scr/*
234234
.agents/tmp/
235235
.codex
236236
.entire
237+
238+
# Generated protobuf and Connect RPC files (rebuilt by hatch build hook)
239+
lib/iris/src/iris/rpc/*_pb2.py
240+
lib/iris/src/iris/rpc/*_pb2.pyi
241+
lib/iris/src/iris/rpc/*_connect.py

.readthedocs.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ build:
44
os: "ubuntu-24.04"
55
tools:
66
python: "3.11"
7+
nodejs: "22"
78
commands:
89
- pip install uv
910
- uv sync --group docs --package marin

Makefile

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,5 +205,20 @@ setup_pre_commit:
205205
chmod +x $$HOOK_PATH; \
206206
echo "Installed git pre-commit hook -> $$HOOK_PATH"
207207

208-
dev_setup: install_uv install_gcloud get_secret_key get_ray_auth_token setup_pre_commit
208+
install_node:
209+
@if command -v node > /dev/null 2>&1; then \
210+
echo "Node.js $$(node --version) is already installed."; \
211+
elif command -v brew > /dev/null 2>&1; then \
212+
echo "Installing Node.js via Homebrew..."; \
213+
brew install node; \
214+
elif command -v apt-get > /dev/null 2>&1; then \
215+
echo "Installing Node.js via apt..."; \
216+
curl -fsSL https://deb.nodesource.com/setup_22.x | sudo -E bash - && \
217+
sudo apt-get install -y nodejs; \
218+
else \
219+
echo "Cannot auto-install Node.js. Please install manually: https://nodejs.org/"; \
220+
exit 1; \
221+
fi
222+
223+
dev_setup: install_uv install_gcloud install_node get_secret_key get_ray_auth_token setup_pre_commit
209224
@echo "Dev setup complete."

0 commit comments

Comments
 (0)