17
17
"""Launches Tensorboard Uploader for SDK."""
18
18
19
19
import threading
20
- from typing import Optional
20
+ from typing import FrozenSet , Optional
21
21
22
22
from google .cloud .aiplatform import base
23
23
from google .cloud .aiplatform import initializer
@@ -48,6 +48,7 @@ def upload_tb_log(
48
48
run_name_prefix : Optional [str ] = None ,
49
49
description : Optional [str ] = None ,
50
50
verbosity : Optional [int ] = 1 ,
51
+ allowed_plugins : Optional [FrozenSet [str ]] = None ,
51
52
):
52
53
"""upload only the existing data in the logdir and then return immediately
53
54
@@ -74,6 +75,7 @@ def upload_tb_log(
74
75
verbosity (str): Optional. Level of verbosity, an integer. Supported
75
76
value: 0 - No upload statistics is printed. 1 - Print upload statistics
76
77
while uploading data (default).
78
+ allowed_plugins (FrozenSet[str]): Optional. List of additional allowed plugin names.
77
79
"""
78
80
self ._create_uploader (
79
81
tensorboard_id = tensorboard_id ,
@@ -85,6 +87,8 @@ def upload_tb_log(
85
87
experiment_display_name = experiment_display_name ,
86
88
run_name_prefix = run_name_prefix ,
87
89
description = description ,
90
+ verbosity = verbosity ,
91
+ allowed_plugins = allowed_plugins ,
88
92
).start_uploading ()
89
93
_LOGGER .info ("One time TensorBoard log upload completed." )
90
94
@@ -98,6 +102,7 @@ def start_upload_tb_log(
98
102
experiment_display_name : Optional [str ] = None ,
99
103
run_name_prefix : Optional [str ] = None ,
100
104
description : Optional [str ] = None ,
105
+ allowed_plugins : Optional [FrozenSet [str ]] = None ,
101
106
):
102
107
"""continues to listen for new data in the logdir and uploads when it appears.
103
108
@@ -121,6 +126,7 @@ def start_upload_tb_log(
121
126
invocation will have their name prefixed by this value.
122
127
description (str): Optional. String description to assign to the
123
128
experiment.
129
+ allowed_plugins (FrozenSet[str]): Optional. List of additional allowed plugin names.
124
130
"""
125
131
if self ._tensorboard_uploader :
126
132
_LOGGER .info (
@@ -141,6 +147,7 @@ def start_upload_tb_log(
141
147
run_name_prefix = run_name_prefix ,
142
148
description = description ,
143
149
verbosity = 0 ,
150
+ allowed_plugins = allowed_plugins ,
144
151
)
145
152
threading .Thread (target = self ._tensorboard_uploader .start_uploading ).start ()
146
153
@@ -174,6 +181,7 @@ def _create_uploader(
174
181
run_name_prefix : Optional [str ] = None ,
175
182
description : Optional [str ] = None ,
176
183
verbosity : Optional [int ] = 1 ,
184
+ allowed_plugins : Optional [FrozenSet [str ]] = None ,
177
185
) -> "TensorBoardUploader" : # noqa: F821
178
186
"""Create a TensorBoardUploader and a TensorBoard Experiment
179
187
@@ -188,6 +196,7 @@ def _create_uploader(
188
196
run_name_prefix (str): Optional. If present, all runs created by this invocation will have their name prefixed by this value.
189
197
description (str): Optional. String description to assign to the experiment.
190
198
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.
191
200
192
201
Returns:
193
202
An instance of TensorBoardUploader.
@@ -244,13 +253,21 @@ def _create_uploader(
244
253
) = uploader_utils .get_blob_storage_bucket_and_folder (
245
254
api_client , tensorboard_resource_name , project
246
255
)
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
+
247
264
tensorboard_uploader = TensorBoardUploader (
248
265
experiment_name = tensorboard_experiment_name ,
249
266
tensorboard_resource_name = tensorboard_resource_name ,
250
267
experiment_display_name = experiment_display_name ,
251
268
blob_storage_bucket = blob_storage_bucket ,
252
269
blob_storage_folder = blob_storage_folder ,
253
- allowed_plugins = uploader_constants . ALLOWED_PLUGINS ,
270
+ allowed_plugins = plugins ,
254
271
writer_client = api_client ,
255
272
logdir = logdir ,
256
273
one_shot = one_shot ,
0 commit comments