Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hparams: Fix metric info generation for sessions without run names. #6541

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tensorboard/plugins/hparams/backend_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ def compute_metric_infos_from_data_provider_session_groups(
self, ctx, experiment_id, session_groups
):
session_runs = set(
f"{s.experiment_id}/{s.run}"
f"{s.experiment_id}/{s.run}" if s.run else s.experiment_id
for sg in session_groups
for s in sg.sessions
)
Expand Down
40 changes: 39 additions & 1 deletion tensorboard/plugins/hparams/backend_context_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,7 @@ def test_experiment_from_data_provider_discrete_string_hparam(self):
"""
self.assertProtoEquals(expected_exp, actual_exp)

def test_experiment_from_data_provider_session_group(self):
def test_experiment_from_data_provider_session_groups(self):
self._mock_tb_context.data_provider.list_tensors.side_effect = None
# The sessions chosen here mimic those returned in the implementation
# of _mock_list_tensors. These work nicely with the scalars returned
Expand Down Expand Up @@ -614,6 +614,44 @@ def test_experiment_from_data_provider_session_group(self):
"""
self.assertProtoEquals(expected_exp, actual_exp)

def test_experiment_from_data_provider_session_group_without_run_name(self):
self._mock_tb_context.data_provider.list_tensors.side_effect = None
self._hyperparameters = provider.ListHyperparametersResult(
hyperparameters=[],
session_groups=[
provider.HyperparameterSessionGroup(
root=provider.HyperparameterSessionRun(
experiment_id="exp/session_1", run=""
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should the id field just be exp?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, it has to be the entire path of the session. I left a comment in the test trying to explain for future readers.

),
# The entire path to the run is encoded in the experiment_id
# to allow us to test empty run name while still generating
# metric_infos.
sessions=[
provider.HyperparameterSessionRun(
experiment_id="exp/session_1", run=""
),
],
hyperparameter_values=[],
),
],
)
actual_exp = self._experiment_from_metadata()
expected_exp = """
metric_infos: {
name: {group: '', tag: 'accuracy'}
}
metric_infos: {
name: {group: '', tag: 'loss'}
}
metric_infos: {
name: {group: 'eval', tag: 'loss'}
}
metric_infos: {
name: {group: 'train', tag: 'loss'}
}
"""
self.assertProtoEquals(expected_exp, actual_exp)

def test_experiment_from_data_provider_old_response_type(self):
self._hyperparameters = [
provider.Hyperparameter(
Expand Down