Skip to content

Commit 367ef7d

Browse files
laramielcopybara-github
authored andcommitted
Avoid exceptions in concurrent tests
PiperOrigin-RevId: 834622310 Change-Id: Ibadc7f6dd1a8e135a7764a6d3667352b22fa24ec
1 parent 8dd5fd9 commit 367ef7d

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

python/tensorstore/tests/chunk_layout_test.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ def _run_threads(
176176

177177
def test_chunk_layout_concurrent() -> None:
178178
"""Tests concurrent access to ChunkLayout properties."""
179-
layout = ts.ChunkLayout(rank=2)
179+
layout = ts.ChunkLayout(chunk_shape=[10, 20], rank=2)
180180
stop = threading.Event()
181181

182182
def read_props() -> None:
@@ -195,17 +195,17 @@ def update_props() -> None:
195195
i = 0
196196
while not stop.is_set():
197197
if (i % 2) == 0:
198-
layout.update(inner_order=[0, 1], chunk_shape=[10, 20])
198+
layout.update(chunk_shape=[10, 20])
199199
else:
200-
layout.update(inner_order=[1, 0], chunk_shape=[None, None])
200+
layout.update(rank=2)
201201
i += 1
202202

203203
_run_threads(stop, read_props, update_props)
204204

205205

206206
def test_grid_concurrent() -> None:
207207
"""Tests concurrent access to ChunkLayout.Grid properties."""
208-
grid = ts.ChunkLayout.Grid(rank=2)
208+
grid = ts.ChunkLayout.Grid(shape=[10, 10])
209209
stop = threading.Event()
210210

211211
def read_props() -> None:
@@ -223,9 +223,9 @@ def update_props() -> None:
223223
i = 0
224224
while not stop.is_set():
225225
if (i % 2) == 0:
226-
grid.update(shape=[1, 2], elements=10)
226+
grid.update(shape=[10, 10])
227227
else:
228-
grid.update(shape=[None, None], elements=None)
228+
grid.update(rank=2, elements=100)
229229
i += 1
230230

231231
_run_threads(stop, read_props, update_props)

python/tensorstore/tests/spec_test.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ def test_spec_concurrent_update_and_read() -> None:
164164
s = ts.Spec({
165165
"driver": "zarr",
166166
"kvstore": {"driver": "memory"},
167-
"transform": {"input_rank": 2},
167+
"schema": {"rank": 2, "dtype": "uint32"},
168168
})
169169

170170
stop = threading.Event()
@@ -188,23 +188,23 @@ def read_props() -> None:
188188
_ = s.vindex[0]
189189
_ = s.T
190190
_ = s.transpose([1, 0])
191-
_ = s.translate_to[1]
191+
_ = s.translate_by[1]
192192

193193
def update_props() -> None:
194194
i = 0
195195
while not stop.is_set():
196196
if (i % 2) == 0:
197-
s.update(dtype=ts.uint32, shape=[10, 20])
197+
s.update(shape=[10, 20], recheck_cached=False)
198198
else:
199-
s.update(dtype=ts.int32, shape=[30, 40])
199+
s.update(shape=[10, 20], recheck_cached=True)
200200
i += 1
201201

202202
_run_threads(stop, read_props, update_props)
203203

204204

205205
def test_schema_concurrent_update_and_read() -> None:
206206
"""Validates that concurrent updates and reads do not crash."""
207-
s = ts.Schema(dtype=ts.int32, fill_value=42, rank=2)
207+
s = ts.Schema(dtype=ts.int32, fill_value=42, shape=[10, 20])
208208

209209
stop = threading.Event()
210210

@@ -227,15 +227,15 @@ def read_props() -> None:
227227
_ = s.vindex[0]
228228
_ = s.T
229229
_ = s.transpose([1, 0])
230-
_ = s.translate_to[1]
230+
_ = s.translate_by[1]
231231

232232
def update_props() -> None:
233233
i = 0
234234
while not stop.is_set():
235235
if (i % 2) == 0:
236-
s.update(dtype=ts.uint32, fill_value=10)
236+
s.update(fill_value=42)
237237
else:
238-
s.update(dtype=ts.int32, fill_value=20)
238+
s.update(shape=[10, 20])
239239
i += 1
240240

241241
_run_threads(stop, read_props, update_props)

0 commit comments

Comments
 (0)