Skip to content

Commit 53df41d

Browse files
authored
Fix ast calls in wait.py for python 3.14 (#306)
* Fix ast calls in wait.py for python 3.14 * trigger workflow * changing github workflows * jacobi bool error and workflow change * test config change * exclude test * fix schedule cb test
1 parent a067434 commit 53df41d

5 files changed

Lines changed: 14 additions & 18 deletions

File tree

.github/workflows/charm4py.yml

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ jobs:
1313
runs-on: ${{ matrix.os }}
1414
strategy:
1515
matrix:
16-
python-version: ["3.8", "3.12"]
16+
python-version: ["3.10", "3.12", "3.14"]
1717
# macos-13 is x86_64, macos-14 is arm64
18-
os: [ubuntu-latest, macos-13, macos-14]
18+
os: [ubuntu-latest, macos-14, macos-15, macos-26]
1919
exclude:
20-
- os: ubuntu-latest # Python 3.8 not supported since ubuntu 24.04
21-
python-version: "3.8"
20+
- os: macos-26
21+
python-version: "3.14"
2222
fail-fast: false
2323

2424
steps:
@@ -32,17 +32,13 @@ jobs:
3232
- name: Install dependencies
3333
run: |
3434
pip install setuptools cython cffi greenlet numpy torch torchvision filelock matplotlib
35-
if [ ${{ matrix.os }} == 'macos-13' ]; then
36-
# pypi only distributes torch packages w/ numpy v1 for macos-x86_64
37-
pip install 'numpy<2'
38-
fi
3935
- name: Build Charm++/Charm4py
4036
run: |
4137
git clone https://github.com/charmplusplus/charm charm_src/charm
4238
export CHARM_EXTRA_BUILD_OPTS="--enable-error-checking"
4339
export CHARM_BUILD_PROCESSES=8
4440
export CHARM4PY_BUILD_CFFI=1
45-
python setup.py build_ext --inplace
41+
pip install -e .
4642
- name: Run auto_test.py
4743
run: |
4844
export PYTHONPATH="$PWD"

charm4py/wait.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -188,9 +188,7 @@ def is_tag_cond(root_ast):
188188
return None
189189

190190
idx = args.slice.value
191-
if isinstance(idx, ast.Num):
192-
idx = idx.n
193-
elif isinstance(idx, ast.Constant):
191+
if isinstance(idx, ast.Constant):
194192
idx = idx.value
195193

196194
if not isinstance(idx, int):
@@ -214,7 +212,7 @@ def visit_Attribute(self, node):
214212
return ast.copy_location(ast.Attribute(
215213
value=ast.Subscript(
216214
value=ast.Name(id='args', ctx=ast.Load()),
217-
slice=ast.Index(value=ast.Num(n=idx)),
215+
slice = ast.Constant(value=idx),
218216
ctx=node.ctx
219217
),
220218
attr=node.attr,
@@ -229,7 +227,7 @@ def visit_Name(self, node):
229227
self.num_msg_args += 1
230228
return ast.copy_location(ast.Subscript(
231229
value=ast.Name(id='args', ctx=ast.Load()),
232-
slice=ast.Index(value=ast.Num(n=idx)),
230+
slice = ast.Constant(value=idx),
233231
ctx=node.ctx
234232
), node)
235233
else:

docs/install.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Install
77
Charm4py runs on Linux, macOS, Windows, Raspberry Pi, and a wide variety of clusters and
88
supercomputer environments (including many supercomputers in the TOP500).
99

10-
Charm4py runs on Python 3.8+. Charm4py supports the CPython Python implementation.
10+
Charm4py runs on Python 3.9+. Charm4py supports the CPython Python implementation.
1111

1212
Installing Charm4Py binaries (via pip)
1313
---------------------------------------

examples/jacobi/jacobi2d.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ def run(self):
101101
max_error = check_and_compute(self.temperature, self.new_temperature,
102102
self.istart, self.ifinish, self.jstart, self.jfinish)
103103
self.temperature, self.new_temperature = self.new_temperature, self.temperature
104-
converged = self.allreduce(max_error <= THRESHOLD, Reducer.logical_and).get()
104+
converged = self.allreduce(bool(max_error <= THRESHOLD), Reducer.logical_and).get()
105105
iteration += 1
106106

107107
if self.thisIndex == (0, 0):

tests/callbacks/schedule_cb.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,11 @@ def start(self):
1414
charm.scheduleCallableAfter(self.thisProxy[self.thisIndex].next, 1, [-1])
1515

1616
def next(self, from_elem):
17-
print(self.thisIndex, 'time=', time() - self.t0, 'from=', from_elem)
17+
elapsed = time() - self.t0
18+
print(self.thisIndex, 'time=', elapsed, 'from=', from_elem)
1819
assert from_elem == self.thisIndex[0] - 1
19-
assert time() - self.t0 > self.thisIndex[0] + 0.9
20+
expected = self.thisIndex[0] + 1.0
21+
assert elapsed >= expected - 0.5, (self.thisIndex[0], elapsed, expected)
2022
if self.thisIndex[0] == NUM_CHARES - 1:
2123
print('DONE')
2224
exit()

0 commit comments

Comments
 (0)