Do not print empty evaluation result tables (#12427)
This commit is contained in:
parent
d418cf23b2
commit
45400be921
|
@ -175,6 +175,9 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
|
|||
- Implemented a new native and rich format in `_print_results` method of the `EvaluationLoop` ([#11332](https://github.com/PyTorchLightning/pytorch-lightning/pull/11332))
|
||||
|
||||
|
||||
- Do not print an empty table at the end of the `EvaluationLoop` ([#12427](https://github.com/PyTorchLightning/pytorch-lightning/pull/12427))
|
||||
|
||||
|
||||
- Set the `prog_bar` flag to False in `LightningModule.log_grad_norm` ([#11472](https://github.com/PyTorchLightning/pytorch-lightning/pull/11472))
|
||||
|
||||
|
||||
|
|
|
@ -325,6 +325,8 @@ class EvaluationLoop(DataLoaderLoop):
|
|||
# remove the dl idx suffix
|
||||
results = [{k.split("/dataloader_idx_")[0]: v for k, v in result.items()} for result in results]
|
||||
metrics = sorted({k for keys in apply_to_collection(results, dict, EvaluationLoop._get_keys) for k in keys})
|
||||
if not metrics:
|
||||
return
|
||||
headers = [f"DataLoader {i}" for i in range(len(results))]
|
||||
|
||||
# fallback is useful for testing of printed output
|
||||
|
|
|
@ -838,6 +838,9 @@ expected3 = """
|
|||
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
|
||||
"""
|
||||
|
||||
inputs4 = ([{}], "foo")
|
||||
expected4 = ""
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
["inputs", "expected"],
|
||||
|
@ -846,6 +849,7 @@ expected3 = """
|
|||
pytest.param(inputs1, expected1, id="case1"),
|
||||
pytest.param(inputs2, expected2, id="case2"),
|
||||
pytest.param(inputs3, expected3, id="case3"),
|
||||
pytest.param(inputs4, expected4, id="empty case"),
|
||||
],
|
||||
)
|
||||
def test_native_print_results(monkeypatch, inputs, expected):
|
||||
|
@ -916,6 +920,7 @@ expected3 = """
|
|||
pytest.param(inputs1, expected1, id="case1"),
|
||||
pytest.param(inputs2, expected2, id="case2"),
|
||||
pytest.param(inputs3, expected3, id="case3"),
|
||||
pytest.param(inputs4, expected4, id="empty case"),
|
||||
],
|
||||
)
|
||||
@RunIf(rich=True, skip_windows=True)
|
||||
|
|
Loading…
Reference in New Issue