pampa 2.1.5 → 2.1.6

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4e863bdb28e3b9204917ef6d94111490ce37f024859474b3914f6ec1d5b48e63
4
- data.tar.gz: ef3c4d42b5338a4eebed3fe94e2ca6fe7390ad2aa3839a60295b5e4702db0c8d
3
+ metadata.gz: 7e1c0e0a3790132d9206240aa5e2fa6fc72a0351787545a7f1376877e7e34035
4
+ data.tar.gz: b37cecd9ddef0bf689cc549ec6d2b32de547f2e1ac447de6d7cea03a6d51b747
5
5
  SHA512:
6
- metadata.gz: a773609dbf576aa1ffc9b40454053cf4e47c873fe28b8893d0e671ec097448a43660b10e2713ac28a8aabd7d26aa55d8ccca024138a3143ff7a853ac5a1aaff9
7
- data.tar.gz: 67410b752e36055057b956bb6719b66caa7e0afe1e223ca0ad64f05619fe4b48d4f5be2e357271e985e52103ba619b5ce776551d8c8936e04d1016f610e2a7ed
6
+ metadata.gz: 80cf1da9de12e2be82cfe2644a00ed9021b8ce29804fc9cb298152c58e6291759149fb99f8c64f01e02cef216de69ccc479f49c268f81b6a5963e7a4612c14b1
7
+ data.tar.gz: 1746698f66f620573187c2a7501790f3ab99b4b7faba9cf602033e42b0fa84e389f3e095e81a842a6a3e3d8a2f64581d347a13f9eaf51e260844c6fa2fd6a054
data/lib/pampa/app.rb CHANGED
@@ -41,7 +41,7 @@ PARSER = BlackStack::SimpleCommandLineParser.new(
41
41
  )
42
42
 
43
43
  # create logger
44
- l = PARSER.value('log') ? BlackStack::LocalLogger.new('app.log') : BlackStack::BaseLogger.new(nil)
44
+ l = PARSER.value('log') ? BlackStack::LocalLogger.new('app.log') : BlackStack::DummyLogger.new(nil)
45
45
 
46
46
  #
47
47
  # load config file
@@ -40,7 +40,7 @@ PARSER = BlackStack::SimpleCommandLineParser.new(
40
40
  )
41
41
 
42
42
  # create logger
43
- l = PARSER.value('log') ? BlackStack::LocalLogger.new('dispatcher.log') : BlackStack::BaseLogger.new(nil)
43
+ l = PARSER.value('log') ? BlackStack::LocalLogger.new('dispatcher.log') : BlackStack::DummyLogger.new(nil)
44
44
 
45
45
  # assign logger to pampa
46
46
  BlackStack::Pampa.set_logger(l)
data/lib/pampa/worker.rb CHANGED
@@ -46,7 +46,7 @@ PARSER = BlackStack::SimpleCommandLineParser.new(
46
46
  )
47
47
 
48
48
  # create logger
49
- l = PARSER.value('log') ? BlackStack::LocalLogger.new("worker.#{PARSER.value('id')}.log") : BlackStack::BaseLogger.new(nil)
49
+ l = PARSER.value('log') ? BlackStack::LocalLogger.new("worker.#{PARSER.value('id')}.log") : BlackStack::DummyLogger.new(nil)
50
50
 
51
51
  # assign logger to pampa
52
52
  BlackStack::Pampa.set_logger(l)
data/lib/pampa.rb CHANGED
@@ -99,6 +99,10 @@ module BlackStack
99
99
  # get the job this worker is working with
100
100
  BlackStack::Pampa.jobs.each { |job|
101
101
  l.logs "job #{job.name}... "
102
+ l.logs("Gettting assigned workers... ")
103
+ assigned = BlackStack::Pampa.workers.select { |worker| worker.attached && worker.assigned_job.to_s == job.name.to_s }
104
+ l.logf "done ".green + " (#{assigned.size.to_s.blue})"
105
+
102
106
  # get attached and unassigned workers
103
107
  l.logs "Getting attached and unassigned workers... "
104
108
  workers = BlackStack::Pampa.workers.select { |w| w.attached && w.assigned_job.nil? }
@@ -107,68 +111,62 @@ module BlackStack
107
111
  l.logs "Getting workers that match the filter... "
108
112
  workers = workers.select { |w| w.id =~ job.filter_worker_id }
109
113
  l.logf "done".green + " (#{workers.size.to_s.blue})"
110
- # if theere are workers
111
- if workers.size > 0
112
- l.logs("Gettting assigned workers... ")
113
- assigned = BlackStack::Pampa.workers.select { |worker| worker.attached && worker.assigned_job.to_s == job.name.to_s }
114
- l.logf "done ".green + " (#{assigned.size.to_s.blue})"
115
-
116
- l.logs("Getting total pending (pending) tasks... ")
117
- pendings = job.pending
118
- l.logf "done".green + " (#{pendings.to_s.blue})"
119
-
120
- l.logs("0 pending tasks?.... ")
121
- if pendings.size == 0
114
+
115
+ l.logs("Getting total pending tasks... ")
116
+ pending_tasks = job.pending.to_i
117
+ l.logf "done".green + " (#{pending_tasks.to_s.blue})"
118
+
119
+ l.logs("0 pending tasks?.... ")
120
+ if pending_tasks == 0
121
+ l.logf "yes".green
122
+
123
+ l.logs("Unassigning all assigned workers... ")
124
+ assigned.each { |w|
125
+ l.logs("Unassigning worker... ")
126
+ w.assigned_job = nil
127
+ workers << w # add worker back to the list of unassigned
128
+ l.logf "done".green + " (#{w.id.to_s.blue})"
129
+ }
130
+ l.logf 'done'.green
131
+ else
132
+ l.logf "no".red
133
+
134
+ l.logs("Under :max_pending_tasks (#{job.max_pending_tasks}) and more than 1 assigned workers ?... ")
135
+ if pending_tasks < job.max_pending_tasks && assigned.size > 1
122
136
  l.logf "yes".green
123
137
 
124
- l.logs("Unassigning all assigned workers... ")
125
- assigned.each { |w|
138
+ while assigned.size > 1
126
139
  l.logs("Unassigning worker... ")
140
+ w = assigned.pop # TODO: find a worker with no pending tasks
127
141
  w.assigned_job = nil
128
- workers << w # add worker back to the list of unassigned
142
+ workers << w # add worker back to the array of unassigned workers
129
143
  l.logf "done".green + " (#{w.id.to_s.blue})"
130
- }
131
- l.logf 'done'.green
144
+ end
132
145
  else
133
146
  l.logf "no".red
134
147
 
135
- l.logs("Under :max_pending_tasks (#{job.max_pending_tasks}) and more than 1 assigned workers ?... ")
136
- if pendings.size < job.max_pending_tasks && assigned.size > 1
137
- l.logf "yes".green
138
-
139
- while assigned.size > 1
140
- l.logs("Unassigning worker... ")
141
- w = assigned.pop # TODO: find a worker with no pending tasks
142
- w.assigned_job = nil
143
- workers << w # add worker back to the array of unassigned workers
144
- l.logf "done".green + " (#{w.id.to_s.blue})"
145
- end
148
+ l.logs("Over :max_assigned_workers (#{job.max_assigned_workers.to_s.blue}) and more than 1 assigned workers?... ")
149
+ if assigned.size >= job.max_assigned_workers && assigned.size > 1
150
+ l.logf("yes".green)
146
151
  else
147
- l.logf "no".red
148
-
149
- l.logs("Over :max_assigned_workers (#{job.max_assigned_workers.to_s.blue}) and more than 1 assigned workers?... ")
150
- if assigned.size >= job.max_assigned_workers && assigned.size > 1
151
- l.logf("yes".green)
152
- else
153
- l.logf("no".red)
154
-
155
- i = assigned.size
156
- while i < job.max_assigned_workers
157
- i += 1
158
- l.logs("Assigning worker... ")
159
- w = workers.pop
160
- if w.nil?
161
- l.logf("no more workers".yellow)
162
- break
163
- else
164
- w.assigned_job = job.name.to_sym
165
- l.logf "done".green + " (#{w.id.to_s.blue})"
166
- end
167
- end # while i < job.max_assigned_workers
168
- end # if assigned.size >= job.max_assigned_workers && assigned.size > 0
169
- end # if pendings.size < job.max_pending_tasks && assigned.size > 1
170
- end # if pendings.size == 0
171
- end # if workers.size > 0
152
+ l.logf("no".red)
153
+
154
+ i = assigned.size
155
+ while i < job.max_assigned_workers
156
+ i += 1
157
+ l.logs("Assigning worker... ")
158
+ w = workers.pop
159
+ if w.nil?
160
+ l.logf("no more workers".yellow)
161
+ break
162
+ else
163
+ w.assigned_job = job.name.to_sym
164
+ l.logf "done".green + " (#{w.id.to_s.blue})"
165
+ end
166
+ end # while i < job.max_assigned_workers
167
+ end # if assigned.size >= job.max_assigned_workers && assigned.size > 0
168
+ end # if pending_tasks < job.max_pending_tasks && assigned.size > 1
169
+ end # if pending_tasks == 0
172
170
  l.logf 'done'.green
173
171
  }
174
172
  end # def self.stretch()
@@ -223,7 +221,7 @@ module BlackStack
223
221
  # get the job this worker is assigned to
224
222
  job = BlackStack::Pampa.jobs.select { |j| j.name.to_s == worker.assigned_job.to_s }.first
225
223
  if job.nil?
226
- l.logf("job #{job.name} not found".red)
224
+ l.logf("job #{worker.assigned_job} not found".red)
227
225
  else
228
226
  l.logf("done".green + " (#{job.run_dispatch(worker).to_s.blue})")
229
227
  end
data/pampa.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'pampa'
3
- s.version = '2.1.5'
3
+ s.version = '2.1.6'
4
4
  s.date = '2024-08-03'
5
5
  s.summary = "Ruby library for async & distributed computing, supporting dynamic reconfiguration, distribution of the computation jobs, error handling, job-retry and fault tolerance, and fast (non-direct) communication to ensure real-time capabilities."
6
6
  s.description = "Pampa is a Ruby library for async & distributing computing providing the following features:
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pampa
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.5
4
+ version: 2.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Leandro Daniel Sardi