From 9eac55422a69d6d28a547464c9883e1bbacfb37b Mon Sep 17 00:00:00 2001 From: VictorSanh Date: Tue, 8 Jun 2021 02:45:25 +0000 Subject: [PATCH] fix show_templates GH actions for blank outputs (conditional templates) --- promptsource/show_templates.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/promptsource/show_templates.py b/promptsource/show_templates.py index 6283a120c..f7d077848 100644 --- a/promptsource/show_templates.py +++ b/promptsource/show_templates.py @@ -39,12 +39,17 @@ print(template.jinja) print() - for example_index in range(10): - example = dataset[example_index] + print_counter = 0 + for example in dataset: print("\t--------") print("\tExample ", example) print("\t--------") - xp, yp = template.apply(example) + output = template.apply(example) + if output == [""]: + print("\t Blank result") + continue + + xp, yp = output print() print("\tPrompt | X") for line in textwrap.wrap(xp, width=width, replace_whitespace=False): @@ -53,3 +58,7 @@ print("\tY") for line in textwrap.wrap(yp, width=width, replace_whitespace=False): print("\t", line.replace("\n", "\n\t")) + + print_counter += 1 + if print_counter >= 10: + break