Skip to content

Commit e16bbc3

Browse files
authored
ARM runner and Python 3.11 support (#172)
1 parent 5259f4c commit e16bbc3

File tree

8 files changed

+146
-152
lines changed

8 files changed

+146
-152
lines changed

.github/workflows/build-binaries.yml

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
name: Build Binaries
2+
on:
3+
push:
4+
branches:
5+
- main
6+
- "releases/*"
7+
8+
jobs:
9+
# Compile the binaries and upload artifacts
10+
compile-binaries:
11+
strategy:
12+
fail-fast: true
13+
matrix:
14+
include:
15+
- os: ubuntu-latest
16+
package-suffix: linux-amd64
17+
- os: macos-latest
18+
package-suffix: macos-amd64
19+
- os: windows-latest
20+
package-suffix: windows-amd64
21+
- os: ubuntu-arm
22+
package-suffix: linux-aarch64
23+
# Need the 8 CPU version that has 12GB of RAM, the 4 CPU version
24+
# only has 6 GB.
25+
runsOn: buildjet-8vcpu-ubuntu-2204-arm
26+
runs-on: ${{ matrix.runsOn || matrix.os }}
27+
steps:
28+
- uses: actions/checkout@v2
29+
with:
30+
submodules: recursive
31+
# actions/setup-python doesn't yet support ARM
32+
- if: ${{ !endsWith(matrix.os, '-arm') }}
33+
uses: actions/setup-python@v4
34+
with:
35+
python-version: "3.11"
36+
- if: ${{ matrix.os == 'ubuntu-arm' }}
37+
uses: deadsnakes/[email protected]
38+
with:
39+
python-version: "3.11"
40+
41+
# Install Rust locally for non-Linux (Linux uses an internal docker
42+
# command to build with cibuildwheel which uses rustup install defined
43+
# in pyproject.toml)
44+
- if: ${{ runner.os != 'Linux' }}
45+
uses: actions-rs/toolchain@v1
46+
with:
47+
toolchain: stable
48+
- if: ${{ runner.os != 'Linux' }}
49+
uses: Swatinem/rust-cache@v1
50+
with:
51+
working-directory: temporalio/bridge
52+
53+
# Prepare
54+
- run: python -m pip install --upgrade wheel poetry poethepoet
55+
- run: poetry install --no-root -E opentelemetry
56+
57+
# Add the source dist only for Linux x64 for now
58+
- if: ${{ matrix.package-suffix == 'linux-amd64' }}
59+
run: poetry build --format sdist
60+
61+
# Build and fix the wheel
62+
- run: poetry run cibuildwheel --output-dir dist
63+
- run: poe fix-wheel
64+
65+
# Simple test
66+
- run: poe test-dist-single
67+
68+
# Upload dist
69+
- uses: actions/upload-artifact@v2
70+
with:
71+
name: packages-${{ matrix.package-suffix }}
72+
path: dist

.github/workflows/ci.yml

Lines changed: 17 additions & 108 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: Continuous Integration
2-
on: # rebuild any PRs and main branch changes
2+
on:
33
pull_request:
44
push:
55
branches:
@@ -12,15 +12,16 @@ jobs:
1212
strategy:
1313
fail-fast: true
1414
matrix:
15-
# TODO(cretz): 3.10.8 is breaking Windows Rust build
16-
python: ["3.7", "3.10.7"]
17-
os: [ubuntu-latest, macos-latest, windows-latest]
15+
python: ["3.7", "3.11"]
16+
os: [ubuntu-latest, macos-latest, windows-latest, ubuntu-arm]
1817
include:
1918
- os: ubuntu-latest
20-
python: 3.10.7
19+
python: "3.11"
2120
docsTarget: true
2221
protoCheckTarget: true
23-
runs-on: ${{ matrix.os }}
22+
- os: ubuntu-arm
23+
runsOn: buildjet-4vcpu-ubuntu-2204-arm
24+
runs-on: ${{ matrix.runsOn || matrix.os }}
2425
steps:
2526
- name: Print build information
2627
run: "echo head_ref: ${{ github.head_ref }}, ref: ${{ github.ref }}, os: ${{ matrix.os }}, python: ${{ matrix.python }}"
@@ -33,15 +34,23 @@ jobs:
3334
- uses: Swatinem/rust-cache@v1
3435
with:
3536
working-directory: temporalio/bridge
36-
- uses: actions/setup-python@v4
37+
# actions/setup-python doesn't yet support ARM
38+
- if: ${{ !endsWith(matrix.os, '-arm') }}
39+
uses: actions/setup-python@v4
40+
with:
41+
python-version: ${{ matrix.python }}
42+
- if: ${{ matrix.os == 'ubuntu-arm' }}
43+
uses: deadsnakes/[email protected]
3744
with:
3845
python-version: ${{ matrix.python }}
3946
- run: python -m pip install --upgrade wheel poetry poethepoet
4047
- run: poetry install --no-root -E opentelemetry
4148
- run: poe lint
4249
- run: poe build-develop
4350
- run: poe test -s -o log_cli_level=DEBUG
44-
- run: poe test -s -o log_cli_level=DEBUG --workflow-environment time-skipping
51+
# Time skipping doesn't yet support ARM
52+
- if: ${{ !endsWith(matrix.os, '-arm') }}
53+
run: poe test -s -o log_cli_level=DEBUG --workflow-environment time-skipping
4554

4655
# Confirm protos are already generated properly
4756
- name: Check generated protos
@@ -58,103 +67,3 @@ jobs:
5867
- name: Deploy prod API docs
5968
if: ${{ github.ref == 'refs/heads/main' && matrix.docsTarget }}
6069
run: npx vercel deploy build/apidocs -t ${{ secrets.VERCEL_TOKEN }} --name python --scope temporal --prod --yes
61-
62-
# Compile the binaries and upload artifacts
63-
compile-binaries:
64-
strategy:
65-
fail-fast: true
66-
matrix:
67-
include:
68-
- os: ubuntu-latest
69-
package-suffix: linux-amd64
70-
ci-arch: auto
71-
- os: macos-latest
72-
package-suffix: macos-amd64
73-
ci-arch: auto
74-
# TODO(cretz): Disabling macOS arm because cibuildwheel is still
75-
# generating an x64 wheel name even for arm64
76-
#- os: macos-latest
77-
# package-suffix: macos-arm64
78-
# ci-arch: arm64
79-
rust-add-target: aarch64-apple-darwin
80-
- os: windows-latest
81-
package-suffix: windows-amd64
82-
ci-arch: auto
83-
runs-on: ${{ matrix.os }}
84-
steps:
85-
- uses: actions/checkout@v2
86-
with:
87-
submodules: recursive
88-
- uses: actions/setup-python@v4
89-
with:
90-
python-version: "3.10.7"
91-
92-
# Install Rust locally for non-Linux (Linux uses an internal docker
93-
# command to build with cibuildwheel which uses rustup install defined
94-
# in pyproject.toml)
95-
- if: ${{ runner.os != 'Linux' }}
96-
uses: actions-rs/toolchain@v1
97-
with:
98-
toolchain: stable
99-
target: ${{ matrix.rust-add-target }}
100-
- if: ${{ runner.os != 'Linux' }}
101-
uses: Swatinem/rust-cache@v1
102-
with:
103-
working-directory: temporalio/bridge
104-
105-
# Prepare
106-
- run: python -m pip install --upgrade wheel poetry poethepoet
107-
- run: poetry install --no-root -E opentelemetry
108-
109-
# Add the source dist only for Linux x64 for now
110-
- if: ${{ matrix.package-suffix == 'linux-amd64' }}
111-
run: poetry build --format sdist
112-
113-
# Build and fix the wheel
114-
- run: poetry run cibuildwheel --output-dir dist --arch ${{ matrix.ci-arch }}
115-
- run: poe fix-wheel
116-
117-
# Do test only for ci-arch auto (i.e. local machine)
118-
- if: ${{ matrix.ci-arch == 'auto' }}
119-
run: poe test-dist-single
120-
121-
# Upload dist
122-
- uses: actions/upload-artifact@v2
123-
with:
124-
name: packages-${{ matrix.package-suffix }}
125-
path: dist
126-
127-
# We separate out Linux aarch64 so we can choose not to run it during PR since
128-
# it is so slow in cibuildwheel (uses QEMU emulation). We can put this back in
129-
# the above matrix when Linux ARM runners are available.
130-
compile-binaries-linux-aarch64:
131-
# Skip compiling Linux aarch64 on PR
132-
if: ${{ github.event_name != 'pull_request' }}
133-
runs-on: ubuntu-latest
134-
steps:
135-
- uses: actions/checkout@v2
136-
with:
137-
submodules: recursive
138-
- uses: actions/setup-python@v4
139-
with:
140-
python-version: "3.10.7"
141-
142-
# Need QEMU for ARM build on Linux
143-
- uses: docker/setup-qemu-action@v1
144-
with:
145-
image: tonistiigi/binfmt:latest
146-
platforms: arm64
147-
148-
# Prepare
149-
- run: python -m pip install --upgrade wheel poetry poethepoet
150-
- run: poetry install --no-root -E opentelemetry
151-
152-
# Build and fix the wheel
153-
- run: poetry run cibuildwheel --output-dir dist --arch aarch64
154-
- run: poe fix-wheel
155-
156-
# Upload dist
157-
- uses: actions/upload-artifact@v2
158-
with:
159-
name: packages-linux-aarch64
160-
path: dist

poetry.lock

Lines changed: 6 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ typing-extensions = "^4.2.0"
3535

3636
[tool.poetry.dev-dependencies]
3737
black = "^22.3.0"
38-
cibuildwheel = "^2.7.0"
38+
cibuildwheel = "^2.11.0"
3939
grpcio-tools = "^1.48.0"
4040
isort = "^5.10.1"
4141
mypy = "^0.971"
@@ -110,11 +110,6 @@ build-verbosity = "1"
110110
before-all = "curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain stable -y && yum install -y openssl-devel"
111111
environment = { PATH = "$PATH:$HOME/.cargo/bin", CARGO_NET_GIT_FETCH_WITH_CLI = "true" }
112112

113-
[[tool.cibuildwheel.overrides]]
114-
# We need the aarch64 target for Rust
115-
before-all = "curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain stable --target aarch64-unknown-linux-gnu -y && yum install -y openssl-devel"
116-
select = "*_aarch64"
117-
118113
[tool.isort]
119114
profile = "black"
120115
skip_gitignore = true

temporalio/worker/workflow_instance.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1135,7 +1135,12 @@ def _next_seq(self, type: str) -> int:
11351135
self._curr_seqs[type] = seq
11361136
return seq
11371137

1138-
def _register_task(self, task: asyncio.Task, *, name: Optional[str]) -> None:
1138+
def _register_task(
1139+
self,
1140+
task: asyncio.Task,
1141+
*,
1142+
name: Optional[str],
1143+
) -> None:
11391144
# Name not supported on older Python versions
11401145
if sys.version_info >= (3, 8):
11411146
# Put the workflow info at the end of the task name
@@ -1324,8 +1329,13 @@ def create_task(
13241329
coro: Union[Awaitable[_T], Generator[Any, None, _T]],
13251330
*,
13261331
name: Optional[str] = None,
1332+
context: Optional[contextvars.Context] = None,
13271333
) -> asyncio.Task[_T]:
1328-
task = asyncio.Task(coro, loop=self)
1334+
# Context only supported on newer Python versions
1335+
if sys.version_info >= (3, 11):
1336+
task = asyncio.Task(coro, loop=self, context=context) # type: ignore
1337+
else:
1338+
task = asyncio.Task(coro, loop=self)
13291339
self._register_task(task, name=name)
13301340
return task
13311341

0 commit comments

Comments
 (0)