Skip to content

Commit 943ad42

Browse files
committed
Rename Test Case Visualizer back to Input Visualizer
See Kattis/problem-package-format#439 (comment)
1 parent c5adbcf commit 943ad42

File tree

12 files changed

+23
-25
lines changed

12 files changed

+23
-25
lines changed

bin/export.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from latex import PdfType
1414
from problem import Problem
1515
from validate import InputValidator, AnswerValidator, OutputValidator
16-
from visualize import TestCaseVisualizer, OutputVisualizer
16+
from visualize import InputVisualizer, OutputVisualizer
1717

1818

1919
def select_languages(problems: list[Problem]) -> list[str]:
@@ -128,7 +128,7 @@ def build_problem_zip(problem: Problem, output: Path) -> bool:
128128
("submissions/accepted/**/*", True),
129129
("submissions/*/**/*", False),
130130
("attachments/**/*", problem.interactive or problem.multi_pass),
131-
(f"{TestCaseVisualizer.source_dir}/**/*", False),
131+
(f"{InputVisualizer.source_dir}/**/*", False),
132132
(f"{OutputVisualizer.source_dir}/**/*", False),
133133
]
134134

@@ -219,7 +219,7 @@ def add_testcase(in_file: Path) -> None:
219219
f"{OutputValidator.source_dir}/**/*",
220220
# "statement/*", "solution/*", "problem_slide/*", use \constant{} commands
221221
# "submissions/*/**/*", removed support?
222-
f"{TestCaseVisualizer.source_dir}/**/*",
222+
f"{InputVisualizer.source_dir}/**/*",
223223
f"{OutputVisualizer.source_dir}/**/*",
224224
]
225225
for pattern in constants_supported:

bin/generate.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1028,7 +1028,7 @@ def use_feedback_image(feedbackdir: Path, source: str) -> None:
10281028
return
10291029

10301030
visualizer: Optional[visualize.AnyVisualizer] = problem.visualizer(
1031-
visualize.TestCaseVisualizer
1031+
visualize.InputVisualizer
10321032
)
10331033
output_visualizer = problem.visualizer(visualize.OutputVisualizer)
10341034
if output_visualizer is not None:
@@ -1057,7 +1057,7 @@ def use_feedback_image(feedbackdir: Path, source: str) -> None:
10571057
for ext in config.KNOWN_VISUALIZER_EXTENSIONS:
10581058
in_path.with_suffix(ext).unlink(True)
10591059

1060-
if isinstance(visualizer, visualize.TestCaseVisualizer):
1060+
if isinstance(visualizer, visualize.InputVisualizer):
10611061
result = visualizer.run(in_path, ans_path, cwd, visualizer_args)
10621062
else:
10631063
feedbackcopy = in_path.with_suffix(".feedbackcopy")
@@ -1931,7 +1931,7 @@ def build_program(p):
19311931
build_programs(program.Generator, generators_used)
19321932
build_programs(run.Submission, solutions_used)
19331933
if build_visualizers:
1934-
self.problem.visualizer(visualize.TestCaseVisualizer)
1934+
self.problem.visualizer(visualize.InputVisualizer)
19351935
self.problem.visualizer(visualize.OutputVisualizer)
19361936

19371937
self.problem.validators(validate.InputValidator)

bin/problem.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,7 @@ def _parse_testdata_yaml(p, path, bar):
490490
case (
491491
validate.OutputValidator.args_key
492492
| validate.AnswerValidator.args_key
493-
| visualize.TestCaseVisualizer.args_key
493+
| visualize.InputVisualizer.args_key
494494
| visualize.OutputVisualizer.args_key
495495
):
496496
if not isinstance(flags[k], list):
@@ -562,7 +562,7 @@ def get_testdata_yaml(
562562
validate.InputValidator.args_key,
563563
validate.OutputValidator.args_key,
564564
validate.AnswerValidator.args_key,
565-
visualize.TestCaseVisualizer.args_key,
565+
visualize.InputVisualizer.args_key,
566566
visualize.OutputVisualizer.args_key,
567567
]
568568
if key not in known_args_keys:
@@ -906,8 +906,8 @@ def build_program(p):
906906

907907
@overload
908908
def visualizer(
909-
problem, cls: type[visualize.TestCaseVisualizer]
910-
) -> Optional[visualize.TestCaseVisualizer]: ...
909+
problem, cls: type[visualize.InputVisualizer]
910+
) -> Optional[visualize.InputVisualizer]: ...
911911
@overload
912912
def visualizer(
913913
problem, cls: type[visualize.OutputVisualizer]

bin/upgrade.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ def upgrade_generators_yaml(problem_path: Path, bar: ProgressBar) -> None:
159159

160160
if "visualizer" in yaml_data:
161161
warn(
162-
"Cannot automatically upgrade 'visualizer'.\n - move visualizer to 'test_case_visualizer/'\n - first argument is the in_file\n - second argument is the ans_file"
162+
"Cannot automatically upgrade 'visualizer'.\n - move visualizer to 'input_visualizer/'\n - first argument is the in_file\n - second argument is the ans_file"
163163
)
164164

165165
if "data" in yaml_data and isinstance(yaml_data["data"], dict):

bin/visualize.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,25 @@
99
from problem import Problem
1010

1111

12-
class TestCaseVisualizer(program.Program):
12+
class InputVisualizer(program.Program):
1313
"""
1414
Visualizes a test case, called as:
1515
1616
./visualizer input answer [args]
1717
1818
"""
1919

20-
visualizer_type: Final[str] = "test case"
20+
visualizer_type: Final[str] = "input"
2121

22-
source_dir: Final[str] = "test_case_visualizer"
22+
source_dir: Final[str] = "input_visualizer"
2323

24-
args_key: Final[str] = "test_case_visualizer_args"
24+
args_key: Final[str] = "input_visualizer_args"
2525

2626
def __init__(self, problem: "Problem", path: Path, **kwargs: Any):
2727
super().__init__(
2828
problem,
2929
path,
30-
TestCaseVisualizer.source_dir,
30+
InputVisualizer.source_dir,
3131
limits={"timeout": problem.limits.visualizer_time},
3232
substitute_constants=True,
3333
**kwargs,
@@ -37,9 +37,7 @@ def __init__(self, problem: "Problem", path: Path, **kwargs: Any):
3737
def run(
3838
self, in_path: Path, ans_path: Path, cwd: Path, args: Optional[list[str]] = None
3939
) -> ExecResult:
40-
assert self.run_command is not None, (
41-
"Test Case Visualizer should be built before running it"
42-
)
40+
assert self.run_command is not None, "Input Visualizer should be built before running it"
4341

4442
return self._exec_command(
4543
self.run_command + [in_path, ans_path] + (args or []),
@@ -94,4 +92,4 @@ def run(
9492
return self._exec_command(command, cwd=cwd)
9593

9694

97-
AnyVisualizer = TestCaseVisualizer | OutputVisualizer
95+
AnyVisualizer = InputVisualizer | OutputVisualizer
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
This input visualizer is intended for use with BAPCtools' `bt generate`.
2+
The visualizer should be invoked as `./visualizer <input_file_path> <answer_file_path> <...input_visualizer_args>` and should write a `testcase.<ext>` file.

skel/problem/test_case_visualizer/readme.md

Lines changed: 0 additions & 2 deletions
This file was deleted.

support/schemas/generators_yaml_schema.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,12 +91,12 @@
9191
},
9292
"description": "Defines arguments passed to the output validator for the test case/group."
9393
},
94-
"test_case_visualizer_args": {
94+
"input_visualizer_args": {
9595
"type": "array",
9696
"items": {
9797
"type": "string"
9898
},
99-
"description": "Defines arguments passed to the test case visualizer for the test case/group."
99+
"description": "Defines arguments passed to the input visualizer for the test case/group."
100100
},
101101
"output_visualizer_args": {
102102
"type": "array",

support/schemas/problemformat.cue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ let filename = "[A-Za-z0-9][A-Za-z0-9_.-]{0,253}[A-Za-z0-9]"
2525
#testdata_settings: {
2626
input_validator_args?: *[] | [string] | {[string]: [string]}
2727
output_validator_args?: *[] | [string]
28-
test_case_visualizer_args?: *[] | [string]
28+
input_visualizer_args?: *[] | [string]
2929
output_visualizer_args?: *[] | [string]
3030
grading?: {
3131
score?: >0

0 commit comments

Comments
 (0)