Skip to content

Commit de8cc93

Browse files
authored
Change default checker to oicompare (#31)
* Change default checker to oicompare * Ability to change oicompare's language * Allow changing oicompare format
1 parent 738aa7a commit de8cc93

File tree

2 files changed

+21
-7
lines changed

2 files changed

+21
-7
lines changed

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
setup(
44
name = "sioworkers",
5-
version = '1.5.2',
5+
version = '1.5.3',
66
author = "SIO2 Project Team",
77
author_email = '[email protected]',
88
description = "Programming contest judging infrastructure",

sio/executors/checker.py

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -87,12 +87,12 @@ def execute_checker(with_stderr=False, stderr=None):
8787
return renv['stdout']
8888

8989

90-
def _run_compare(env):
91-
e = SandboxExecutor('exec-sandbox')
90+
def _run_compare(env, format):
91+
e = SandboxExecutor('oicompare-sandbox-v1.0.2')
9292
renv = _run_in_executor(
93-
env, [os.path.join('bin', 'compare'), 'hint', 'out'], e, ignore_errors=True
93+
env, [os.path.join('bin', 'oicompare'), 'hint', 'out', format], e, ignore_errors=True
9494
)
95-
return renv['stdout']
95+
return renv
9696

9797

9898
def _limit_length(s):
@@ -116,7 +116,21 @@ def run(environ, use_sandboxes=True):
116116

117117
output = _run_checker(environ, use_sandboxes)
118118
elif use_sandboxes:
119-
output = _run_compare(environ)
119+
renv = _run_compare(environ, environ.get('checker_format', 'english_abbreviated'))
120+
if renv['return_code'] == 0:
121+
environ['result_code'] = 'OK'
122+
environ['result_percentage'] = (100, 1)
123+
elif renv['return_code'] == 1:
124+
environ['result_code'] = 'WA'
125+
environ['result_percentage'] = (0, 1)
126+
# Should be redundant because we are using oicompare with abbreviated output,
127+
# but just in case.
128+
environ['result_string'] = _limit_length(renv['stdout'][0])
129+
else:
130+
raise CheckerError(
131+
'oicompare returned code(%d). Checker renv: %s' % (renv['return_code'], renv)
132+
)
133+
return environ
120134
else:
121135
output = _run_diff(environ)
122136
except (CheckerError, ExecError) as e:
@@ -155,4 +169,4 @@ def output_to_fraction(output_str):
155169
except ZeroDivisionError:
156170
raise CheckerError('Zero division in checker output "%s"' % output_str)
157171
except TypeError:
158-
raise CheckerError('Invalid checker output "%s"' % output_str)
172+
raise CheckerError('Invalid checker output "%s"' % output_str)

0 commit comments

Comments
 (0)