From 6991ec787f62271f21d96abe66921cd4d0d4f939 Mon Sep 17 00:00:00 2001 From: Brian Dubois Date: Thu, 24 Aug 2023 07:35:35 -0400 Subject: [PATCH] Add helpful comment. Refactor a bit. --- tensorboard/plugins/hparams/get_experiment.py | 21 +++++++++---------- .../plugins/hparams/list_session_groups.py | 2 ++ 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/tensorboard/plugins/hparams/get_experiment.py b/tensorboard/plugins/hparams/get_experiment.py index 9894cff8e42..5fa3987b110 100644 --- a/tensorboard/plugins/hparams/get_experiment.py +++ b/tensorboard/plugins/hparams/get_experiment.py @@ -32,7 +32,12 @@ def __init__( self._request_context = request_context self._backend_context = backend_context self._experiment_id = experiment_id - self._request = request + self._include_metrics = ( + # Metrics are included by default if include_metrics is not + # specified in the request. + not request.HasField("include_metrics") + or request.include_metrics + ) def run(self): """Handles the request specified on construction. @@ -40,20 +45,14 @@ def run(self): Returns: An Experiment object. """ - experiment_id = self._experiment_id - include_metrics = ( - not self._request.HasField("include_metrics") - or self._request.include_metrics - ) - return self._backend_context.experiment_from_metadata( self._request_context, - experiment_id, - include_metrics, + self._experiment_id, + self._include_metrics, self._backend_context.hparams_metadata( - self._request_context, experiment_id + self._request_context, self._experiment_id ), self._backend_context.hparams_from_data_provider( - self._request_context, experiment_id + self._request_context, self._experiment_id ), ) diff --git a/tensorboard/plugins/hparams/list_session_groups.py b/tensorboard/plugins/hparams/list_session_groups.py index c10b336dc78..908abfa5b8d 100644 --- a/tensorboard/plugins/hparams/list_session_groups.py +++ b/tensorboard/plugins/hparams/list_session_groups.py @@ -52,6 +52,8 @@ def __init__( self._experiment_id = experiment_id self._request = request self._include_metrics = ( + # Metrics are included by default if include_metrics is not + # specified in the request. not self._request.HasField("include_metrics") or self._request.include_metrics )