Skip to content

Commit 0f134e2

Browse files
authored
Add generated protos (#42)
1 parent 81e17c0 commit 0f134e2

File tree

190 files changed

+29491
-14
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

190 files changed

+29491
-14
lines changed

.github/workflows/ci.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ jobs:
1818
- os: ubuntu-latest
1919
python: 3.10
2020
docsTarget: true
21+
protoCheckTarget: true
2122
runs-on: ${{ matrix.os }}
2223
steps:
2324
- name: Print build information
@@ -41,6 +42,14 @@ jobs:
4142
- run: poe build-develop
4243
- run: poe test -s -o log_cli_level=DEBUG
4344

45+
# Confirm protos are already generated properly
46+
- name: Check generated protos
47+
if: ${{ matrix.protoCheckTarget }}
48+
run: |
49+
poe gen-protos
50+
poe format
51+
[[ -z $(git status --porcelain) ]] || (git status; echo "Protos changed"; exit 1)
52+
4453
# Do docs stuff (only on one host)
4554
- name: Build API docs
4655
if: ${{ matrix.docsTarget }}
@@ -91,7 +100,6 @@ jobs:
91100
go-version: "1.17"
92101
- run: python -m pip install --upgrade wheel poetry poethepoet
93102
- run: poetry install --no-root
94-
- run: poe gen-protos
95103
- run: poetry build
96104
- run: poe fix-wheel
97105
- run: poe test-dist-single

.gitignore

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@
22
__pycache__
33
/build
44
/dist
5-
temporalio/api/*
6-
!temporalio/api/__init__.py
7-
temporalio/bridge/proto/*
8-
!temporalio/bridge/proto/__init__.py
95
temporalio/bridge/target/
106
temporalio/bridge/temporal_sdk_bridge*
117
/tests/helpers/golangserver/golangserver

README.md

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -595,12 +595,6 @@ it):
595595
poetry install --no-root
596596
```
597597

598-
Now generate the protobuf code:
599-
600-
```bash
601-
poe gen-protos
602-
```
603-
604598
#### Build
605599

606600
Now perform the release build:
@@ -680,7 +674,6 @@ installing dependencies, and generating the protobuf code:
680674
git clone --recursive https://github.com/temporalio/sdk-python.git
681675
cd sdk-python
682676
poetry install --no-root
683-
poe gen-protos
684677
```
685678

686679
Now compile the Rust extension in develop mode which is quicker than release mode:

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ toml = "^0.10.2"
5151
twine = "^3.8.0"
5252

5353
[tool.poe.tasks]
54-
build-develop = ["gen-protos", "build-bridge-develop"]
54+
build-develop = ["build-bridge-develop"]
5555
build-bridge-develop = "python scripts/setup_bridge.py develop"
5656
fix-wheel = "python scripts/fix_wheel.py"
5757
format = [{cmd = "black ."}, {cmd = "isort ."}]

scripts/gen_protos.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,22 @@ def fix_generated_output(base_path: Path):
6868
f.write(content)
6969
# Write init
7070
with (base_path / "__init__.py").open("w") as f:
71+
# Add docstring to API's init
72+
if str(base_path.as_posix()).endswith("/temporal/api"):
73+
f.write('"""gRPC API."""\n')
7174
# Imports
7275
message_names = []
7376
for stem, messages in imports.items():
7477
for message in messages:
75-
f.write(f"from .{stem} import {message}\n")
78+
# MyPy protobuf does not document this experimental class, see
79+
# https://github.com/nipunn1313/mypy-protobuf/issues/212#issuecomment-885300106
80+
import_suffix = ""
81+
if stem == "service_pb2_grpc" and message == "WorkflowService":
82+
import_suffix = " # type: ignore"
83+
f.write(f"from .{stem} import {message}{import_suffix}\n")
7684
message_names.append(message)
7785
# __all__
86+
message_names = sorted(message_names)
7887
if message_names:
7988
f.write(
8089
f'\n__all__ = [\n "' + '",\n "'.join(message_names) + '",\n]\n'

temporalio/api/command/__init__.py

Whitespace-only changes.

temporalio/api/command/v1/__init__.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
from .message_pb2 import (
2+
CancelTimerCommandAttributes,
3+
CancelWorkflowExecutionCommandAttributes,
4+
Command,
5+
CompleteWorkflowExecutionCommandAttributes,
6+
ContinueAsNewWorkflowExecutionCommandAttributes,
7+
FailWorkflowExecutionCommandAttributes,
8+
RecordMarkerCommandAttributes,
9+
RequestCancelActivityTaskCommandAttributes,
10+
RequestCancelExternalWorkflowExecutionCommandAttributes,
11+
ScheduleActivityTaskCommandAttributes,
12+
SignalExternalWorkflowExecutionCommandAttributes,
13+
StartChildWorkflowExecutionCommandAttributes,
14+
StartTimerCommandAttributes,
15+
UpsertWorkflowSearchAttributesCommandAttributes,
16+
)
17+
18+
__all__ = [
19+
"CancelTimerCommandAttributes",
20+
"CancelWorkflowExecutionCommandAttributes",
21+
"Command",
22+
"CompleteWorkflowExecutionCommandAttributes",
23+
"ContinueAsNewWorkflowExecutionCommandAttributes",
24+
"FailWorkflowExecutionCommandAttributes",
25+
"RecordMarkerCommandAttributes",
26+
"RequestCancelActivityTaskCommandAttributes",
27+
"RequestCancelExternalWorkflowExecutionCommandAttributes",
28+
"ScheduleActivityTaskCommandAttributes",
29+
"SignalExternalWorkflowExecutionCommandAttributes",
30+
"StartChildWorkflowExecutionCommandAttributes",
31+
"StartTimerCommandAttributes",
32+
"UpsertWorkflowSearchAttributesCommandAttributes",
33+
]

0 commit comments

Comments
 (0)