Skip to content

Commit 4d418c7

Browse files
jiyongjungtfx-copybara
authored andcommitted
Fixes parse error of CLI output in template pipeline testing which expects '| str |' format.
Moreover, adding a space between a separator and the content makes links more usable when we put links in the table. PiperOrigin-RevId: 364968402
1 parent a50def4 commit 4d418c7

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

tfx/tools/cli/handler/base_handler.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -191,11 +191,11 @@ def _subprocess_call(self,
191191
def _format_table(self, header: Collection[Any],
192192
data: Collection[Collection[Any]]):
193193

194-
def _force_strings(items):
195-
return [str(item) for item in items]
194+
def _format_as_strings(items):
195+
return [f' {item} ' for item in items]
196196

197-
header = _force_strings(header)
198-
data = [_force_strings(row) for row in data]
197+
header = _format_as_strings(header)
198+
data = [_format_as_strings(row) for row in data]
199199

200200
max_widths = [len(s) for s in header]
201201
for row in data:

tfx/tools/cli/handler/base_handler_test.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -207,13 +207,13 @@ def testFormatTable(self):
207207
handler = FakeHandler(flags_dict)
208208
self.assertEqual(
209209
textwrap.dedent("""\
210-
+===+===+=====+
211-
|abc|d |False|
212-
+===+===+=====+
213-
|1 |234|None |
214-
+---+---+-----+
215-
|xxx| |[] |
216-
+===+===+=====+
210+
+=====+=====+=======+
211+
| abc | d | False |
212+
+=====+=====+=======+
213+
| 1 | 234 | None |
214+
+-----+-----+-------+
215+
| xxx | | [] |
216+
+=====+=====+=======+
217217
"""),
218218
handler._format_table(('abc', 'd', False),
219219
[[1, '234', None], ['xxx', '', []]]))

0 commit comments

Comments
 (0)