@@ -224,7 +224,7 @@ class InputValidator(Validator):
224
224
Also supports checktestdata and viva files, with different invocation.
225
225
"""
226
226
227
- validator_type : Final [str ] = "input"
227
+ validator_type : Final [str ] = "input validator "
228
228
229
229
source_dir : Final [str ] = "input_validators"
230
230
@@ -284,7 +284,7 @@ class AnswerValidator(Validator):
284
284
Also supports checktestdata and viva files, with different invocation.
285
285
"""
286
286
287
- validator_type : Final [str ] = "answer"
287
+ validator_type : Final [str ] = "answer validator "
288
288
289
289
source_dir : Final [str ] = "answer_validators"
290
290
@@ -335,7 +335,7 @@ class OutputValidator(Validator):
335
335
./validator input answer feedbackdir [arguments from problem.yaml] < output
336
336
"""
337
337
338
- validator_type : Final [str ] = "output"
338
+ validator_type : Final [str ] = "output validator "
339
339
340
340
source_dir : Final [str ] = "output_validator"
341
341
@@ -356,7 +356,7 @@ def run(
356
356
---------
357
357
358
358
mode: either a run.Run (namely, when validating submission output) or a Mode
359
- (namely, when validation a testcase)
359
+ (namely, when validating a testcase)
360
360
361
361
Returns
362
362
-------
@@ -366,7 +366,7 @@ def run(
366
366
assert self .run_command is not None , "Validator should be built before running it"
367
367
368
368
if mode == Mode .INPUT :
369
- raise ValueError ("OutputValidator do not support Mode.INPUT" )
369
+ raise ValueError ("OutputValidator does not support Mode.INPUT" )
370
370
371
371
in_path = testcase .in_path .resolve ()
372
372
ans_path = testcase .ans_path .resolve ()
@@ -410,7 +410,68 @@ def run(
410
410
return ret
411
411
412
412
413
- AnyValidator = InputValidator | AnswerValidator | OutputValidator
413
+ class OutputVisualizer (Validator ):
414
+ """
415
+ Visualize the output of a submission
416
+
417
+ ./visualizer input answer feedbackdir [arguments from problem.yaml] < output
418
+ """
419
+
420
+ validator_type : Final [str ] = "output visualizer"
421
+
422
+ source_dir : Final [str ] = "output_visualizer"
423
+
424
+ def __init__ (self , problem , path , ** kwargs ):
425
+ super ().__init__ (problem , path , "output_visualizer" , ** kwargs )
426
+
427
+ def run (
428
+ self ,
429
+ testcase , # TODO #102: fix type errors after setting type to Testcase
430
+ mode ,
431
+ constraints : Optional [ConstraintsDict ] = None ,
432
+ args = None ,
433
+ ) -> ExecResult :
434
+ """
435
+ Run this validator on the given testcase.
436
+
437
+ Arguments
438
+ ---------
439
+
440
+ run: run.Run (namely, when visualizing submission output)
441
+
442
+ Returns
443
+ -------
444
+ The ExecResult
445
+ """
446
+
447
+ assert self .run_command is not None , "Validator should be built before running it"
448
+
449
+ in_path = testcase .in_path .resolve ()
450
+ ans_path = testcase .ans_path .resolve ()
451
+ run = mode # mode is actually a run
452
+ path = run .out_path
453
+ in_path = run .in_path
454
+
455
+ if self .language in Validator .FORMAT_VALIDATOR_LANGUAGES :
456
+ raise ValueError ("Invalid output validator language" )
457
+
458
+ # Only get the output_validator_args
459
+ _ , _ , arglist = self ._run_helper (testcase , constraints , args )
460
+ cwd = run .feedbackdir
461
+ invocation = self .run_command + [in_path , ans_path , cwd ]
462
+
463
+ with path .open () as file :
464
+ ret = self ._exec_helper (
465
+ invocation + arglist ,
466
+ exec_code_map = validator_exec_code_map ,
467
+ stdin = file ,
468
+ cwd = cwd ,
469
+ )
470
+
471
+ return ret
472
+
473
+
474
+ AnyValidator = InputValidator | AnswerValidator | OutputValidator | OutputVisualizer
414
475
415
476
416
477
# Checks if byte is printable or whitespace
0 commit comments