Description:
- new install script
- add comment in grader chain
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
r254:8d92eda43960 - - 4 files changed: 48 inserted, 41 deleted
@@ -1,25 +1,10 | |||
|
1 | 1 | #!/bin/sh |
|
2 | 2 | |
|
3 | + #installation script for cafe-grader, for ubuntu 16.04 | |
|
4 | + | |
|
3 | 5 | echo "This script will install and configure Cafe grader." |
|
4 | 6 | |
|
5 |
- RUBY_VERSION=2. |
|
|
6 | - echo "This will install Ruby $RUBY_VERSION under RVM" | |
|
7 | - | |
|
8 | - echo "Installing required apts" | |
|
9 | - | |
|
10 | - sudo apt-get update | |
|
11 | - sudo apt-get install mysql-server mysql-client \ | |
|
12 | - g++ gcc apache2 libmysqlclient20 build-essential \ | |
|
13 | - git-core openssl libreadline6 libreadline6-dev \ | |
|
14 | - zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-dev \ | |
|
15 | - sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev \ | |
|
16 | - ncurses-dev automake libtool bison subversion \ | |
|
17 | - pkg-config curl nodejs unzip pyflakes ruby default-jdk \ | |
|
18 | - libmysqld-dev mercurial python-setuptools python-dev python3-numpy | |
|
19 | - | |
|
20 | - echo "Installing RVM" | |
|
21 | - curl -k -L https://get.rvm.io | bash -s stable | |
|
22 | - source ~/.rvm/scripts/rvm | |
|
7 | + RUBY_VERSION=2.3.7 | |
|
23 | 8 | |
|
24 | 9 | echo "Installing Ruby $RUBY_VERSION in RVM" |
|
25 | 10 | |
@@ -32,7 +17,7 | |||
|
32 | 17 | |
|
33 | 18 | mkdir cafe_grader |
|
34 | 19 | cd cafe_grader |
|
35 |
- git clone -q git://github.com/ |
|
|
20 | + git clone -q git://github.com/cafe-grader-team/cafe-grader-web.git web | |
|
36 | 21 | |
|
37 | 22 | echo "Configuring rails app" |
|
38 | 23 | |
@@ -132,6 +117,17 | |||
|
132 | 117 | |
|
133 | 118 | rake assets:precompile |
|
134 | 119 | |
|
120 | + echo "setup the secret file" | |
|
121 | + SECRET_A=`rake secret` | |
|
122 | + SECRET_B=`rake secret` | |
|
123 | + SECRET_C=`rake secret` | |
|
124 | + echo "development:" > config/secrets.yml | |
|
125 | + echo " secret_key_base: '$SECRET_A'" >> config/secrets.yml | |
|
126 | + echo "test:" >> config/secrets.yml | |
|
127 | + echo " secret_key_base: '$SECRET_B'" >> config/secrets.yml | |
|
128 | + echo "production:" >> config/secrets.yml | |
|
129 | + echo " secret_key_base: '$SECRET_C'" >> config/secrets.yml | |
|
130 | + | |
|
135 | 131 | echo "Intalling web interface complete..." |
|
136 | 132 | echo |
|
137 | 133 | echo "Fetching grader" |
@@ -140,7 +136,7 | |||
|
140 | 136 | |
|
141 | 137 | mkdir judge |
|
142 | 138 | cd judge |
|
143 |
- git clone -q git://github.com/ |
|
|
139 | + git clone -q git://github.com/cafe-grader-team/cafe-grader-judge-scripts.git scripts | |
|
144 | 140 | mkdir raw |
|
145 | 141 | mkdir ev-exam |
|
146 | 142 | mkdir ev |
@@ -9,7 +9,7 | |||
|
9 | 9 | # room_maker and reporter. |
|
10 | 10 | # |
|
11 | 11 | class Engine |
|
12 | - | |
|
12 | + | |
|
13 | 13 | attr_writer :room_maker |
|
14 | 14 | attr_writer :reporter |
|
15 | 15 | |
@@ -27,7 +27,7 | |||
|
27 | 27 | @room_maker = options[:room_maker] |
|
28 | 28 | @reporter = options[:reporter] |
|
29 | 29 | end |
|
30 | - | |
|
30 | + | |
|
31 | 31 | # takes a submission, asks room_maker to produce grading directories, |
|
32 | 32 | # calls grader scripts, and asks reporter to save the result |
|
33 | 33 | def grade(submission) |
@@ -77,17 +77,20 | |||
|
77 | 77 | raise "engine: No test data." |
|
78 | 78 | end |
|
79 | 79 | |
|
80 | + # copy the source script, using lock | |
|
80 | 81 | dinit = DirInit::Manager.new(problem_home) |
|
81 | 82 | |
|
83 | + # lock the directory and copy the scripts | |
|
82 | 84 | dinit.setup do |
|
83 | 85 | copy_log = copy_script(problem_home) |
|
84 | 86 | save_copy_log(problem_home,copy_log) |
|
85 | 87 | end |
|
86 | - | |
|
88 | + | |
|
87 | 89 | call_judge(problem_home,language,grading_dir,source_name) |
|
88 | 90 | |
|
89 | 91 | @reporter.report(submission,"#{grading_dir}/test-result") |
|
90 | 92 | |
|
93 | + # unlock the directory | |
|
91 | 94 | dinit.teardown do |
|
92 | 95 | copy_log = load_copy_log(problem_home) |
|
93 | 96 | clear_copy_log(problem_home) |
@@ -103,19 +106,21 | |||
|
103 | 106 | Dir.chdir(current_dir) # this is really important |
|
104 | 107 | end |
|
105 | 108 | end |
|
106 | - | |
|
109 | + | |
|
107 | 110 | protected |
|
108 | - | |
|
111 | + | |
|
109 | 112 | def talk(str) |
|
110 | 113 | if @config.talkative |
|
111 | 114 | puts str |
|
112 | 115 | end |
|
113 | 116 | end |
|
114 | 117 | |
|
118 | + #change directory to problem_home | |
|
119 | + #call the "judge" script | |
|
115 | 120 | def call_judge(problem_home,language,grading_dir,fname) |
|
116 | 121 | ENV['PROBLEM_HOME'] = problem_home |
|
117 | 122 | ENV['RUBYOPT'] = '' |
|
118 | - | |
|
123 | + | |
|
119 | 124 | talk grading_dir |
|
120 | 125 | Dir.chdir grading_dir |
|
121 | 126 | script_name = "#{problem_home}/script/judge" |
@@ -129,6 +134,9 | |||
|
129 | 134 | GRADER_ROOT + '/std-script' |
|
130 | 135 | end |
|
131 | 136 | |
|
137 | + #copy any script presented in std-script directory that is not in the problem_home | |
|
138 | + #this allow a problem setter to provide their own version for each script | |
|
139 | + #in case that they want to hack something | |
|
132 | 140 | def copy_script(problem_home) |
|
133 | 141 | script_dir = "#{problem_home}/script" |
|
134 | 142 | std_script_dir = get_std_script_dir |
@@ -136,7 +144,7 | |||
|
136 | 144 | raise "engine: std-script directory not found" if !FileTest.exist?(std_script_dir) |
|
137 | 145 | |
|
138 | 146 | scripts = Dir[std_script_dir + '/*'] |
|
139 | - | |
|
147 | + | |
|
140 | 148 | copied = [] |
|
141 | 149 | |
|
142 | 150 | scripts.each do |s| |
@@ -147,7 +155,7 | |||
|
147 | 155 | FileUtils.cp(s, "#{script_dir}", :preserve => true) |
|
148 | 156 | end |
|
149 | 157 | end |
|
150 | - | |
|
158 | + | |
|
151 | 159 | return copied |
|
152 | 160 | end |
|
153 | 161 | |
@@ -162,7 +170,7 | |||
|
162 | 170 | end |
|
163 | 171 | f.close |
|
164 | 172 | end |
|
165 | - | |
|
173 | + | |
|
166 | 174 | def load_copy_log(problem_home) |
|
167 | 175 | f = File.new(copy_log_filename(problem_home),"r") |
|
168 | 176 | log = [] |
@@ -24,6 +24,9 | |||
|
24 | 24 | return task |
|
25 | 25 | end |
|
26 | 26 | |
|
27 | + # grade a specified problem for the latest submission of each user | |
|
28 | + # optionally, on all submission when options[:all_sub] is set | |
|
29 | + # optionally, only submission that has error (use when the problem itself has some problem) | |
|
27 | 30 | def grade_problem(problem, options={}) |
|
28 | 31 | user_index = 0 |
|
29 | 32 | user_count = User.count |
@@ -4,17 +4,17 | |||
|
4 | 4 | def initialize |
|
5 | 5 | @config = Grader::Configuration.get_instance |
|
6 | 6 | end |
|
7 | - | |
|
7 | + | |
|
8 | 8 | def produce_grading_room(submission) |
|
9 | 9 | user = submission.user |
|
10 | 10 | problem = submission.problem |
|
11 | 11 | grading_room = "#{@config.user_result_dir}/" + |
|
12 | 12 | "#{user.login}/#{problem.name}/#{submission.id}" |
|
13 | - | |
|
13 | + | |
|
14 | 14 | FileUtils.mkdir_p(grading_room) |
|
15 | 15 | grading_room |
|
16 | 16 | end |
|
17 | - | |
|
17 | + | |
|
18 | 18 | def find_problem_home(submission) |
|
19 | 19 | problem = submission.problem |
|
20 | 20 | "#{@config.problems_dir}/#{problem.name}" |
@@ -30,7 +30,7 | |||
|
30 | 30 | def clean_up(submission) |
|
31 | 31 | end |
|
32 | 32 | end |
|
33 | - | |
|
33 | + | |
|
34 | 34 | class SubmissionReporter |
|
35 | 35 | def initialize(options={}) |
|
36 | 36 | options = {:dry_run => false, :result_collector => nil}.merge(options) |
@@ -38,7 +38,7 | |||
|
38 | 38 | @dry_run = options[:dry_run] |
|
39 | 39 | @result_collector = options[:result_collector] |
|
40 | 40 | end |
|
41 | - | |
|
41 | + | |
|
42 | 42 | def report(sub,test_result_dir) |
|
43 | 43 | result = read_result(test_result_dir) |
|
44 | 44 | if @result_collector |
@@ -47,7 +47,7 | |||
|
47 | 47 | end |
|
48 | 48 | save_result(sub,result) |
|
49 | 49 | end |
|
50 | - | |
|
50 | + | |
|
51 | 51 | def report_error(sub,msg) |
|
52 | 52 | save_result(sub,{:points => 0, |
|
53 | 53 | :comment => "Grading error: #{msg}" }) |
@@ -63,7 +63,7 | |||
|
63 | 63 | else |
|
64 | 64 | cmp_msg = "" |
|
65 | 65 | end |
|
66 | - | |
|
66 | + | |
|
67 | 67 | result_fname = "#{test_result_dir}/result" |
|
68 | 68 | comment_fname = "#{test_result_dir}/comment" |
|
69 | 69 | runstat_fname = "#{test_result_dir}/run_stat" |
@@ -77,7 +77,7 | |||
|
77 | 77 | result = 0 |
|
78 | 78 | comment = "error reading result file." |
|
79 | 79 | end |
|
80 | - | |
|
80 | + | |
|
81 | 81 | begin |
|
82 | 82 | comment_file = File.open(comment_fname) |
|
83 | 83 | comment += comment_file.readline.chomp |
@@ -114,7 +114,7 | |||
|
114 | 114 | end |
|
115 | 115 | end |
|
116 | 116 | end |
|
117 | - | |
|
117 | + | |
|
118 | 118 | def save_result(submission,result) |
|
119 | 119 | problem = submission.problem |
|
120 | 120 | submission.graded_at = Time.now.gmtime |
@@ -140,7 +140,7 | |||
|
140 | 140 | #submission.grader_comment = 'FAILED: ' + comment |
|
141 | 141 | submission.grader_comment = comment |
|
142 | 142 | end |
|
143 | - | |
|
143 | + | |
|
144 | 144 | #very lazy trim the string |
|
145 | 145 | submission.compiler_message = result[:cmp_msg][0..60000] or '' |
|
146 | 146 | |
@@ -148,7 +148,7 | |||
|
148 | 148 | submission.save |
|
149 | 149 | end |
|
150 | 150 | end |
|
151 | - | |
|
151 | + | |
|
152 | 152 | end |
|
153 | - | |
|
153 | + | |
|
154 | 154 | end |
You need to be logged in to leave comments.
Login now