Returns flags as a string that can be passed as command line arguments. E.g., returns: "--batch_size=256 --use_synthetic_data" for the following code block: ``` flags.FLAGS.batch_size = 256 flags.FLAGS.use_synthetic_data = True print(get_nondefault_flags_as_str()) ``` Only flags w
()
| 99 | |
| 100 | |
| 101 | def get_nondefault_flags_as_str(): |
| 102 | """Returns flags as a string that can be passed as command line arguments. |
| 103 | |
| 104 | E.g., returns: "--batch_size=256 --use_synthetic_data" for the following code |
| 105 | block: |
| 106 | |
| 107 | ``` |
| 108 | flags.FLAGS.batch_size = 256 |
| 109 | flags.FLAGS.use_synthetic_data = True |
| 110 | print(get_nondefault_flags_as_str()) |
| 111 | ``` |
| 112 | |
| 113 | Only flags with nondefault values are returned, as passing default flags as |
| 114 | command line arguments has no effect. |
| 115 | |
| 116 | Returns: |
| 117 | A string with the flags, that can be passed as command line arguments to a |
| 118 | program to use the flags. |
| 119 | """ |
| 120 | nondefault_flags = _get_nondefault_flags_as_dict() |
| 121 | flag_strings = [] |
| 122 | for name, value in sorted(nondefault_flags.items()): |
| 123 | if isinstance(value, bool): |
| 124 | flag_str = '--{}'.format(name) if value else '--no{}'.format(name) |
| 125 | elif isinstance(value, list): |
| 126 | flag_str = '--{}={}'.format(name, ','.join(value)) |
| 127 | else: |
| 128 | flag_str = '--{}={}'.format(name, value) |
| 129 | flag_strings.append(flag_str) |
| 130 | return ' '.join(shlex_quote(flag_str) for flag_str in flag_strings) |
nothing calls this directly
no test coverage detected