Skip to content

hparams: strip a trailing path separator from the metric run name on Windows - #7176

Open
Ramnath0521 wants to merge 1 commit into
tensorflow:masterfrom
Ramnath0521:fix/issue-7175
Open

Ramnath0521 wants to merge 1 commit into
tensorflow:masterfrom
Ramnath0521:fix/issue-7175

Conversation

@Ramnath0521

Copy link
Copy Markdown

Motivation for features / changes

Fixes #7175. On Windows the HParams dashboard shows null for every metric of a session, and the JSON download has null too, although the scalars are in the event files.

run_tag_from_session_and_metric joins the session name and the metric group with os.path.join and then removes a trailing /. When the group is empty (what add_hparams writes), os.path.join("Model001", "") is Model001\ on Windows. The / check does not remove it, so the metric lookup uses a run name that the multiplexer does not know.

Technical description of changes

tensorboard/plugins/hparams/metrics.py: remove a trailing os.sep as well as a trailing /. A session name that ends in / (a cloud path read on Windows) is still handled by the / check.

tensorboard/plugins/hparams/metrics_test.py (new, with a py_test target in BUILD): six tests of run_tag_from_session_and_metric, run once with posixpath and once with ntpath swapped into os, so they exercise both separators on any machine. They cover an empty group, an empty group with a nested session, a session name ending in /, and a non-empty group. Two of the six fail without the change (the empty-group cases on ntpath).

Screenshots of UI changes (or N/A)

N/A

Detailed steps to verify changes work correctly (as executed by you)

On Windows 11, Python 3.12, with the TensorBoard 2.21.0 wheel installed for the generated protos:

  1. Wrote an event file with one scalar (train_loss) into logdir/Model001 and loaded logdir with EventMultiplexer. It reports the run Model001.
  2. Called run_tag_from_session_and_metric("Model001", MetricName(group="", tag="train_loss")):
    • installed 2.21.0: ('Model001\\', 'train_loss'), which is not a known run
    • with this change: ('Model001', 'train_loss'), which is the run in the multiplexer
  3. python -m pytest tensorboard/plugins/hparams/metrics_test.py: 6 passed. Without the change in metrics.py, 2 fail and 4 pass.

I did not run the Bazel build, and I did not open the dashboard in a browser. list_metric_evals_test and list_session_groups_test need TensorFlow, which I did not install here, so I did not run them.

Alternate designs / implementations considered (or N/A)

  • Building the run name with "/".join(...): on Windows the multiplexer names nested runs with \ (a logdir with Model001/train reports the runs Model001 and Model001\train), so a / join would not match them.
  • Stripping every trailing separator with rstrip: this would also change run names that legitimately end in more than one separator, which the old code did not touch.

🤖 Generated with Claude Code

…Windows

With an empty metric group, os.path.join(session_name, "") ends in a
backslash on Windows. Only a trailing "/" was removed, so the run name did
not match any run in the multiplexer and the HParams dashboard showed null
for every metric. Remove a trailing os.sep as well.

Fixes tensorflow#7175

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@google-cla

google-cla Bot commented Nov 16, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Error Parsing Hyper Parameters (HPARAMS) on Windows

1 participant