1717"""Launches Tensorboard Uploader for SDK."""
1818
1919import threading
20- from typing import Optional
20+ from typing import FrozenSet , Optional
2121
2222from google .cloud .aiplatform import base
2323from google .cloud .aiplatform import initializer
@@ -48,6 +48,7 @@ def upload_tb_log(
4848 run_name_prefix : Optional [str ] = None ,
4949 description : Optional [str ] = None ,
5050 verbosity : Optional [int ] = 1 ,
51+ allowed_plugins : Optional [FrozenSet [str ]] = None ,
5152 ):
5253 """upload only the existing data in the logdir and then return immediately
5354
@@ -74,6 +75,7 @@ def upload_tb_log(
7475 verbosity (str): Optional. Level of verbosity, an integer. Supported
7576 value: 0 - No upload statistics is printed. 1 - Print upload statistics
7677 while uploading data (default).
78+ allowed_plugins (FrozenSet[str]): Optional. List of additional allowed plugin names.
7779 """
7880 self ._create_uploader (
7981 tensorboard_id = tensorboard_id ,
@@ -85,6 +87,8 @@ def upload_tb_log(
8587 experiment_display_name = experiment_display_name ,
8688 run_name_prefix = run_name_prefix ,
8789 description = description ,
90+ verbosity = verbosity ,
91+ allowed_plugins = allowed_plugins ,
8892 ).start_uploading ()
8993 _LOGGER .info ("One time TensorBoard log upload completed." )
9094
@@ -98,6 +102,7 @@ def start_upload_tb_log(
98102 experiment_display_name : Optional [str ] = None ,
99103 run_name_prefix : Optional [str ] = None ,
100104 description : Optional [str ] = None ,
105+ allowed_plugins : Optional [FrozenSet [str ]] = None ,
101106 ):
102107 """continues to listen for new data in the logdir and uploads when it appears.
103108
@@ -121,6 +126,7 @@ def start_upload_tb_log(
121126 invocation will have their name prefixed by this value.
122127 description (str): Optional. String description to assign to the
123128 experiment.
129+ allowed_plugins (FrozenSet[str]): Optional. List of additional allowed plugin names.
124130 """
125131 if self ._tensorboard_uploader :
126132 _LOGGER .info (
@@ -141,6 +147,7 @@ def start_upload_tb_log(
141147 run_name_prefix = run_name_prefix ,
142148 description = description ,
143149 verbosity = 0 ,
150+ allowed_plugins = allowed_plugins ,
144151 )
145152 threading .Thread (target = self ._tensorboard_uploader .start_uploading ).start ()
146153
@@ -174,6 +181,7 @@ def _create_uploader(
174181 run_name_prefix : Optional [str ] = None ,
175182 description : Optional [str ] = None ,
176183 verbosity : Optional [int ] = 1 ,
184+ allowed_plugins : Optional [FrozenSet [str ]] = None ,
177185 ) -> "TensorBoardUploader" : # noqa: F821
178186 """Create a TensorBoardUploader and a TensorBoard Experiment
179187
@@ -188,6 +196,7 @@ def _create_uploader(
188196 run_name_prefix (str): Optional. If present, all runs created by this invocation will have their name prefixed by this value.
189197 description (str): Optional. String description to assign to the experiment.
190198 verbosity (int)): Optional. Level of verbosity. Supported value: 0 - No upload statistics is printed. 1 - Print upload statistics while uploading data (default).
199+ allowed_plugins (FrozenSet[str]): Optional. List of additional allowed plugin names.
191200
192201 Returns:
193202 An instance of TensorBoardUploader.
@@ -244,13 +253,21 @@ def _create_uploader(
244253 ) = uploader_utils .get_blob_storage_bucket_and_folder (
245254 api_client , tensorboard_resource_name , project
246255 )
256+
257+ plugins = uploader_constants .ALLOWED_PLUGINS
258+ plugins += [
259+ plugin
260+ for plugin in allowed_plugins
261+ if plugin not in uploader_constants .ALLOWED_PLUGINS
262+ ]
263+
247264 tensorboard_uploader = TensorBoardUploader (
248265 experiment_name = tensorboard_experiment_name ,
249266 tensorboard_resource_name = tensorboard_resource_name ,
250267 experiment_display_name = experiment_display_name ,
251268 blob_storage_bucket = blob_storage_bucket ,
252269 blob_storage_folder = blob_storage_folder ,
253- allowed_plugins = uploader_constants . ALLOWED_PLUGINS ,
270+ allowed_plugins = plugins ,
254271 writer_client = api_client ,
255272 logdir = logdir ,
256273 one_shot = one_shot ,
0 commit comments