Add Bazel targets for on-demand schemas and Python SDK generation (#54096)

## What changed

- Add `//bazel/schema:app-server` to generate stable and experimental schemas from Rust sources without depending on committed precomputed bundles.
- Add `//sdk/python:generated` to generate Python SDK models, the notification registry, and API methods from the stable schema in scratch space, using dependencies from `uv.lock`.
- Add `generate-types --no-format` to skip formatters for build outputs while preserving formatting by default.

## Testing

Extend contract generation tests to regenerate in a temporary SDK copy, checking byte equality for formatted output and AST equality for unformatted output.

GitOrigin-RevId: 9ca7daa8ac0a33c4106a9e95c2f48bbded07df21
This commit is contained in:
Dmitriy Kovalenko
2026-10-14 20:59:31 +00:00
committed by copyberry
parent 12fd621f62
commit bc13ff239c
9 changed files with 298 additions and 27 deletions
+51
View File
@@ -0,0 +1,51 @@
"""Generate SDK build outputs in scratch space without formatting."""
import json
import os
import shutil
import subprocess
import sys
import tempfile
from pathlib import Path
def main() -> None:
files = json.loads(Path(sys.argv[1]).read_text())
schema = Path(sys.argv[2]).resolve()
output = Path(sys.argv[3]).resolve()
with tempfile.TemporaryDirectory() as temporary:
sdk = Path(temporary) / "sdk/python"
for source, relative in files:
destination = sdk / relative
destination.parent.mkdir(parents=True, exist_ok=True)
shutil.copyfile(source, destination)
environment = {
**os.environ,
"PYTHONPATH": os.pathsep.join(sys.path),
}
subprocess.run(
[
sys.executable,
str(sdk / "scripts/update_sdk_artifacts.py"),
"generate-types",
"--no-format",
"--schema-dir",
str(schema),
],
cwd=sdk,
env=environment,
check=True,
)
for relative in (
"src/openai_codex/api.py",
"src/openai_codex/generated/v2_all.py",
"src/openai_codex/generated/notification_registry.py",
):
destination = output / relative
destination.parent.mkdir(parents=True, exist_ok=True)
shutil.copyfile(sdk / relative, destination)
if __name__ == "__main__":
main()