# HG changeset patch # User Nattee Niparnan # Date 2018-06-12 13:11:37 # Node ID 0654ec1bf773f72aa16191b0c7db4c8146cb24ad # Parent 5845bbd3b4134dc94f351673e509e938364788a9 # Parent 1460f97ba17ddfa293a221952fbe5905549c3b58 merge to master diff --git a/grader b/grader --- a/grader +++ b/grader @@ -57,7 +57,8 @@ the problem name must be specified by the next argument. additional options: - --all-sub re-grade every submissions instead of just the latest submission of each user. + --all-sub re-grade every submissions instead of just the latest submission of each user. + --only-error re-grade only submissions that are "error during grading" sub: re-grader the specified submission. The submission ID to be re-graded must be specified by the next argument. @@ -136,6 +137,7 @@ end options[:all_sub] = (ARGV.delete('--all-sub') != nil) + options[:only_err] = (ARGV.delete('--only-error') != nil) options[:err_log] = (ARGV.delete('--err-log') != nil) diff --git a/grader-process-check b/grader-process-check deleted file mode 100755 --- a/grader-process-check +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/bash -count=`ps aux | grep "cafe_grader" | grep "grader grading queue" | wc -l` -if [ $count -lt 1 ]; then - cd /home/dae/cafe_grader/judge - /home/dae/.rvm/wrappers/ruby-2.3.0/ruby /home/dae/cafe_grader/judge/scripts/grader grading queue > /home/dae/grading.log & -fi diff --git a/grader-process-check.SAMPLE b/grader-process-check.SAMPLE new file mode 100755 --- /dev/null +++ b/grader-process-check.SAMPLE @@ -0,0 +1,9 @@ +#!/bin/bash +count=`ps aux | grep "algo_grader" | grep "grader grading queue" | wc -l` +install_dir=/home/john/cafe_grader +ruby_executable=/home/john/.rvm/wrappers/ruby-2.3.0/ruby +if [ $count -lt 1 ]; then + cd $judge_dir/judge + $ruby_executable $install_dir/judge/scripts/grader grading queue > $install_dir/judge/grading.log & +fi + diff --git a/lib/runner.rb b/lib/runner.rb --- a/lib/runner.rb +++ b/lib/runner.rb @@ -25,20 +25,24 @@ end def grade_problem(problem, options={}) + user_index = 0 + user_count = User.count User.find_each do |u| - puts "user: #{u.login}" + puts "user: #{u.login} (#{user_index}/#{user_count})" + user_index += 1 if options[:user_conditions]!=nil con_proc = options[:user_conditions] next if not con_proc.call(u) end if options[:all_sub] Submission.where(user_id: u.id,problem_id: problem.id).find_each do |sub| + next if options[:only_err] and sub.grader_comment != 'error during grading' @engine.grade(sub) end else last_sub = Submission.find_last_by_user_and_problem(u.id,problem.id) if last_sub!=nil - @engine.grade(last_sub) + @engine.grade(last_sub) unless options[:only_err] and last_sub.grader_comment != 'error during grading' end end end diff --git a/lib/submission_helper.rb b/lib/submission_helper.rb --- a/lib/submission_helper.rb +++ b/lib/submission_helper.rb @@ -140,7 +140,9 @@ #submission.grader_comment = 'FAILED: ' + comment submission.grader_comment = comment end - submission.compiler_message = result[:cmp_msg] or '' + + #very lazy trim the string + submission.compiler_message = result[:cmp_msg][0..60000] or '' if not @dry_run submission.save diff --git a/std-script/run b/std-script/run --- a/std-script/run +++ b/std-script/run @@ -91,7 +91,7 @@ # JAVA_OPTION = "-s set_robust_list -s futex -s clone -s getppid -s clone -s wait4 -p /usr/bin/ -p ./" -RUBY_OPTION = "-p /usr/lib64/ -p /usr/local/lib64/ -p /usr/local/lib/ -p /lib64/ -p /dev/urandom -p #{sandbox_dir}/#{program_name} -p #{sandbox_dir}/ -s set_robust_list -s sched_getaffinity -s clock_gettime -s sigaltstack -s pipe2 -s clone -s futex -s openat -s pipe" +RUBY_OPTION = "-p /usr/lib64/ -p /usr/local/lib64/ -p /usr/local/lib/ -p /lib64/ -p /dev/urandom -p #{sandbox_dir}/#{program_name} -p #{sandbox_dir}/ -s set_robust_list -s sched_getaffinity -s clock_gettime -s sigaltstack -s pipe2 -s clone -s futex -s openat -s pipe -s getrandom" PYTHON_OPTION = "-p /usr/lib64/ -p /usr/local/lib64/ -p /usr/local/lib/ -p /usr/bin/ -p /lib64/ -p /dev/urandom -p /usr/ -p #{sandbox_dir}/#{program_name} -p ./#{program_name} -p #{sandbox_dir}/#{source_name} -p /proc/sys/crypto/fips_enabled -p /proc/self/status -p /proc/mounts -p /var/lib/dpkg/status -s statfs -s set_robust_list -s openat -s sysinfo -s recvmsg -s connect -s socket -s sendto -s futex -s sigaltstack -s getrandom -E PYTHONNOUSERSITE=yes" PHP_OPTION = "-p /usr/lib64/ -p/lib64/ -p /usr/bin/ -p #{sandbox_dir}/#{program_name} -p ./#{program_name} -p /usr/share/ -s setfsuid -s setfsgid -s openat -s set_robust_list -s futex -s clone -s socket -s connect" HASKELL_OPTION = "-s set_robust_list -s clock_gettime -s sysinfo -s timer_create -s timer_settime -s futex -s timer_delete" @@ -109,11 +109,11 @@ when "ruby" run_command = "#{problem_home}/script/box -a 2 -f -T -t #{time_limit*=2} -m #{mem_limit} #{RUBY_OPTION} -i #{input_file_name} -o output.txt /usr/bin/ruby #{program_name} " when "python" - run_command = "#{problem_home}/script/box -a 2 -f -T -t #{time_limit*=2} -m #{[128 * 1024,mem_limit].max} #{PYTHON_OPTION} -i #{input_file_name} -o output.txt /usr/bin/python3 #{program_name} " + run_command = "#{problem_home}/script/box -a 2 -f -T -t #{time_limit*=2} -m #{[512 * 1024,mem_limit].max} #{PYTHON_OPTION} -i #{input_file_name} -o output.txt /usr/bin/python3 #{program_name} " when "haskell" run_command = "#{problem_home}/script/box -a 2 -f -T -t #{time_limit} -m #{[512 * 1024,mem_limit].max} #{HASKELL_OPTION} -i #{input_file_name} -o output.txt #{program_name} " when "php" - run_command = "#{problem_home}/script/box -a 2 -f -T -t #{time_limit*=2} -m #{[128 * 1024,mem_limit].max} #{PHP_OPTION} -i #{input_file_name} -o output.txt /usr/bin/php -A -d -A memory_limit=#{mem_limit}k -A #{program_name} " + run_command = "#{problem_home}/script/box -a 2 -f -T -t #{time_limit*=2} -m #{[512 * 1024,mem_limit].max} #{PHP_OPTION} -i #{input_file_name} -o output.txt /usr/bin/php -A -d -A memory_limit=#{mem_limit}k -A #{program_name} " else # for c++, pascal, we do the normal checking run_command = "#{problem_home}/script/box -a 2 -f -T -t #{time_limit} -m #{mem_limit} -i #{input_file_name} -o output.txt #{program_name} " end