girdle 0.0.6 → 0.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.markdown +1 -1
- data/lib/girdle.rb +2 -0
- data/lib/girdle/helpers.rb +14 -0
- data/lib/girdle/job.rb +80 -16
- data/lib/girdle/specification.rb +18 -1
- data/lib/girdle/task.rb +6 -5
- data/lib/girdle/version.rb +1 -1
- data/spec/girdle/helpers_spec.rb +20 -0
- data/spec/girdle/job_spec.rb +32 -18
- data/spec/girdle/specification_spec.rb +18 -2
- data/spec/girdle/task_spec.rb +1 -0
- metadata +21 -18
data/README.markdown
CHANGED
data/lib/girdle.rb
CHANGED
data/lib/girdle/job.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
module Girdle
|
2
2
|
|
3
3
|
class Job
|
4
|
+
extend Girdle::Helpers
|
4
5
|
|
5
6
|
attr_reader :name, :id
|
6
7
|
|
@@ -8,20 +9,70 @@ module Girdle
|
|
8
9
|
@id = id
|
9
10
|
end
|
10
11
|
|
11
|
-
def self.list
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
12
|
+
def self.list(options = {})
|
13
|
+
validate_options! [
|
14
|
+
:gid, # grid identifier
|
15
|
+
], options
|
16
|
+
|
17
|
+
options.merge!(job: 'list')
|
18
|
+
|
19
|
+
Girdle.run(options)['jobList']
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.submit(cmd, options = {})
|
23
|
+
validate_options! [
|
24
|
+
:gid, # grid identifier
|
25
|
+
:si, # standard in
|
26
|
+
:in, # in directory
|
27
|
+
:dids, # job identifiers
|
28
|
+
:email, # notification email
|
29
|
+
:art, # art path
|
30
|
+
:artid, # art identifier
|
31
|
+
:artequal, # art value (equal)
|
32
|
+
:artmin, # art value (min)
|
33
|
+
:artmax # art value (max)
|
34
|
+
], options
|
35
|
+
|
36
|
+
options.merge!(job: 'submit', cmd: cmd)
|
37
|
+
|
38
|
+
Girdle.run(options)['jobIdentifier']
|
39
|
+
end
|
40
|
+
|
41
|
+
def self.run(cmd, options = {})
|
42
|
+
validate_options! [
|
43
|
+
:gid, # grid identifier
|
44
|
+
:si, # standard in
|
45
|
+
:in, # in directory
|
46
|
+
:so, # standard out
|
47
|
+
:se, # standard error
|
48
|
+
:out, # out directory
|
49
|
+
:email, # notification email
|
50
|
+
:art, # art path
|
51
|
+
:artid, # art identifier
|
52
|
+
:artequal, # art value (equal)
|
53
|
+
:artmin, # art value (min)
|
54
|
+
:artmax # art value (max)
|
55
|
+
], options
|
56
|
+
|
57
|
+
options.merge!(job: 'run', cmd: cmd)
|
58
|
+
|
59
|
+
Girdle.run(options)
|
60
|
+
end
|
61
|
+
|
62
|
+
def self.batch(spec, options = {})
|
63
|
+
validate_options! [
|
64
|
+
:gid, # grid identifier
|
65
|
+
], options
|
66
|
+
|
67
|
+
options.merge!(job: 'batch')
|
68
|
+
|
69
|
+
if spec.respond_to?(:to_plist)
|
70
|
+
plist = spec.to_plist
|
71
|
+
else
|
72
|
+
plist = spec
|
73
|
+
end
|
74
|
+
|
75
|
+
Girdle.run_batch(plist, options)['jobIdentifier']
|
25
76
|
end
|
26
77
|
|
27
78
|
def attributes
|
@@ -68,8 +119,17 @@ module Girdle
|
|
68
119
|
attributes['undoneTaskCount'].to_i
|
69
120
|
end
|
70
121
|
|
71
|
-
def results
|
72
|
-
|
122
|
+
def results(options = {})
|
123
|
+
self.class.validate_options! [
|
124
|
+
:tid, # task identifier
|
125
|
+
:so, # standard out
|
126
|
+
:se, # standard error
|
127
|
+
:out # out directory
|
128
|
+
], options
|
129
|
+
|
130
|
+
options.merge!(job: 'results', id: id)
|
131
|
+
|
132
|
+
Girdle.run(options)
|
73
133
|
end
|
74
134
|
|
75
135
|
def specification
|
@@ -79,6 +139,10 @@ module Girdle
|
|
79
139
|
def log
|
80
140
|
Girdle.run(job: 'log', id: id)['jobLog']
|
81
141
|
end
|
142
|
+
|
143
|
+
def wait
|
144
|
+
Girdle.run(job: 'wait', id: id)['jobStatus']
|
145
|
+
end
|
82
146
|
|
83
147
|
def stop
|
84
148
|
Girdle.run(job: 'stop', id: id)
|
data/lib/girdle/specification.rb
CHANGED
@@ -2,12 +2,13 @@ module Girdle
|
|
2
2
|
|
3
3
|
class Specification
|
4
4
|
|
5
|
-
attr_accessor :name, :notification_email, :tasks
|
5
|
+
attr_accessor :name, :notification_email, :tasks, :depends_on
|
6
6
|
|
7
7
|
def initialize(options = {})
|
8
8
|
@name = options[:name]
|
9
9
|
@notification_email = options[:notification_email]
|
10
10
|
@tasks = options[:tasks] || []
|
11
|
+
@depends_on = options[:depends_on] || []
|
11
12
|
end
|
12
13
|
|
13
14
|
def to_plist
|
@@ -24,6 +25,15 @@ module Girdle
|
|
24
25
|
xml.string name
|
25
26
|
xml.key 'notificationEmail'
|
26
27
|
xml.string notification_email
|
28
|
+
xml.key 'schedulerParameters'
|
29
|
+
xml.dict do
|
30
|
+
xml.key 'dependsOnJobs'
|
31
|
+
xml.array do
|
32
|
+
depends_on.each do |dependency|
|
33
|
+
xml.string dependency
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
27
37
|
xml.key 'taskSpecifications'
|
28
38
|
xml.dict do
|
29
39
|
tasks.each do |task|
|
@@ -37,6 +47,13 @@ module Girdle
|
|
37
47
|
end
|
38
48
|
xml.key 'command'
|
39
49
|
xml.string task.command
|
50
|
+
xml.key 'environment'
|
51
|
+
xml.dict do
|
52
|
+
task.environment.each do |k,v|
|
53
|
+
xml.key k
|
54
|
+
xml.string v
|
55
|
+
end
|
56
|
+
end
|
40
57
|
xml.key 'dependsOnTasks'
|
41
58
|
xml.array do
|
42
59
|
task.depends_on.each do |dependency|
|
data/lib/girdle/task.rb
CHANGED
@@ -2,13 +2,14 @@ module Girdle
|
|
2
2
|
|
3
3
|
class Task
|
4
4
|
|
5
|
-
attr_reader :name, :command, :arguments, :depends_on
|
5
|
+
attr_reader :name, :command, :arguments, :depends_on, :environment
|
6
6
|
|
7
7
|
def initialize(options = {})
|
8
|
-
@name
|
9
|
-
@command
|
10
|
-
@arguments
|
11
|
-
@depends_on
|
8
|
+
@name = options[:name]
|
9
|
+
@command = options[:command]
|
10
|
+
@arguments = options[:arguments]
|
11
|
+
@depends_on = options[:depends_on] || []
|
12
|
+
@environment = options[:environment] || {}
|
12
13
|
end
|
13
14
|
|
14
15
|
end
|
data/lib/girdle/version.rb
CHANGED
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Girdle::Helpers do
|
4
|
+
|
5
|
+
describe '::validate_options!' do
|
6
|
+
|
7
|
+
before do
|
8
|
+
@valid_options = [:foo, :bar]
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'must validate valid options' do
|
12
|
+
Girdle::Helpers.validate_options!(@valid_options, foo: 'foo', bar: 'bar').must_equal true
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'must invalidate invalid options' do
|
16
|
+
Proc.new { Girdle::Helpers.validate_options!(@valid_options, ugh: 'ugh', foo: 'foo')}.must_raise ArgumentError
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
end
|
data/spec/girdle/job_spec.rb
CHANGED
@@ -22,25 +22,34 @@ describe Girdle::Job do
|
|
22
22
|
result.must_equal 'hello'
|
23
23
|
end
|
24
24
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
25
|
+
describe '::batch' do
|
26
|
+
|
27
|
+
before do
|
28
|
+
@plist = Girdle::Specification.new(
|
29
|
+
name: 'specification name',
|
30
|
+
notification_email: 'email@example.com',
|
31
|
+
tasks: [
|
32
|
+
Girdle::Task.new(
|
33
|
+
name: 'task name',
|
34
|
+
command: '/bin/echo',
|
35
|
+
arguments: ['hello'],
|
36
|
+
depends_on: ['another task']
|
37
|
+
)
|
38
|
+
]
|
39
|
+
)
|
40
|
+
end
|
41
|
+
|
42
|
+
it 'must submit batch file and return an id' do
|
43
|
+
Girdle.expects(:run_batch).
|
44
|
+
with(@plist.to_plist, job: 'batch').
|
45
|
+
returns('jobIdentifier' => '123')
|
46
|
+
id = Girdle::Job.batch(@plist)
|
47
|
+
id.must_equal '123'
|
48
|
+
end
|
49
|
+
|
43
50
|
end
|
51
|
+
|
52
|
+
|
44
53
|
end
|
45
54
|
|
46
55
|
it 'must retrieve list of jobs' do
|
@@ -147,6 +156,11 @@ describe Girdle::Job do
|
|
147
156
|
@job.log.must_equal []
|
148
157
|
end
|
149
158
|
|
159
|
+
it 'must wait synchronously until job state changes' do
|
160
|
+
Girdle.expects(:run).with(job: 'wait', id: 123).returns('jobStatus' => 'finished')
|
161
|
+
@job.wait.must_equal 'finished'
|
162
|
+
end
|
163
|
+
|
150
164
|
describe 'status' do
|
151
165
|
|
152
166
|
it 'must stop, but don\'t delete' do
|
@@ -11,9 +11,13 @@ describe Girdle::Specification do
|
|
11
11
|
name: 'task name',
|
12
12
|
command: '/bin/echo',
|
13
13
|
arguments: ['hello'],
|
14
|
-
depends_on: ['another task']
|
14
|
+
depends_on: ['another task'],
|
15
|
+
environment: {'MY_ENV_VARIABLE' => 'MY_VALUE'}
|
15
16
|
)
|
16
|
-
]
|
17
|
+
],
|
18
|
+
depends_on: [
|
19
|
+
'another specification name'
|
20
|
+
]
|
17
21
|
)
|
18
22
|
end
|
19
23
|
|
@@ -40,6 +44,13 @@ describe Girdle::Specification do
|
|
40
44
|
<string>specification name</string>
|
41
45
|
<key>notificationEmail</key>
|
42
46
|
<string>email@example.com</string>
|
47
|
+
<key>schedulerParameters</key>
|
48
|
+
<dict>
|
49
|
+
<key>dependsOnJobs</key>
|
50
|
+
<array>
|
51
|
+
<string>another specification name</string>
|
52
|
+
</array>
|
53
|
+
</dict>
|
43
54
|
<key>taskSpecifications</key>
|
44
55
|
<dict>
|
45
56
|
<key>task name</key>
|
@@ -50,6 +61,11 @@ describe Girdle::Specification do
|
|
50
61
|
</array>
|
51
62
|
<key>command</key>
|
52
63
|
<string>/bin/echo</string>
|
64
|
+
<key>environment</key>
|
65
|
+
<dict>
|
66
|
+
<key>MY_ENV_VARIABLE</key>
|
67
|
+
<string>MY_VALUE</string>
|
68
|
+
</dict>
|
53
69
|
<key>dependsOnTasks</key>
|
54
70
|
<array>
|
55
71
|
<string>another task</string>
|
data/spec/girdle/task_spec.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: girdle
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-08-
|
12
|
+
date: 2011-08-23 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
16
|
-
requirement: &
|
16
|
+
requirement: &70339972619540 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70339972619540
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: guard
|
27
|
-
requirement: &
|
27
|
+
requirement: &70339972619120 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70339972619120
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: guard-minitest
|
38
|
-
requirement: &
|
38
|
+
requirement: &70339975778240 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70339975778240
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: rb-fsevent
|
49
|
-
requirement: &
|
49
|
+
requirement: &70339975777820 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70339975777820
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: growl_notify
|
60
|
-
requirement: &
|
60
|
+
requirement: &70339975777400 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ! '>='
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: '0'
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *70339975777400
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: mocha
|
71
|
-
requirement: &
|
71
|
+
requirement: &70339975776980 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ! '>='
|
@@ -76,10 +76,10 @@ dependencies:
|
|
76
76
|
version: '0'
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *70339975776980
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
81
|
name: nokogiri
|
82
|
-
requirement: &
|
82
|
+
requirement: &70339975776560 !ruby/object:Gem::Requirement
|
83
83
|
none: false
|
84
84
|
requirements:
|
85
85
|
- - ! '>='
|
@@ -87,10 +87,10 @@ dependencies:
|
|
87
87
|
version: '0'
|
88
88
|
type: :runtime
|
89
89
|
prerelease: false
|
90
|
-
version_requirements: *
|
90
|
+
version_requirements: *70339975776560
|
91
91
|
- !ruby/object:Gem::Dependency
|
92
92
|
name: nokogiri-plist
|
93
|
-
requirement: &
|
93
|
+
requirement: &70339975776140 !ruby/object:Gem::Requirement
|
94
94
|
none: false
|
95
95
|
requirements:
|
96
96
|
- - ! '>='
|
@@ -98,7 +98,7 @@ dependencies:
|
|
98
98
|
version: '0'
|
99
99
|
type: :runtime
|
100
100
|
prerelease: false
|
101
|
-
version_requirements: *
|
101
|
+
version_requirements: *70339975776140
|
102
102
|
description: An Xgrid client
|
103
103
|
email:
|
104
104
|
- jamiehodge@me.com
|
@@ -115,12 +115,14 @@ files:
|
|
115
115
|
- lib/girdle.rb
|
116
116
|
- lib/girdle/controller.rb
|
117
117
|
- lib/girdle/grid.rb
|
118
|
+
- lib/girdle/helpers.rb
|
118
119
|
- lib/girdle/job.rb
|
119
120
|
- lib/girdle/specification.rb
|
120
121
|
- lib/girdle/task.rb
|
121
122
|
- lib/girdle/version.rb
|
122
123
|
- spec/girdle/controller_spec.rb
|
123
124
|
- spec/girdle/grid_spec.rb
|
125
|
+
- spec/girdle/helpers_spec.rb
|
124
126
|
- spec/girdle/job_spec.rb
|
125
127
|
- spec/girdle/specification_spec.rb
|
126
128
|
- spec/girdle/task_spec.rb
|
@@ -153,6 +155,7 @@ summary: A client for submitting and managing Xgrid jobs
|
|
153
155
|
test_files:
|
154
156
|
- spec/girdle/controller_spec.rb
|
155
157
|
- spec/girdle/grid_spec.rb
|
158
|
+
- spec/girdle/helpers_spec.rb
|
156
159
|
- spec/girdle/job_spec.rb
|
157
160
|
- spec/girdle/specification_spec.rb
|
158
161
|
- spec/girdle/task_spec.rb
|