coursemology-evaluator 0.1.4 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +23 -0
- data/coursemology-evaluator.gemspec +2 -1
- data/lib/coursemology/evaluator.rb +2 -0
- data/lib/coursemology/evaluator/cli.rb +23 -1
- data/lib/coursemology/evaluator/client.rb +1 -1
- data/lib/coursemology/evaluator/docker_container.rb +3 -2
- data/lib/coursemology/evaluator/version.rb +1 -1
- metadata +19 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 81bd30cc5392032f6b0baaf8314278f48b3ae384
|
4
|
+
data.tar.gz: 135910bce96d87502a3c4b1bf80729ae35b1187a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5460c5ea63f1857fa0a294a35130283e6aa3a6f76278734db13741921e881ff3cdcbae85791cf42b03596eafc8c9fe26f52329a5743e483379bdbbaee50f8366
|
7
|
+
data.tar.gz: 5db7643a681aa5e17a2c5a2a81ea7fa0ca8c7720c3498115b109a4f73a5637645c200b2a87f345fd25bcb5b433f095f348c67d407ecb0f5799417d5eed85cb08
|
data/README.md
CHANGED
@@ -27,3 +27,26 @@ This is the evaluator program which will query Coursemology for pending evaluati
|
|
27
27
|
|
28
28
|
3. Start the evaluator using the Procfile. You can use [foreman](https://github.com/ddollar/foreman)
|
29
29
|
or any similar tool to generate system scripts for boot.
|
30
|
+
|
31
|
+
### Command Line Options
|
32
|
+
|
33
|
+
#### Compulsory Options
|
34
|
+
|
35
|
+
1. `--host`: Coursemology host to connect to
|
36
|
+
2. `--api-user-email`: User with autograder flag set
|
37
|
+
3. `--api-token`: Authentication token of the user
|
38
|
+
|
39
|
+
#### Optional Options
|
40
|
+
|
41
|
+
Time options are expected to be strings in [ISO8601 format](https://en.wikipedia.org/wiki/ISO_8601#Durations).
|
42
|
+
|
43
|
+
1. `--interval`: Time interval between checks for programming allocations. As this time is
|
44
|
+
expected to be short, specify it with the time components of ISO8601 only. (Hours, minutes, seconds)
|
45
|
+
The time designator `T` must be left out.
|
46
|
+
|
47
|
+
2. `--lifetime`: Length of time to cache Docker images. This is expected to be in the order of days.
|
48
|
+
If more granularity is needed, the time designator is required.
|
49
|
+
|
50
|
+
E.g. `1DT2H5M10S`
|
51
|
+
|
52
|
+
3. `--one-shot`: Runs once and terminates. Primarily used for testing.
|
@@ -28,10 +28,11 @@ Gem::Specification.new do |spec|
|
|
28
28
|
spec.add_development_dependency 'vcr'
|
29
29
|
|
30
30
|
spec.add_dependency 'activesupport', '~> 4.2.0', '>= 4.2.2'
|
31
|
+
spec.add_dependency 'iso8601', '~> 0.9.1'
|
31
32
|
spec.add_dependency 'flexirest', '~> 1.2', '>= 1.2.6'
|
32
33
|
spec.add_dependency 'faraday_middleware'
|
33
34
|
|
34
35
|
spec.add_dependency 'coursemology-polyglot', '>= 0.0.3'
|
35
|
-
spec.add_dependency 'docker-api', '>= 1.
|
36
|
+
spec.add_dependency 'docker-api', '>= 1.29.1'
|
36
37
|
spec.add_dependency 'rubyzip'
|
37
38
|
end
|
@@ -9,9 +9,11 @@ Docker.validate_version!
|
|
9
9
|
require 'coursemology/polyglot'
|
10
10
|
require 'coursemology/polyglot/extensions'
|
11
11
|
require 'coursemology/evaluator/version'
|
12
|
+
require 'iso8601'
|
12
13
|
|
13
14
|
module Coursemology::Evaluator
|
14
15
|
extend ActiveSupport::Autoload
|
16
|
+
include ActiveSupport::Configurable
|
15
17
|
|
16
18
|
autoload :Client
|
17
19
|
autoload :DockerContainer
|
@@ -2,7 +2,8 @@
|
|
2
2
|
require 'optparse'
|
3
3
|
|
4
4
|
class Coursemology::Evaluator::CLI
|
5
|
-
Options = Struct.new(:host, :api_token, :api_user_email,
|
5
|
+
Options = Struct.new(:host, :api_token, :api_user_email,
|
6
|
+
:one_shot, :poll_interval, :image_lifetime)
|
6
7
|
|
7
8
|
def self.start(argv)
|
8
9
|
new.start(argv)
|
@@ -14,6 +15,13 @@ class Coursemology::Evaluator::CLI
|
|
14
15
|
|
15
16
|
def run(argv)
|
16
17
|
options = optparse!(argv)
|
18
|
+
Coursemology::Evaluator.config.poll_interval =
|
19
|
+
::ISO8601::Duration.new("PT#{options.poll_interval}".upcase).to_seconds
|
20
|
+
|
21
|
+
# Must include the time designator T if hours/minutes/seconds are required.
|
22
|
+
Coursemology::Evaluator.config.image_lifetime =
|
23
|
+
::ISO8601::Duration.new("P#{options.image_lifetime}".upcase).to_seconds
|
24
|
+
|
17
25
|
Coursemology::Evaluator::Client.initialize(options.host, options.api_user_email,
|
18
26
|
options.api_token)
|
19
27
|
Coursemology::Evaluator::Client.new(options.one_shot).run
|
@@ -27,6 +35,12 @@ class Coursemology::Evaluator::CLI
|
|
27
35
|
# @return [Coursemology::Evaluator::CLI::Options]
|
28
36
|
def optparse!(argv) # rubocop:disable Metrics/MethodLength
|
29
37
|
options = Options.new
|
38
|
+
|
39
|
+
# default options for optional parameters
|
40
|
+
options.poll_interval = '10S'
|
41
|
+
options.image_lifetime = '1D'
|
42
|
+
options.one_shot = false
|
43
|
+
|
30
44
|
option_parser = OptionParser.new do |parser|
|
31
45
|
parser.banner = "Usage: #{parser.program_name} [options]"
|
32
46
|
parser.on('-hHOST', '--host=HOST', 'Coursemology host to connect to') do |host|
|
@@ -41,6 +55,14 @@ class Coursemology::Evaluator::CLI
|
|
41
55
|
options.api_user_email = user
|
42
56
|
end
|
43
57
|
|
58
|
+
parser.on('-iINTERVAL', '--interval=INTERVAL') do |interval|
|
59
|
+
options.poll_interval = interval
|
60
|
+
end
|
61
|
+
|
62
|
+
parser.on('-lLIFETIME', '--lifetime=LIFETIME') do |lifetime|
|
63
|
+
options.image_lifetime = lifetime
|
64
|
+
end
|
65
|
+
|
44
66
|
parser.on('-o', '--one-shot') do
|
45
67
|
options.one_shot = true
|
46
68
|
end
|
@@ -31,7 +31,7 @@ class Coursemology::Evaluator::Client
|
|
31
31
|
# :nocov:
|
32
32
|
# This sleep might not be triggered in the specs, because interruptions to the thread is
|
33
33
|
# nondeterministically run by the OS scheduler.
|
34
|
-
sleep(
|
34
|
+
sleep(Coursemology::Evaluator.config.poll_interval)
|
35
35
|
# :nocov:
|
36
36
|
end
|
37
37
|
|
@@ -17,13 +17,14 @@ class Coursemology::Evaluator::DockerContainer < Docker::Container
|
|
17
17
|
|
18
18
|
# Pulls the given image from Docker Hub.
|
19
19
|
#
|
20
|
-
# This caches images for
|
20
|
+
# This caches images for the specified time, because the overhead for querying
|
21
|
+
# for images is quite high.
|
21
22
|
#
|
22
23
|
# @param [String] image The image to pull.
|
23
24
|
def pull_image(image)
|
24
25
|
ActiveSupport::Notifications.instrument('pull.docker.evaluator.coursemology',
|
25
26
|
image: image) do |payload|
|
26
|
-
cached([:image, image], expires_in:
|
27
|
+
cached([:image, image], expires_in: Coursemology::Evaluator.config.image_lifetime) do
|
27
28
|
Docker::Image.create('fromImage' => image)
|
28
29
|
payload[:cached] = false
|
29
30
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: coursemology-evaluator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joel Low
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-08-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -142,6 +142,20 @@ dependencies:
|
|
142
142
|
- - ">="
|
143
143
|
- !ruby/object:Gem::Version
|
144
144
|
version: 4.2.2
|
145
|
+
- !ruby/object:Gem::Dependency
|
146
|
+
name: iso8601
|
147
|
+
requirement: !ruby/object:Gem::Requirement
|
148
|
+
requirements:
|
149
|
+
- - "~>"
|
150
|
+
- !ruby/object:Gem::Version
|
151
|
+
version: 0.9.1
|
152
|
+
type: :runtime
|
153
|
+
prerelease: false
|
154
|
+
version_requirements: !ruby/object:Gem::Requirement
|
155
|
+
requirements:
|
156
|
+
- - "~>"
|
157
|
+
- !ruby/object:Gem::Version
|
158
|
+
version: 0.9.1
|
145
159
|
- !ruby/object:Gem::Dependency
|
146
160
|
name: flexirest
|
147
161
|
requirement: !ruby/object:Gem::Requirement
|
@@ -196,14 +210,14 @@ dependencies:
|
|
196
210
|
requirements:
|
197
211
|
- - ">="
|
198
212
|
- !ruby/object:Gem::Version
|
199
|
-
version: 1.
|
213
|
+
version: 1.29.1
|
200
214
|
type: :runtime
|
201
215
|
prerelease: false
|
202
216
|
version_requirements: !ruby/object:Gem::Requirement
|
203
217
|
requirements:
|
204
218
|
- - ">="
|
205
219
|
- !ruby/object:Gem::Version
|
206
|
-
version: 1.
|
220
|
+
version: 1.29.1
|
207
221
|
- !ruby/object:Gem::Dependency
|
208
222
|
name: rubyzip
|
209
223
|
requirement: !ruby/object:Gem::Requirement
|
@@ -278,7 +292,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
278
292
|
version: '0'
|
279
293
|
requirements: []
|
280
294
|
rubyforge_project:
|
281
|
-
rubygems_version: 2.
|
295
|
+
rubygems_version: 2.6.6
|
282
296
|
signing_key:
|
283
297
|
specification_version: 4
|
284
298
|
summary: Coursemology programming package evaluator
|