Skip to content

Commit 675ace8

Browse files
committed
correct logic for saving datadisplays, stop running lc2st plots on local
1 parent a32b1c4 commit 675ace8

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

.github/workflows/test.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@ jobs:
1616
- run: poetry install --with dev
1717

1818
- name: Test with pytest
19-
run: poetry run pytest --cov=src/
19+
run: poetry run pytest

src/deepdiagnostics/plots/plot.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,8 @@ def _finish(self, data_display: Optional["data_display"] = None) -> None:
132132
with File(f"{self.out_dir.rstrip('/')}/{self.run_id}_diagnostic_metrics.h5", "w") as f:
133133

134134
for key, value in data_display.items():
135-
f.create_dataset(f"{self.plot_name}/{key}", data=value)
135+
if value is not None:
136+
f.create_dataset(f"{self.plot_name}/{key}", data=value)
136137

137138
f.close()
138139

tests/test_plots.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ def test_plot_tarp(plot_config, mock_model, mock_data, mock_run_id):
5050
plot(**get_item("plots", "TARP", raise_exception=False))
5151
assert os.path.exists(f"{plot.out_dir}/{mock_run_id}_{plot.plot_name}")
5252

53+
IN_GITHUB_ACTIONS = os.getenv("GITHUB_ACTIONS") == "true"
54+
@pytest.mark.skipif(not IN_GITHUB_ACTIONS, reason="L2CST Test is very slow, should only be run on remote.")
5355
def test_lc2st(plot_config, mock_model, mock_data, mock_2d_data, result_output, mock_run_id):
5456
Config(plot_config)
5557
plot = LC2ST(mock_model, mock_data, mock_run_id, save=True, show=False)
@@ -61,7 +63,7 @@ def test_lc2st(plot_config, mock_model, mock_data, mock_2d_data, result_output,
6163
out_dir=f"{result_output.strip('/')}/mock_2d/")
6264
assert type(plot.data.simulator).__name__ == "Mock2DSimulator"
6365
plot(**get_item("plots", "LC2ST", raise_exception=False))
64-
assert os.path.exists(f"{plot.out_dir}/{plot.plot_name}")
66+
assert os.path.exists(f"{plot.out_dir}/{mock_run_id}_{plot.plot_name}")
6567

6668
def test_ppc(plot_config, mock_model, mock_data, mock_2d_data, result_output, mock_run_id):
6769
Config(plot_config)
@@ -115,7 +117,7 @@ def test_parity(plot_config, mock_model, mock_data, mock_run_id):
115117
assert os.path.exists(f"{plot.out_dir}/{mock_run_id}_{plot.plot_name}")
116118

117119

118-
@pytest.mark.parametrize("plot_type", [CDFRanks, Ranks, CoverageFraction, TARP, LC2ST, PPC, PriorPC, Parity])
120+
@pytest.mark.parametrize("plot_type", [CDFRanks, Ranks, CoverageFraction, TARP, PPC, PriorPC, Parity])
119121
def test_rerun_plot(plot_type, plot_config, mock_model, mock_data, mock_run_id):
120122

121123
Config(plot_config)

0 commit comments

Comments
 (0)