MCPcopy
hub / github.com/tensorflow/tensorboard / configure

Method configure

tensorboard/program.py:158–252  ·  view source on GitHub ↗

Configures TensorBoard behavior via flags. This method will populate the "flags" property with an argparse.Namespace representing flag values parsed from the provided argv list, overridden by explicit flags from remaining keyword arguments. Args: argv: Can

(self, argv=("",), **kwargs)

Source from the content-addressed store, hash-verified

156 self.flags = None
157
158 def configure(self, argv=("",), **kwargs):
159 """Configures TensorBoard behavior via flags.
160
161 This method will populate the "flags" property with an argparse.Namespace
162 representing flag values parsed from the provided argv list, overridden by
163 explicit flags from remaining keyword arguments.
164
165 Args:
166 argv: Can be set to CLI args equivalent to sys.argv; the first arg is
167 taken to be the name of the path being executed.
168 kwargs: Additional arguments will override what was parsed from
169 argv. They must be passed as Python data structures, e.g.
170 `foo=1` rather than `foo="1"`.
171
172 Returns:
173 Either argv[:1] if argv was non-empty, or [''] otherwise, as a mechanism
174 for absl.app.run() compatibility.
175
176 Raises:
177 ValueError: If flag values are invalid.
178 """
179
180 base_parser = argparse_flags.ArgumentParser(
181 prog="tensorboard",
182 description=(
183 "TensorBoard is a suite of web applications for "
184 "inspecting and understanding your TensorFlow runs "
185 "and graphs. https://github.com/tensorflow/tensorboard "
186 ),
187 )
188 subparsers = base_parser.add_subparsers(
189 help="TensorBoard subcommand (defaults to %r)"
190 % _SERVE_SUBCOMMAND_NAME
191 )
192
193 serve_subparser = subparsers.add_parser(
194 _SERVE_SUBCOMMAND_NAME,
195 help="start local TensorBoard server (default subcommand)",
196 )
197 serve_subparser.set_defaults(
198 **{_SUBCOMMAND_FLAG: _SERVE_SUBCOMMAND_NAME}
199 )
200
201 if len(argv) < 2 or argv[1].startswith("-"):
202 # This invocation, if valid, must not use any subcommands: we
203 # don't permit flags before the subcommand name.
204 serve_parser = base_parser
205 else:
206 # This invocation, if valid, must use a subcommand: we don't take
207 # any positional arguments to `serve`.
208 serve_parser = serve_subparser
209
210 for name, subcommand in self.subcommands.items():
211 subparser = subparsers.add_parser(
212 name,
213 help=subcommand.help(),
214 description=subcommand.description(),
215 )

Calls 6

setFunction · 0.85
itemsMethod · 0.80
helpMethod · 0.80
descriptionMethod · 0.45
define_flagsMethod · 0.45
fix_flagsMethod · 0.45

Tested by 8

testConfigureMethod · 0.76
testImplicitServeMethod · 0.76
testExplicitServeMethod · 0.76
testSubcommandMethod · 0.76