peplum 0.3.1 → 0.3.3
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 +4 -4
- data/lib/peplum/application/worker.rb +19 -0
- data/lib/peplum/application.rb +38 -25
- data/lib/peplum/version.rb +1 -1
- data/peplum.gemspec +4 -2
- metadata +8 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3568df5f67778e52d60fdadfc43365b8a73560ee2a7a432d7f00f911d1b54c74
|
4
|
+
data.tar.gz: 4b72178fc2b3b948a76e04fe86b039b3cd545b3c857b21fdfbe8698d8e8ee094
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 65f7fe80859499e249207f9d88d3d68701959b4511b0d8c0470c4d61a78b25dc5734fcf7b63e45001bbfe9323ed2b657dc2bea934a597d19a25833e5fd71b67e
|
7
|
+
data.tar.gz: 1c74b1a6cf7df7b9db5daf1fc76190f55bc0c45f6acc242667cf2a29a769d00b209369c36dd105996b150148ea6fe5aa65e8b38fd24dd16f337a0610cde3554d
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Peplum
|
2
|
+
class Application
|
3
|
+
|
4
|
+
module Worker
|
5
|
+
|
6
|
+
# @return [Cuboid::RPC::Server::Instance::Peers]
|
7
|
+
attr_reader :peers
|
8
|
+
|
9
|
+
# @return [Cuboid::RPC::Client::Instance, NilClass]
|
10
|
+
attr_reader :scheduler
|
11
|
+
|
12
|
+
def peers
|
13
|
+
@peers ||= Cuboid::RPC::Server::Instance::Peers.new
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
data/lib/peplum/application.rb
CHANGED
@@ -4,60 +4,53 @@ require 'peplum'
|
|
4
4
|
|
5
5
|
module Peplum
|
6
6
|
class Application < Cuboid::Application
|
7
|
+
require 'peplum/application/worker'
|
7
8
|
require 'peplum/application/payload'
|
8
9
|
|
9
10
|
require 'peplum/application/services/shared_hash'
|
10
11
|
require 'peplum/application/services/scheduler'
|
11
12
|
|
12
|
-
class Error < Peplum::Error
|
13
|
+
class Error < Peplum::Error
|
14
|
+
class PayloadMissing < Error
|
15
|
+
end
|
16
|
+
end
|
13
17
|
|
18
|
+
# Hijack Cuboid to set ourselves up.
|
14
19
|
class <<self
|
15
20
|
def inherited( application )
|
16
21
|
super
|
17
22
|
|
23
|
+
# Don't trust Cuboid's auto-detection for this, make sure the inheriting class is the Cuboid application.
|
18
24
|
Cuboid::Application.application = application
|
19
25
|
|
20
26
|
application.validate_options_with :validate_options
|
21
|
-
application.serialize_with JSON
|
22
27
|
|
23
28
|
application.instance_service_for :scheduler, Services::Scheduler
|
29
|
+
|
30
|
+
# Shared, in-memory key-value store for the workers, the scheduler will not be participate.
|
24
31
|
application.instance_service_for :shared_hash, Services::SharedHash
|
25
32
|
end
|
26
33
|
end
|
27
34
|
|
28
|
-
# @return [Cuboid::RPC::Server::Instance::Peers]
|
29
|
-
attr_reader :peers
|
30
|
-
|
31
|
-
# @return [Cuboid::RPC::Client::Instance]
|
32
|
-
attr_reader :master
|
33
|
-
|
34
|
-
def initialize(*)
|
35
|
-
super
|
36
|
-
|
37
|
-
@peers = Cuboid::RPC::Server::Instance::Peers.new
|
38
|
-
end
|
39
|
-
|
40
35
|
def run
|
41
36
|
options = @options.dup
|
37
|
+
|
38
|
+
# System options.
|
42
39
|
peplum_options = options.delete( 'peplum' )
|
40
|
+
|
41
|
+
# Payload options.
|
43
42
|
payload_options = options.delete( 'payload' )
|
44
43
|
|
45
|
-
# We have a master so we're
|
44
|
+
# We have a master so we're a worker, run the payload.
|
46
45
|
if peplum_options['master']
|
47
|
-
|
46
|
+
work( peplum_options, payload_options )
|
48
47
|
|
49
|
-
# We're the scheduler Instance, get to grouping and spawning.
|
48
|
+
# We're the scheduler Instance, get to grouping objects and spawning workers.
|
50
49
|
else
|
51
50
|
schedule( peplum_options, payload_options )
|
52
51
|
end
|
53
52
|
end
|
54
53
|
|
55
|
-
# @return [TrueClass, FalseClass] Are we a worker Instance?
|
56
|
-
def worker?
|
57
|
-
# Has a master?
|
58
|
-
!!@master
|
59
|
-
end
|
60
|
-
|
61
54
|
# @return [#run, #split, #merge]
|
62
55
|
#
|
63
56
|
# * `#run` -- Worker; executes its payload against `objects`.
|
@@ -68,23 +61,32 @@ module Peplum
|
|
68
61
|
#
|
69
62
|
# @abstract
|
70
63
|
def payload
|
71
|
-
fail Error, 'Missing #payload!'
|
64
|
+
fail Error::PayloadMissing, 'Missing #payload implementation!'
|
72
65
|
end
|
73
66
|
|
67
|
+
# Overload {Cuboid#report} and delegate to the {Payload.merge} prior passing it on to {Cuboid}.
|
68
|
+
# @private
|
74
69
|
def report( data )
|
75
70
|
super payload.merge( data )
|
76
71
|
end
|
77
72
|
|
78
73
|
private
|
79
74
|
|
80
|
-
def
|
75
|
+
def work( peplum_options, payload_options )
|
76
|
+
# We're now a worker class!
|
77
|
+
self.class.include Worker
|
78
|
+
|
81
79
|
master_info = peplum_options.delete( 'master' )
|
82
80
|
@master = Processes::Instances.connect( master_info['url'], master_info['token'] )
|
83
81
|
|
82
|
+
# Configure us to know the rest of our worker peers.
|
83
|
+
# Required for the SharedHash service.
|
84
84
|
self.peers.set( peplum_options.delete( 'peers' ) || {} )
|
85
85
|
|
86
|
+
# Deliver the payload.
|
86
87
|
report_data = payload.run( peplum_options['objects'], payload_options )
|
87
88
|
|
89
|
+
# Signal that we're done by passing our report to the scheduler.
|
88
90
|
@master.scheduler.report report_data, Cuboid::Options.rpc.url
|
89
91
|
end
|
90
92
|
|
@@ -153,9 +155,20 @@ module Peplum
|
|
153
155
|
fail Error, 'Options: Missing :max_workers'
|
154
156
|
end
|
155
157
|
|
158
|
+
validate_payload
|
159
|
+
|
156
160
|
@options = options
|
157
161
|
true
|
158
162
|
end
|
159
163
|
|
164
|
+
def validate_payload
|
165
|
+
p = self.payload
|
166
|
+
|
167
|
+
%w(run merge split).each do |m|
|
168
|
+
next if p.respond_to? m
|
169
|
+
fail Payload::Error::ImplementationMissing, "#{payload} missing implementation for: ##{m}"
|
170
|
+
end
|
171
|
+
end
|
172
|
+
|
160
173
|
end
|
161
174
|
end
|
data/lib/peplum/version.rb
CHANGED
data/peplum.gemspec
CHANGED
@@ -9,8 +9,10 @@ Gem::Specification.new do |spec|
|
|
9
9
|
spec.email = ["tasos.laskos@gmail.com"]
|
10
10
|
|
11
11
|
spec.summary = "Distributed parallel computing made easy."
|
12
|
-
spec.description =
|
13
|
-
|
12
|
+
spec.description = <<EOTXT
|
13
|
+
Peplum allows you to easily combine the resources of multiple machines and build a Beowulf (or otherwise) cluster/super-computer.
|
14
|
+
EOTXT
|
15
|
+
spec.homepage = "https://github.com/peplum/peplum"
|
14
16
|
spec.required_ruby_version = ">= 2.6.0"
|
15
17
|
|
16
18
|
spec.files = Dir.glob( 'bin/*')
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: peplum
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tasos Laskos
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-05-
|
11
|
+
date: 2023-05-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: cuboid
|
@@ -24,7 +24,10 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
|
-
description:
|
27
|
+
description: 'Peplum allows you to easily combine the resources of multiple machines
|
28
|
+
and build a Beowulf (or otherwise) cluster/super-computer.
|
29
|
+
|
30
|
+
'
|
28
31
|
email:
|
29
32
|
- tasos.laskos@gmail.com
|
30
33
|
executables: []
|
@@ -37,10 +40,11 @@ files:
|
|
37
40
|
- lib/peplum/application/payload.rb
|
38
41
|
- lib/peplum/application/services/scheduler.rb
|
39
42
|
- lib/peplum/application/services/shared_hash.rb
|
43
|
+
- lib/peplum/application/worker.rb
|
40
44
|
- lib/peplum/core_ext/array.rb
|
41
45
|
- lib/peplum/version.rb
|
42
46
|
- peplum.gemspec
|
43
|
-
homepage:
|
47
|
+
homepage: https://github.com/peplum/peplum
|
44
48
|
licenses: []
|
45
49
|
metadata: {}
|
46
50
|
post_install_message:
|