Skip to content

Protocompiled files - #282

Open
mihncalo wants to merge 2 commits into
mlcommons:mainfrom
Keysight:build/issue-271-protocompiled-files
Open

mihncalo wants to merge 2 commits into
mlcommons:mainfrom
Keysight:build/issue-271-protocompiled-files

Conversation

@mihncalo

Copy link
Copy Markdown
Contributor

Summary

The generated protobuf code (*_pb2.py, *_pb2.pyi) is now committed, so installing no longer runs protoc.

Problem:

  • Every source install ran protoc through grpcio-tools==1.80.0. That package has no Python 3.15 wheel, so 3.15 installs failed.
  • Test the clean install on Python 3.14 and cap requires-python below 3.15 #269 worked around this by capping requires-python <3.15.
  • grpcio-tools 1.84.0 has a 3.15 wheel, but its generated code needs protobuf>=7.35.1, which would drop protobuf 6.x users.
  • The build also shipped unused *_pb2_grpc.py modules. They import grpc, which is not a dependency.

Changes:

  • Generated code committed. The files are byte-identical to what pip install . produces on main. .gitignore now ignores only *_pb2_grpc.py.
  • Build machinery removed:
    • grpcio-tools and setuptools-grpc are gone from [build-system].
    • setup.cfg is deleted. Its only section was [build_grpc].
    • The uv cache-keys block is gone.
    • requires-python has no upper bound any more.
  • Packaging: the .pyi stubs are listed in package-data. setuptools before 69 leaves them out otherwise.
  • Lint: ruff and pyright now skip the generated files.
  • New scripts/gen_proto.sh:
    • It installs grpcio-tools with pip into a throwaway venv, from wheels only, so contributors who use only pip can run it.
    • It runs protoc with --proto_path=schema/protobuf.
    • --check compares against the committed files and writes nothing.
  • CI:
    • New drift-check step in python_tests.yml.
    • Python 3.15 added to the clean-install matrix.
    • The clean install now builds the sdist, then the wheel from it.
    • The packaging checks assert the .pyi stubs are present and no *_pb2_grpc.py is shipped.
  • just: new gen-proto and proto-check recipes. proto-check is part of gate.
  • Tests: new guard tests, plus a slow test showing the drift check catches a .proto change that wasn't regenerated.
  • Docs: doc/DEVELOPMENT.md covers the new steps.

The import path chakra.schema.protobuf.et_def_pb2 is unchanged.

Test Plan

Environment:

  • Python 3.11 and Python 3.15.2.
  • Lint and type checks used only the dev tools from requirements-dev.txt, as CI does.

Results:

  • Byte identity: each committed file is identical to main's built wheel (checked with cmp, all 4 files).
  • Drift check: just proto-check reports the files are up to date. After a .proto edit without regenerating, it reports "out of date" and exits with 1.
  • Lint and types: ruff format --check ., ruff check ., vulture, shellcheck and pyright are clean, with 0 errors.
  • Tests: CHAKRA_TOOLING_TESTS=1 CHAKRA_TEST_SLOW=1 python -m pytest tests gives 383 passed. The pipeline output tests pass, so the .et output is unchanged.
  • Wheel: scripts/wheel_check.sh passes with protobuf 6.31.1 and with the newest protobuf.
  • Clean install: scripts/check_clean_install.sh passes on Python 3.11 and 3.15.2, building from the sdist.
  • Original failure: grpcio-tools 1.80.0 has no wheel for Python 3.15, which reproduces the problem.

Additional Notes

  • After a .proto change: run just gen-proto (or scripts/gen_proto.sh) and commit the result. It needs a network and Python 3.9 to 3.14.
  • Bumping grpcio-tools (rare, maintainers only): a newer grpcio-tools generates code that needs a newer protobuf. Update the pin in gen_proto.sh, regenerate, and raise the protobuf lower bound in pyproject.toml. If you forget, the proto smoke test fails in CI.

Closes #271

@mlcommons-cla-bot

Copy link
Copy Markdown

MLCommons CLA bot: All contributors are covered by the MLCommons CLA ✍️ ✅

Comment thread schema/protobuf/et_def_pb2.py Resolved
Comment thread schema/protobuf/storage_pb2.py Resolved

@danmih-ixia danmih-ixia left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add proper descriptive commit messages.

@mihncalo
mihncalo force-pushed the build/issue-271-protocompiled-files branch from db42ee8 to 5edd069 Compare November 24, 2026 20:14
@mihncalo
mihncalo requested a review from danmih-ixia November 24, 2026 20:17
@mihncalo

Copy link
Copy Markdown
Contributor Author

Please add proper descriptive commit messages.

Addressed the issue by changing the name of the first commit to something indicative of the changes done in said commit

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Discussion on protocompiled files

3 participants