manband 0.7.0 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
data/README CHANGED
@@ -108,6 +108,7 @@ Webband may use this gem, or use current files with same hierarchy
108
108
 
109
109
  ## History
110
110
 
111
+ 0.8: Add Interactive feature
111
112
  0.7:
112
113
  Add IF management
113
114
  Fix some message dispatching issues
@@ -0,0 +1,66 @@
1
+ require 'rubygems'
2
+ require 'yaml'
3
+ require 'optparse'
4
+ require 'amqp'
5
+ require 'json'
6
+ require 'logger'
7
+
8
+ $:.push File.expand_path("../lib")
9
+
10
+ require 'manband/flowconfig.rb'
11
+ require 'manband/util.rb'
12
+
13
+
14
+ # The program sends a message operation to the workflow control to ack a job.
15
+ # This program does not need database credentials but needs AMQP_URL set.
16
+ # Author: Olivier Sallou <olivier.sallou@irisa.fr>
17
+ # Copyright: 2012, IRISA
18
+
19
+
20
+ log = Logger.new(STDOUT)
21
+ log.level = Logger::INFO
22
+
23
+ options = {}
24
+
25
+ optparse = OptionParser.new do|opts|
26
+
27
+ # This displays the help screen, all programs are
28
+ # assumed to have this option.
29
+ opts.on( '-h', '--help', 'Display this screen' ) do
30
+ puts opts
31
+ exit
32
+ end
33
+
34
+ options[:workflow] = nil
35
+ opts.on( '-w', '--workflow ID', 'Id of the worflow') do |id|
36
+ options[:workflow] = id
37
+ end
38
+
39
+ options[:job] = nil
40
+ opts.on( '-j', '--job ID', 'Job id') do |id|
41
+ options[:job] = id
42
+ end
43
+
44
+ options[:instance] = 0
45
+ opts.on( '-i', '--instance ID', 'Job instance number, defaults to 0') do |id|
46
+ options[:instance] = id
47
+ end
48
+
49
+ options[:handler] = 'interactive'
50
+ opts.on( '-d', '--handler NAME', 'Handler name, defaults to interactive') do |id|
51
+ options[:handler] = id
52
+ end
53
+
54
+ end
55
+
56
+ optparse.parse!
57
+
58
+ if options[:workflow]==nil || options[:job]==nil
59
+ puts "Missing parameter!"
60
+ exit
61
+ end
62
+
63
+ msg = '{ "workflow" : "'+options[:workflow].to_s+'" , "id" : "'+options[:job].to_s+'", "handler" : "'+options[:handler].to_s+'", "instance" : "'+options[:instance].to_s+'" }'
64
+
65
+ Utils.publish('manband.master',{ "operation" => "finish", "msg" => msg })
66
+
@@ -28,7 +28,7 @@ require 'manband/store.rb'
28
28
  handler = Time.now.to_s
29
29
 
30
30
  log = Logger.new(STDOUT)
31
- log.level = Logger::DEBUG
31
+ log.level = Logger::INFO
32
32
 
33
33
  options = {}
34
34
 
@@ -30,7 +30,7 @@ require 'manband/job.rb'
30
30
  require 'manband/bandmanager.rb'
31
31
 
32
32
  log = Logger.new(STDOUT)
33
- log.level = Logger::DEBUG
33
+ log.level = Logger::INFO
34
34
 
35
35
 
36
36
  @@options = {}
@@ -164,7 +164,7 @@ EventMachine.run do
164
164
  if myjob.status == STATUS_SKIP
165
165
  doSkip = true
166
166
  end
167
- if msg["handler"]!=nil && myjob.handler != msg["handler"]
167
+ if msg["handler"]!=nil && myjob.handler != msg["handler"] && myjob.type!=INTERACTIVE_ACTOR
168
168
  log.debug "Finish received from a different handler "+myjob.handler+" vs "+msg["handler"]+", skipping message"
169
169
  else
170
170
  myjob.finish
@@ -13,7 +13,7 @@ require 'manband/flowconfig.rb'
13
13
  class BandManager
14
14
 
15
15
  @@log = Logger.new(STDOUT)
16
- @@log.level = Logger::DEBUG
16
+ @@log.level = Logger::INFO
17
17
 
18
18
 
19
19
  # Loads a workflow file
@@ -35,11 +35,14 @@ OP_CLEAN = "clean" # Delete work dirs of workflow
35
35
  OP_DESTROY = "destroy" # Delete workflow and its work dirs
36
36
  OP_STORE = "store" # Store result to S3
37
37
 
38
+ # Actors type are exclusive
38
39
  # Basic actor
39
40
  ACTOR = -1
40
41
  # If actor, i.e. ony one of the following jobs will be executed. Selected job match the exit code of the command. Type of the node will be set to selected output
41
42
  # WARNING: input of IF actors MUST NOT be a pattern matchng multiple files. The IF condition must be executed only once, not on a bunch of files.
42
43
  IF_ACTOR = -2
44
+ # Interactive actor: there is no automatic FINISH message. Command is executed and user/an other script will send a FINISH message when appropriate.
45
+ INTERACTIVE_ACTOR = -3
43
46
 
44
47
 
45
48
  # This class holds the base config
@@ -34,7 +34,7 @@ class Job
34
34
  end
35
35
 
36
36
  @@log = Logger.new(STDOUT)
37
- @@log.level = Logger::DEBUG
37
+ @@log.level = Logger::INFO
38
38
 
39
39
  @channel = nil
40
40
  @delivery_tag = nil
@@ -95,13 +95,17 @@ class Job
95
95
  jobmsg = '{ "workflow" : "'+@wid.to_s+'" , "node" : "'+@node+'", "id" : "'+@id.to_s+'", "handler" : "'+curhandler.to_s+'", "instance" : "'+instance.to_s+'" }'
96
96
  sendmessage(OP_ERROR,jobmsg)
97
97
  else
98
- if curjob.store == STORE_DO || curjob.store == STORE_ERROR
99
- workflow = WorkFlow.get(curjob.wid)
100
- jobmsg = '{ "id" : "'+curjob.id.to_s+'", "bucket" : "'+workflow.bucket+'" }'
101
- sendmessage(OP_STORE,jobmsg)
98
+ if @type == INTERACTIVE_ACTOR
99
+ @@log.debug "Interactive job, job will take in charge the answer and storage"
100
+ else
101
+ if curjob.store == STORE_DO || curjob.store == STORE_ERROR
102
+ workflow = WorkFlow.get(curjob.wid)
103
+ jobmsg = '{ "id" : "'+curjob.id.to_s+'", "bucket" : "'+workflow.bucket+'" }'
104
+ sendmessage(OP_STORE,jobmsg)
105
+ end
106
+ jobmsg = '{ "workflow" : "'+@wid.to_s+'" , "node" : "'+@node+'", "id" : "'+@id.to_s+'", "handler" : "'+curhandler.to_s+'", "instance" : "'+instance.to_s+'" }'
107
+ sendmessage(OP_FINISH,jobmsg)
102
108
  end
103
- jobmsg = '{ "workflow" : "'+@wid.to_s+'" , "node" : "'+@node+'", "id" : "'+@id.to_s+'", "handler" : "'+curhandler.to_s+'", "instance" : "'+instance.to_s+'" }'
104
- sendmessage(OP_FINISH,jobmsg)
105
109
  end
106
110
  ack()
107
111
  end # End EventMachine
@@ -120,7 +124,7 @@ class Job
120
124
  # wordir: job working directory
121
125
  # instance: instance number in the list of commands
122
126
  def runcommand(workdir,instance)
123
- initcmd = "AMQP_URL="" && MYSQL_URL="" && mkdir -p "+workdir+" && cd "+workdir+" && WORKDIR="+workdir+" && "
127
+ initcmd = "AMQP_URL='' && MYSQL_URL='' && WID="+@wid.to_s+" && JID="+@id.to_s+" && INSTANCE="+instance.to_s+" && mkdir -p "+workdir+" && cd "+workdir+" && WORKDIR="+workdir+" && "
124
128
  curjob = Job.get(@id)
125
129
  command = JSON.parse(curjob.command)
126
130
  if command.length > 1
@@ -19,7 +19,7 @@ class WorkFlow
19
19
  include DataMapper::Resource
20
20
 
21
21
  @@log = Logger.new(STDOUT)
22
- @@log.level = Logger::DEBUG
22
+ @@log.level = Logger::INFO
23
23
 
24
24
  property :id, Serial # An auto-increment integer key
25
25
  property :uid, Text # user id
@@ -113,6 +113,9 @@ class WorkFlow
113
113
  if fworkflow["workflow"][job]["type"]=='if'
114
114
  type = IF_ACTOR
115
115
  end
116
+ if fworkflow["workflow"][job]["type"]=='interactive'
117
+ type = INTERACTIVE_ACTOR
118
+ end
116
119
  workdir = FlowConfig.getjobdir(@workdir)
117
120
  if curnode == "root"
118
121
  workdir = self.workdir + "/root";
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: manband
3
3
  version: !ruby/object:Gem::Version
4
- hash: 3
4
+ hash: 63
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 7
8
+ - 8
9
9
  - 0
10
- version: 0.7.0
10
+ version: 0.8.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Olivier Sallou
@@ -126,6 +126,7 @@ extra_rdoc_files:
126
126
  - LICENSE
127
127
  files:
128
128
  - bin/env.sh
129
+ - bin/ackband.rb
129
130
  - bin/manband.rb
130
131
  - bin/remoteband.rb
131
132
  - bin/jobhandler.rb