Skip to content

Commit b75dcb7

Browse files
committed
Add test
1 parent 08a0a26 commit b75dcb7

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

tests/test_particlefile.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -467,6 +467,23 @@ def test_pfile_write_custom_particle():
467467
...
468468

469469

470+
def test_particlefile_readable_after_kernel_error(fieldset, tmp_parquet):
471+
"""Parquet output file must be readable even if the kernel raises an error mid-execution (GH-2713)."""
472+
473+
def ErrorKernel(particles, fieldset): # pragma: no cover
474+
particles.state = StatusCode.Error
475+
476+
pset = ParticleSet(fieldset, pclass=Particle, x=0, y=0)
477+
ofile = ParticleFile(tmp_parquet, outputdt=np.timedelta64(1, "s"))
478+
479+
with pytest.raises(RuntimeError, match="General error occurred at"):
480+
pset.execute(ErrorKernel, runtime=np.timedelta64(10, "s"), dt=np.timedelta64(1, "s"), output_file=ofile)
481+
482+
# File must be readable despite the crash
483+
df = pd.read_parquet(tmp_parquet)
484+
assert len(df) >= 1 # at least the initial condition was written
485+
486+
470487
@pytest.mark.xfail(
471488
reason="set_variable_write_status should be removed - with Particle writing defined on the particle level. GH2186"
472489
)

0 commit comments

Comments
 (0)