def compile(env, **kwargs): """Compiles source file on the remote machine and returns name of the executable that may be ran USES * env['source_file'] - source file name * env['language'] - if ``env['compiler']`` is not set and ``env['language']`` is, the compiler is set to ``'default-' + env['language']``. * the entire ``env`` is also passed to the ``compile`` job PRODUCES * env['compilation_result'] - may be OK if the file compiled successfully or CE otherwise. * env['compiled_file'] - exists if and only if env['compilation_result'] is set to OK and contains compiled binary path * env['compilation_message'] - contains compiler stdout and stderr * env['exec_info'] - information how to execute the compiled file """ compilation_job = env.copy() compilation_job['job_type'] = 'compile' compilation_job['task_priority'] = COMPILE_TASK_PRIORITY compilation_job['out_file'] = _make_filename(env, 'exe') if 'language' in env and 'compiler' not in env: compilation_job['compiler'] = 'default-' + env['language'] env['workers_jobs'] = {'compile': compilation_job} return transfer_job(env, 'oioioi.sioworkers.handlers.transfer_job', 'oioioi.sioworkers.handlers.restore_job')
def _call_transfer(environ): environ['magic'] = 1234 return transfer_job( environ, 'oioioi.evalmgr.tests.tests._transfer', 'oioioi.evalmgr.tests.tests._resume', transfer_kwargs={'transfer_magic': 42})
def run_tests(env, kind=None, **kwargs): """Runs tests and saves their results into the environment If ``kind`` is specified, only tests with the given kind will be run. Used ``environ`` keys: * ``tests``: this should be a dictionary, mapping test name into the environment to pass to the ``exec`` job * ``unsafe_exec``: set to ``True`` if we want to use only ``ulimit()`` to limit the executable file resources, ``False`` otherwise (see the documentation for ``unsafe-exec`` job for more information), * ``compiled_file``: the compiled file which will be tested, * ``exec_info``: information how to execute ``compiled_file`` * ``check_outputs``: set to ``True`` if the output should be verified * ``checker``: if present, it should be the filetracker path of the binary used as the output checker, * ``save_outputs``: set to ``True`` if and only if each of test results should have its output file attached. * ``sioworkers_extra_args``: dict mappting kinds to additional arguments passed to :fun:`oioioi.sioworkers.jobs.run_sioworkers_jobs` (kwargs). Produced ``environ`` keys: * ``test_results``: a dictionary, mapping test names into dictionaries with the following keys: ``result_code`` test status: OK, WA, RE, ... ``result_string`` detailed supervisor information (for example, where the required and returned outputs differ) ``time_used`` total time used, in miliseconds ``mem_used`` memory usage, in KiB ``num_syscalls`` number of syscalls performed ``out_file`` filetracker path to the output file (only if ``env['save_outputs']`` was set) If the dictionary already exists, new test results are appended. """ jobs = dict() not_to_judge = [] for test_name, test_env in six.iteritems(env['tests']): if kind and test_env['kind'] != kind: continue if not test_env['to_judge']: not_to_judge.append(test_name) continue job = test_env.copy() job['job_type'] = (env.get('exec_mode', '') + '-exec').lstrip('-') if kind == 'INITIAL' or kind == 'EXAMPLE': job['task_priority'] = EXAMPLE_TEST_TASK_PRIORITY elif env['submission_kind'] == 'TESTRUN': job['task_priority'] = TESTRUN_TEST_TASK_PRIORITY else: job['task_priority'] = DEFAULT_TEST_TASK_PRIORITY job['exe_file'] = env['compiled_file'] job['exec_info'] = env['exec_info'] job['check_output'] = env.get('check_outputs', True) if env.get('checker'): job['chk_file'] = env['checker'] if env.get('save_outputs'): job.setdefault('out_file', _make_filename(env, test_name + '.out')) job['upload_out'] = True job['untrusted_checker'] = env['untrusted_checker'] jobs[test_name] = job extra_args = env.get('sioworkers_extra_args', {}).get(kind, {}) env['workers_jobs'] = jobs env['workers_jobs.extra_args'] = extra_args env['workers_jobs.not_to_judge'] = not_to_judge return transfer_job(env, 'oioioi.sioworkers.handlers.transfer_job', 'oioioi.sioworkers.handlers.restore_job')