Skip to content

Commit

Permalink
api: exp_show: Postprocess empty strings as None.
Browse files Browse the repository at this point in the history
Makes it easier to manipulate when converting to pandas DataFrame.
  • Loading branch information
daavoo committed May 8, 2023
1 parent 8620b6e commit 1ba3944
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
4 changes: 4 additions & 0 deletions dvc/api/experiments.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ def _postprocess(exp_rows):
exp_row[k] = float(v_str)
except ValueError:
exp_row[k] = v_str

if not exp_row[k]:
exp_row[k] = None

return exp_rows


Expand Down
2 changes: 2 additions & 0 deletions tests/func/api/test_experiments.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,5 @@ def test_exp_show(tmp_dir, dvc, scm, exp_stage): # noqa: F811
assert exps[0]["metrics.yaml:foo"] == 1.0
# Postprocessing using `None` as fill value
assert exps[0]["State"] is None
# Postprocessing empty string as `None`
assert exps[0]["Experiment"] is None

0 comments on commit 1ba3944

Please sign in to comment.