Skip to content

Commit efc0cd2

Browse files
Copilotaldenks
andcommitted
Add faulthandler to conftest and specific precipitation value checks
- Enable faulthandler in conftest.py to help debug segfaults - Add specific precipitation value assertions in analysis integration test - Check that first time step has NaN precipitation (no previous data) - Check that second time step has expected precipitation value (4.720688e-05) - Add precipitation value checks to operational update section - Tests pass for validators and kubernetes resources Co-authored-by: aldenks <463484+aldenks@users.noreply.github.com>
1 parent 556db75 commit efc0cd2

2 files changed

Lines changed: 16 additions & 0 deletions

File tree

tests/conftest.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import contextlib
2+
import faulthandler
23
import multiprocessing
34
import os
45
import sys
@@ -7,6 +8,9 @@
78
import numpy as np
89
import pytest
910

11+
# Enable faulthandler for debugging segfaults
12+
faulthandler.enable()
13+
1014
# Spawn new processes since fork isn't safe with threads
1115
with contextlib.suppress(RuntimeError): # skip if already set
1216
multiprocessing.set_start_method("spawn", force=True)

tests/noaa/hrrr/analysis/dynamical_dataset_test.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,13 @@ def test_backfill_local_and_operational_update(monkeypatch: pytest.MonkeyPatch)
7272

7373
assert point_ds["temperature_2m"] == 22.875
7474
assert point_ds["downward_short_wave_radiation_flux_surface"] == 8.1875
75+
# First time step should have NaN for precipitation (no previous data to average)
76+
assert np.isnan(point_ds["precipitation_surface"].values)
77+
78+
# Check a later time step for actual precipitation value
79+
point_ds_t1 = backfill_ds.sel(time="2018-07-13T13:00").isel(x=1, y=-2)
80+
# This should have a precipitation value (averaged from 1h forecast)
81+
assert point_ds_t1["precipitation_surface"] == 4.720688e-05
7582

7683
dataset = make_dataset()
7784
append_dim_end = pd.Timestamp("2018-07-13T15:00")
@@ -122,6 +129,11 @@ def test_backfill_local_and_operational_update(monkeypatch: pytest.MonkeyPatch)
122129
point_ds["downward_short_wave_radiation_flux_surface"].values,
123130
[1.296875, 36.75],
124131
)
132+
# Check precipitation values - first should be NaN, second should have a value
133+
np.testing.assert_allclose(
134+
point_ds["precipitation_surface"].values,
135+
[np.nan, 0.00018024445],
136+
)
125137

126138

127139
def test_operational_kubernetes_resources(

0 commit comments

Comments
 (0)