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