Skip to content

Commit 3b8a5a5

Browse files
committed
Fix the bug.
1 parent 1ea2565 commit 3b8a5a5

2 files changed

Lines changed: 7 additions & 4 deletions

File tree

src/modelarrayio/storage/tiledb_storage.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,8 @@ def create_scalar_matrix_array(
176176
storage_np_dtype,
177177
tile_shape,
178178
)
179+
if tiledb.object_type(uri):
180+
tiledb.remove(uri)
179181
tiledb.Array.create(uri, schema)
180182

181183
logger.info('Writing full array %s to TileDB (this may take a while)...', uri)
@@ -265,6 +267,8 @@ def create_empty_scalar_matrix_array(
265267
storage_np_dtype,
266268
tile_shape,
267269
)
270+
if tiledb.object_type(uri):
271+
tiledb.remove(uri)
268272
tiledb.Array.create(uri, schema)
269273

270274
if sources_list is not None:

test/test_voxels_cli.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,6 @@ def test_nifti_tiledb_fails_when_output_already_exists(tmp_path, monkeypatch):
351351
assert out_tdb.exists()
352352
assert tiledb.object_type(str(out_tdb / 'scalars' / 'FA' / 'values')) is not None
353353

354-
# Second run to the same output directory should fail because the TileDB
355-
# arrays already exist (this is the bug reported in issue #39).
356-
with pytest.raises(tiledb.TileDBError, match='already exists'):
357-
modelarrayio_main(cli_args)
354+
# Second run to the same output directory should succeed now that existing
355+
# arrays are removed before re-creation (regression for issue #39).
356+
assert modelarrayio_main(cli_args) == 0

0 commit comments

Comments
 (0)