Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 11 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1902,21 +1902,19 @@ poe test -s --log-cli-level=DEBUG -k test_sync_activity_thread_cancel_caught

#### Proto Generation and Testing

To allow for backwards compatibility, protobuf code is generated on the 3.x series of the protobuf library. To generate
protobuf code, you must be on Python <= 3.10, and then run `uv add "protobuf<4"` + `uv sync --all-extras`. Then the
protobuf files can be generated via `poe gen-protos`. Tests can be run for protobuf version 3 by setting the
`TEMPORAL_TEST_PROTO3` env var to `1` prior to running tests.

Do not commit `uv.lock` or `pyproject.toml` changes. To go back from this downgrade, restore both of those files and run
`uv sync --all-extras`. Make sure you `poe format` the results.

For a less system-intrusive approach, you can:
```shell
docker build -f scripts/_proto/Dockerfile .
docker run --rm -v "${PWD}/temporalio/api:/api_new" -v "${PWD}/temporalio/bridge/proto:/bridge_new" <just built image sha>
poe format
If you have docker available, run

```
poe gen-protos-docker
```

Alternatively: to generate protobuf code, you must be on Python <= 3.10, and then run `uv add
"protobuf<4"` + `uv sync --all-extras`. Then the protobuf files can be generated via `poe
gen-protos` followed by `poe format`. Do not commit `uv.lock` or `pyproject.toml` changes. To go
back from this downgrade, restore both of those files and run `uv sync --all-extras`. Tests can be
run for protobuf version 3 by setting the `TEMPORAL_TEST_PROTO3` env var to `1` prior to running
tests.

### Style

* Mostly [Google Style Guide](https://google.github.io/styleguide/pyguide.html). Notable exceptions:
Expand Down
5 changes: 3 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,9 @@ dev = [
build-develop = "uv run maturin develop --uv"
build-develop-with-release = { cmd = "uv run maturin develop --release --uv" }
format = [{cmd = "uv run ruff check --select I --fix"}, {cmd = "uv run ruff format"}, ]
gen-docs = "uv run python scripts/gen_docs.py"
gen-protos = "uv run python scripts/gen_protos.py"
gen-docs = "uv run scripts/gen_docs.py"
gen-protos = "uv run scripts/gen_protos.py"
gen-protos-docker = "uv run scripts/gen_protos_docker.py"
lint = [
{cmd = "uv run ruff check --select I"},
{cmd = "uv run ruff format --check"},
Expand Down
2 changes: 1 addition & 1 deletion scripts/_proto/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ RUN uv add "protobuf<4"
RUN uv sync --all-extras
RUN poe gen-protos

CMD cp -r ./temporalio/api/* /api_new && cp -r ./temporalio/bridge/proto/* /bridge_new
CMD ["sh", "-c", "cp -r ./temporalio/api/* /api_new && cp -r ./temporalio/bridge/proto/* /bridge_new"]
Copy link
Contributor Author

@dandavison dandavison Aug 20, 2025

Choose a reason for hiding this comment

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

Avoids warning:

     - JSONArgsRecommended: JSON arguments recommended for CMD to prevent
     unintended behavior related to OS signals (line 15)

26 changes: 26 additions & 0 deletions scripts/gen_protos_docker.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import os
import subprocess

# Build the Docker image and capture its ID
result = subprocess.run(
["docker", "build", "-q", "-f", "scripts/_proto/Dockerfile", "."],
capture_output=True,
text=True,
check=True,
)
image_id = result.stdout.strip()

subprocess.run(
[
"docker",
"run",
"--rm",
"-v",
f"{os.getcwd()}/temporalio/api:/api_new",
"-v",
f"{os.getcwd()}/temporalio/bridge/proto:/bridge_new",
image_id,
],
check=True,
)
subprocess.run(["uv", "run", "poe", "format"], check=True)
Loading