Description:
add task queue access control, grader status
git-svn-id: http://theory.cpe.ku.ac.th/grader/cli/trunk/scripts@58 6386c4cd-e34a-4fa8-8920-d93eb39b512e
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
r20:4c69afce24c0 - - 3 files changed: 31 inserted, 6 deleted
@@ -2,12 +2,15 | |||||
|
2 | PROBLEMS_DIR = "/home/jittat/grader/ev" |
|
2 | PROBLEMS_DIR = "/home/jittat/grader/ev" |
|
3 |
|
3 | ||
|
4 | USER_RESULT_DIR = "/home/jittat/grader/result" |
|
4 | USER_RESULT_DIR = "/home/jittat/grader/result" |
|
5 |
|
5 | ||
|
6 | TALKATIVE = true |
|
6 | TALKATIVE = true |
|
7 |
|
7 | ||
|
|
8 | + REPORT_GRADER = true | ||
|
|
9 | + GRADER_IP_ADDRESS = '158.108.111.111' | ||
|
|
10 | + | ||
|
8 | def report_comment(comment) |
|
11 | def report_comment(comment) |
|
9 | if comment.chomp =~ /^P+$/ # all P's |
|
12 | if comment.chomp =~ /^P+$/ # all P's |
|
10 | 'passed' |
|
13 | 'passed' |
|
11 | else |
|
14 | else |
|
12 | 'failed' |
|
15 | 'failed' |
|
13 | end |
|
16 | end |
@@ -2,9 +2,12 | |||||
|
2 | PROBLEMS_DIR = "/home/jittat/grader/ev" |
|
2 | PROBLEMS_DIR = "/home/jittat/grader/ev" |
|
3 |
|
3 | ||
|
4 | USER_RESULT_DIR = "/home/jittat/grader/result" |
|
4 | USER_RESULT_DIR = "/home/jittat/grader/result" |
|
5 |
|
5 | ||
|
6 | TALKATIVE = true |
|
6 | TALKATIVE = true |
|
7 |
|
7 | ||
|
|
8 | + REPORT_GRADER = true | ||
|
|
9 | + GRADER_IP_ADDRESS = '158.108.111.111' | ||
|
|
10 | + | ||
|
8 | def report_comment(comment) |
|
11 | def report_comment(comment) |
|
9 | comment.chomp |
|
12 | comment.chomp |
|
10 | end |
|
13 | end |
@@ -108,13 +108,13 | |||||
|
108 | language = 'c++' |
|
108 | language = 'c++' |
|
109 | end |
|
109 | end |
|
110 |
|
110 | ||
|
111 | user_dir = "#{USER_RESULT_DIR}/#{user.login}" |
|
111 | user_dir = "#{USER_RESULT_DIR}/#{user.login}" |
|
112 | Dir.mkdir(user_dir) if !FileTest.exist?(user_dir) |
|
112 | Dir.mkdir(user_dir) if !FileTest.exist?(user_dir) |
|
113 |
|
113 | ||
|
114 | - problem_out_dir = "#{user_dir}/#{problem.name}" |
|
114 | + problem_out_dir = "#{user_dir}/#{problem.name}/#{submission_id}" |
|
115 | Dir.mkdir(problem_out_dir) if !FileTest.exist?(problem_out_dir) |
|
115 | Dir.mkdir(problem_out_dir) if !FileTest.exist?(problem_out_dir) |
|
116 |
|
116 | ||
|
117 | problem_home = "#{PROBLEMS_DIR}/#{problem.name}" |
|
117 | problem_home = "#{PROBLEMS_DIR}/#{problem.name}" |
|
118 | source_name = "#{problem.name}.#{lang_ext}" |
|
118 | source_name = "#{problem.name}.#{lang_ext}" |
|
119 |
|
119 | ||
|
120 | save_source(sub,problem_out_dir,source_name) |
|
120 | save_source(sub,problem_out_dir,source_name) |
@@ -168,38 +168,56 | |||||
|
168 | GRADER_ENV = 'exam' |
|
168 | GRADER_ENV = 'exam' |
|
169 | end |
|
169 | end |
|
170 |
|
170 | ||
|
171 | puts "environment: #{GRADER_ENV}" |
|
171 | puts "environment: #{GRADER_ENV}" |
|
172 | require File.dirname(__FILE__) + "/environment.rb" |
|
172 | require File.dirname(__FILE__) + "/environment.rb" |
|
173 |
|
173 | ||
|
174 | - #main program |
|
174 | + #reading rails environment |
|
175 | talk 'Reading rails environment' |
|
175 | talk 'Reading rails environment' |
|
176 |
|
176 | ||
|
177 | RAILS_ENV = 'development' |
|
177 | RAILS_ENV = 'development' |
|
178 | require RAILS_APP_DIR + '/config/environment' |
|
178 | require RAILS_APP_DIR + '/config/environment' |
|
179 |
|
179 | ||
|
|
180 | + #register grader process | ||
|
|
181 | + if REPORT_GRADER | ||
|
|
182 | + grader_proc = GraderProcess.register(GRADER_IP_ADDRESS, | ||
|
|
183 | + Process.pid, | ||
|
|
184 | + grader_mode) | ||
|
|
185 | + else | ||
|
|
186 | + grader_proc = nil | ||
|
|
187 | + end | ||
|
|
188 | + | ||
|
180 | case grader_mode |
|
189 | case grader_mode |
|
181 | when "queue" |
|
190 | when "queue" |
|
182 | talk 'Grader queue' |
|
191 | talk 'Grader queue' |
|
183 | while true |
|
192 | while true |
|
|
193 | + | ||
|
184 | if check_stopfile # created by calling grader stop |
|
194 | if check_stopfile # created by calling grader stop |
|
185 | clear_stopfile |
|
195 | clear_stopfile |
|
186 | puts "stopped" |
|
196 | puts "stopped" |
|
|
197 | + grader_proc.report_inactive if grader_proc!=nil | ||
|
187 | exit(0) |
|
198 | exit(0) |
|
188 | end |
|
199 | end |
|
189 |
|
200 | ||
|
190 | - task = Task.find(:first, :order => 'created_at') |
|
201 | + task = Task.get_inqueue_and_change_status(Task::STATUS_GRADING) |
|
191 | if task!=nil |
|
202 | if task!=nil |
|
|
203 | + grader_proc.report_active(task) if grader_proc!=nil | ||
|
|
204 | + | ||
|
192 | grade(task.submission_id) |
|
205 | grade(task.submission_id) |
|
193 |
- task. |
|
206 | + task.status_complete |
|
194 | else |
|
207 | else |
|
195 | - sleep(1) |
|
208 | + #grader_proc.report_active if grader_proc!=nil |
|
|
209 | + | ||
|
|
210 | + sleep(5) | ||
|
196 | end |
|
211 | end |
|
197 | end |
|
212 | end |
|
198 |
|
213 | ||
|
199 | when "prob" |
|
214 | when "prob" |
|
|
215 | + | ||
|
|
216 | + grader_proc.report_active if grader_proc!=nil | ||
|
|
217 | + | ||
|
200 | prob = Problem.find_by_name(ARGV[2]) |
|
218 | prob = Problem.find_by_name(ARGV[2]) |
|
201 | if prob==nil |
|
219 | if prob==nil |
|
202 | puts "cannot find problem: #{ARGV[2]}" |
|
220 | puts "cannot find problem: #{ARGV[2]}" |
|
203 | exit(0) |
|
221 | exit(0) |
|
204 | end |
|
222 | end |
|
205 | users = User.find(:all) |
|
223 | users = User.find(:all) |
@@ -212,10 +230,11 | |||||
|
212 | if last_sub!=nil |
|
230 | if last_sub!=nil |
|
213 | grade(last_sub.id) |
|
231 | grade(last_sub.id) |
|
214 | end |
|
232 | end |
|
215 | end |
|
233 | end |
|
216 | end |
|
234 | end |
|
217 |
|
235 | ||
|
218 | - |
|
236 | + # report inactive |
|
|
237 | + grader_proc.report_inactive if grader_proc!=nil | ||
|
219 |
|
238 | ||
|
220 |
|
239 | ||
|
221 |
|
240 |
You need to be logged in to leave comments.
Login now