Class: Girdle::Job

Inherits:
Object
  • Object
show all
Extended by:
Helpers
Defined in:
lib/girdle/job.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Helpers

validate_options!

Constructor Details

#initialize(id) ⇒ Job

Returns a new instance of Job.



8
9
10
# File 'lib/girdle/job.rb', line 8

def initialize(id)
  @id = id
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



6
7
8
# File 'lib/girdle/job.rb', line 6

def id
  @id
end

#nameObject (readonly)

Returns the value of attribute name.



6
7
8
# File 'lib/girdle/job.rb', line 6

def name
  @name
end

Class Method Details

.batch(spec, options = {}) ⇒ Object



62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/girdle/job.rb', line 62

def self.batch(spec, options = {})
  validate_options! [
    :gid,       # grid identifier
    ], options
    
  options.merge!(job: 'batch')
  
  if spec.respond_to?(:to_plist)
    plist = spec.to_plist
  else
    plist = spec
  end
    
  Girdle.run_batch(plist, options)['jobIdentifier']
end

.list(options = {}) ⇒ Object



12
13
14
15
16
17
18
19
20
# File 'lib/girdle/job.rb', line 12

def self.list(options = {})
  validate_options! [
    :gid,       # grid identifier
    ], options
    
  options.merge!(job: 'list')
  
  Girdle.run(options)['jobList']
end

.run(cmd, options = {}) ⇒ Object



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/girdle/job.rb', line 41

def self.run(cmd, options = {})
  validate_options! [
    :gid,       # grid identifier 
    :si,        # standard in
    :in,        # in directory
    :so,        # standard out
    :se,        # standard error
    :out,       # out directory
    :email,     # notification email
    :art,       # art path
    :artid,     # art identifier
    :artequal,  # art value (equal)
    :artmin,    # art value (min)
    :artmax     # art value (max)
    ], options
    
  options.merge!(job: 'run', cmd: cmd)
    
  Girdle.run(options)
end

.submit(cmd, options = {}) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/girdle/job.rb', line 22

def self.submit(cmd, options = {})
  validate_options! [
    :gid,       # grid identifier 
    :si,        # standard in
    :in,        # in directory
    :dids,      # job identifiers
    :email,     # notification email
    :art,       # art path
    :artid,     # art identifier
    :artequal,  # art value (equal)
    :artmin,    # art value (min)
    :artmax     # art value (max)
    ], options
    
  options.merge!(job: 'submit', cmd: cmd)
    
  Girdle.run(options)['jobIdentifier']
end

Instance Method Details

#active_cpu_powerObject



87
88
89
# File 'lib/girdle/job.rb', line 87

def active_cpu_power
  attributes['activeCPUPower'].to_i
end

#attributesObject



78
79
80
# File 'lib/girdle/job.rb', line 78

def attributes
  @attributes ||= Girdle.run(job: 'attributes', id: id)['jobAttributes']
end

#attributes!Object



82
83
84
85
# File 'lib/girdle/job.rb', line 82

def attributes!
  @attributes = nil
  attributes
end

#date_nowObject



91
92
93
# File 'lib/girdle/job.rb', line 91

def date_now
  attributes['dateNow']
end

#date_startedObject



95
96
97
# File 'lib/girdle/job.rb', line 95

def date_started
  attributes['dateStarted']
end

#date_stoppedObject



99
100
101
# File 'lib/girdle/job.rb', line 99

def date_stopped
  attributes['dateStopped']
end

#date_submittedObject



103
104
105
# File 'lib/girdle/job.rb', line 103

def 
  attributes['dateSubmitted']
end

#deleteObject



165
166
167
# File 'lib/girdle/job.rb', line 165

def delete
  Girdle.run(job: 'delete', id: id)
end

#logObject



144
145
146
147
# File 'lib/girdle/job.rb', line 144

def log
  Girdle.run(job: 'log', id: id)['jobLog'].
    map {|log| Girdle::LogEntry.new(log) }
end

#percent_doneObject



115
116
117
# File 'lib/girdle/job.rb', line 115

def percent_done
  attributes['percentDone']
end

#restartObject



169
170
171
# File 'lib/girdle/job.rb', line 169

def restart
  Girdle.run(job: 'restart', id: id)
end

#results(options = {}) ⇒ Object



127
128
129
130
131
132
133
134
135
136
137
138
# File 'lib/girdle/job.rb', line 127

def results(options = {})
  self.class.validate_options! [
    :tid,       # task identifier
    :so,        # standard out
    :se,        # standard error
    :out        # out directory
    ], options
    
  options.merge!(job: 'results', id: id)
    
  Girdle.run_redirect(options).gsub /^$\n/, ''
end

#resumeObject



161
162
163
# File 'lib/girdle/job.rb', line 161

def resume
  Girdle.run(job: 'resume', id: id)
end

#specificationObject



140
141
142
# File 'lib/girdle/job.rb', line 140

def specification
  Girdle.run(job: 'specification', id: id)['jobSpecification']
end

#statusObject



107
108
109
# File 'lib/girdle/job.rb', line 107

def status
  attributes['jobStatus'].downcase.to_sym
end

#stopObject



153
154
155
# File 'lib/girdle/job.rb', line 153

def stop
  Girdle.run(job: 'stop', id: id)
end

#suspendObject



157
158
159
# File 'lib/girdle/job.rb', line 157

def suspend
  Girdle.run(job: 'suspend', id: id)
end

#task_countObject



119
120
121
# File 'lib/girdle/job.rb', line 119

def task_count
  attributes['taskCount'].to_i
end

#undone_task_countObject



123
124
125
# File 'lib/girdle/job.rb', line 123

def undone_task_count
  attributes['undoneTaskCount'].to_i
end

#waitObject



149
150
151
# File 'lib/girdle/job.rb', line 149

def wait
  Girdle.run(job: 'wait', id: id)['jobStatus']
end