49
49
flags .DEFINE_integer (
50
50
"event_file_inactive_secs" ,
51
51
None ,
52
- "Age in seconds of last write after which an event file is considered " " inactive." ,
52
+ "Age in seconds of last write after which an event file is considered inactive." ,
53
53
)
54
54
flags .DEFINE_string (
55
55
"run_name_prefix" ,
56
56
None ,
57
57
"If present, all runs created by this invocation will have their name "
58
58
"prefixed by this value." ,
59
59
)
60
+ flags .DEFINE_string (
61
+ "api_uri" ,
62
+ "aiplatform.googleapis.com" ,
63
+ "The API URI for fetching Tensorboard metadata." ,
64
+ )
65
+ flags .DEFINE_string (
66
+ "web_server_uri" ,
67
+ "tensorboard.googleusercontent.com" ,
68
+ "The API URI for accessing the Tensorboard UI." ,
69
+ )
60
70
61
71
flags .DEFINE_multi_string (
62
72
"allowed_plugins" ,
@@ -79,6 +89,7 @@ def main(argv):
79
89
if len (argv ) > 1 :
80
90
raise app .UsageError ("Too many command-line arguments." )
81
91
92
+ aiplatform .constants .API_BASE_PATH = FLAGS .api_uri
82
93
m = re .match (
83
94
"projects/(.*)/locations/(.*)/tensorboards/.*" , FLAGS .tensorboard_resource_name
84
95
)
@@ -131,7 +142,7 @@ def main(argv):
131
142
print (
132
143
"View your Tensorboard at https://{}.{}/experiment/{}" .format (
133
144
region ,
134
- "tensorboard.googleusercontent.com" ,
145
+ FLAGS . web_server_uri ,
135
146
tb_uploader .get_experiment_resource_name ().replace ("/" , "+" ),
136
147
)
137
148
)
@@ -141,8 +152,16 @@ def main(argv):
141
152
tb_uploader .start_uploading ()
142
153
143
154
155
+ def flags_parser (args ):
156
+ # Plumbs the flags defined in this file to the main module, mostly for the
157
+ # console script wrapper tb-gcp-uploader.
158
+ for flag in set (flags .FLAGS .get_key_flags_for_module (__name__ )):
159
+ flags .FLAGS .register_flag_by_module (args [0 ], flag )
160
+ return app .parse_flags_with_usage (args )
161
+
162
+
144
163
def run_main ():
145
- app .run (main )
164
+ app .run (main , flags_parser = flags_parser )
146
165
147
166
148
167
if __name__ == "__main__" :
0 commit comments