Skip to content

Validators in scripting languages

David Anderson edited this page Jan 11, 2024 · 5 revisions

The validator script_validator allows you to write your validation logic in your language of choice (Python, PHP, Perl, Java, bash). script_validator takes two additional command-line arguments:

--init_script "filename arg1 ... argn"

script to check the validity of a result. Exit zero if valid.

--compare_script "filename arg1 ... argn"

script to compare two results. Exit zero if outputs are equivalent.

arg1 ... argn represent cmdline args to be passed to the scripts. The options for init_script are:

files

list of paths of output files of the result

result_id

result ID

runtime

task runtime in seconds

Additional options for compare_script, for the second result:

files2

list of paths of output files

result_id2

result ID

runtime2

task runtime

arg1 ... argn can be omitted, in which case only the output file paths are passed to the scripts.

The scripts must be put in your project's bin/ directory.

For applications that don't use replication, the compare script need not be given. For applications that don't need output file syntax checking, the init script need not be given.

As an example, the following PHP script, used as a compare script, would require that results match exactly:

#/usr/bin/env
<?php

$f1 = $argv[1];
$f2 = $argv[2];
if (md5_file($f1) != md5_file($f2)) {
    fwrite(STDERR, "$f1 and $f2 don't match\n");
    exit(1);
}

?>

The corresponding entry in config.xml would look like

<daemon>
    <cmd>script_validator --app uppercase -d 3 --compare_script compare.php</cmd>
</daemon>
Clone this wiki locally