scout-gear 10.7.4 → 10.7.5
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/.gitmodules +0 -4
- data/.vimproject +2 -14
- data/Rakefile +1 -4
- data/VERSION +1 -1
- data/lib/scout/association/index.rb +1 -1
- data/lib/scout/entity/identifiers.rb +5 -2
- data/lib/scout/entity/property.rb +1 -1
- data/lib/scout/tsv/change_id/translate.rb +8 -2
- data/lib/scout/tsv/open.rb +2 -0
- data/lib/scout/workflow/entity.rb +99 -0
- data/lib/scout/workflow/export.rb +66 -0
- data/lib/scout/workflow/step/file.rb +3 -3
- data/lib/scout/workflow/step/info.rb +5 -0
- data/lib/scout/workflow/step/provenance.rb +1 -2
- data/lib/scout/workflow/step/status.rb +1 -0
- data/lib/scout/workflow/step.rb +5 -3
- data/lib/scout/workflow/task/inputs.rb +2 -1
- data/lib/scout/workflow.rb +4 -2
- data/lib/scout-gear.rb +5 -1
- data/scout-gear.gemspec +7 -18
- data/test/scout/workflow/task/test_dependencies.rb +7 -7
- data/test/scout/workflow/test_definition.rb +2 -2
- data/test/scout/workflow/test_entity.rb +58 -0
- data/test/scout/workflow/test_step.rb +1 -1
- metadata +7 -57
- data/lib/scout/offsite/exceptions.rb +0 -9
- data/lib/scout/offsite/ssh.rb +0 -175
- data/lib/scout/offsite/step.rb +0 -100
- data/lib/scout/offsite/sync.rb +0 -55
- data/lib/scout/offsite.rb +0 -3
- data/scout_commands/offsite +0 -30
- data/test/scout/offsite/test_ssh.rb +0 -15
- data/test/scout/offsite/test_step.rb +0 -32
- data/test/scout/offsite/test_sync.rb +0 -36
- data/test/scout/offsite/test_task.rb +0 -0
- data/test/scout/test_offsite.rb +0 -0
@@ -0,0 +1,58 @@
|
|
1
|
+
require File.expand_path(__FILE__).sub(%r(/test/.*), '/test/test_helper.rb')
|
2
|
+
require File.expand_path(__FILE__).sub(%r(.*/test/), '').sub(/test_(.*)\.rb/,'\1')
|
3
|
+
|
4
|
+
class TestWorkflowEntity < Test::Unit::TestCase
|
5
|
+
def get_EWF
|
6
|
+
@m ||= Module.new do
|
7
|
+
extend EntityWorkflow
|
8
|
+
|
9
|
+
self.name = 'TestEWF'
|
10
|
+
|
11
|
+
property :introduction do
|
12
|
+
"Mi name is #{self}"
|
13
|
+
end
|
14
|
+
|
15
|
+
entity_job hi: :string do
|
16
|
+
"Hi. #{entity.introduction}"
|
17
|
+
end
|
18
|
+
|
19
|
+
list_job group_hi: :string do
|
20
|
+
"Here is the group: " + entity_list.hi * "; "
|
21
|
+
end
|
22
|
+
|
23
|
+
list_job bye: :array do
|
24
|
+
entity_list.collect do |e|
|
25
|
+
"Bye from #{e}"
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_property_job
|
32
|
+
ewf = get_EWF
|
33
|
+
|
34
|
+
e = ewf.setup("Miki")
|
35
|
+
|
36
|
+
assert_equal "Mi name is Miki", e.introduction
|
37
|
+
assert_equal "Hi. Mi name is Miki", e.hi
|
38
|
+
end
|
39
|
+
|
40
|
+
def test_list
|
41
|
+
ewf = get_EWF
|
42
|
+
|
43
|
+
l = ewf.setup(["Miki", "Clei"])
|
44
|
+
|
45
|
+
assert_equal 2, l.hi.length
|
46
|
+
|
47
|
+
assert_include l.group_hi, "group: "
|
48
|
+
end
|
49
|
+
|
50
|
+
def test_multiple
|
51
|
+
ewf = get_EWF
|
52
|
+
|
53
|
+
l = ewf.setup(["Miki", "Clei"])
|
54
|
+
|
55
|
+
assert_equal 2, l.bye.length
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
@@ -387,7 +387,7 @@ class TestWorkflowStep < Test::Unit::TestCase
|
|
387
387
|
step1.fork(false, sem)
|
388
388
|
step2.fork(false, sem)
|
389
389
|
sleep 1
|
390
|
-
assert((step1.status == :queue) || (step2.status == :queue))
|
390
|
+
assert((step1.status.to_sym == :queue) || (step2.status.to_sym == :queue))
|
391
391
|
step1.join
|
392
392
|
step2.join
|
393
393
|
assert_equal "done2", step2.run
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: scout-gear
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 10.7.
|
4
|
+
version: 10.7.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Miguel Vazquez
|
8
8
|
bindir: bin
|
9
9
|
cert_chain: []
|
10
|
-
date: 2025-03-
|
10
|
+
date: 2025-03-19 00:00:00.000000000 Z
|
11
11
|
dependencies:
|
12
12
|
- !ruby/object:Gem::Dependency
|
13
13
|
name: scout-essentials
|
@@ -65,34 +65,6 @@ dependencies:
|
|
65
65
|
- - ">="
|
66
66
|
- !ruby/object:Gem::Version
|
67
67
|
version: '0'
|
68
|
-
- !ruby/object:Gem::Dependency
|
69
|
-
name: rdoc
|
70
|
-
requirement: !ruby/object:Gem::Requirement
|
71
|
-
requirements:
|
72
|
-
- - "~>"
|
73
|
-
- !ruby/object:Gem::Version
|
74
|
-
version: '3.12'
|
75
|
-
type: :development
|
76
|
-
prerelease: false
|
77
|
-
version_requirements: !ruby/object:Gem::Requirement
|
78
|
-
requirements:
|
79
|
-
- - "~>"
|
80
|
-
- !ruby/object:Gem::Version
|
81
|
-
version: '3.12'
|
82
|
-
- !ruby/object:Gem::Dependency
|
83
|
-
name: bundler
|
84
|
-
requirement: !ruby/object:Gem::Requirement
|
85
|
-
requirements:
|
86
|
-
- - "~>"
|
87
|
-
- !ruby/object:Gem::Version
|
88
|
-
version: '1.0'
|
89
|
-
type: :development
|
90
|
-
prerelease: false
|
91
|
-
version_requirements: !ruby/object:Gem::Requirement
|
92
|
-
requirements:
|
93
|
-
- - "~>"
|
94
|
-
- !ruby/object:Gem::Version
|
95
|
-
version: '1.0'
|
96
68
|
- !ruby/object:Gem::Dependency
|
97
69
|
name: juwelier
|
98
70
|
requirement: !ruby/object:Gem::Requirement
|
@@ -107,22 +79,8 @@ dependencies:
|
|
107
79
|
- - "~>"
|
108
80
|
- !ruby/object:Gem::Version
|
109
81
|
version: 2.1.0
|
110
|
-
|
111
|
-
|
112
|
-
requirement: !ruby/object:Gem::Requirement
|
113
|
-
requirements:
|
114
|
-
- - ">="
|
115
|
-
- !ruby/object:Gem::Version
|
116
|
-
version: '0'
|
117
|
-
type: :development
|
118
|
-
prerelease: false
|
119
|
-
version_requirements: !ruby/object:Gem::Requirement
|
120
|
-
requirements:
|
121
|
-
- - ">="
|
122
|
-
- !ruby/object:Gem::Version
|
123
|
-
version: '0'
|
124
|
-
description: Temporary files, logs, path, resources, persistence, workflows, TSV,
|
125
|
-
etc.
|
82
|
+
description: 'Scout gear: workflow, TSVs, persistence, entities, associations, and
|
83
|
+
knowledge_bases.'
|
126
84
|
email: mikisvaz@gmail.com
|
127
85
|
executables:
|
128
86
|
- scout
|
@@ -162,11 +120,6 @@ files:
|
|
162
120
|
- lib/scout/knowledge_base/query.rb
|
163
121
|
- lib/scout/knowledge_base/registry.rb
|
164
122
|
- lib/scout/knowledge_base/traverse.rb
|
165
|
-
- lib/scout/offsite.rb
|
166
|
-
- lib/scout/offsite/exceptions.rb
|
167
|
-
- lib/scout/offsite/ssh.rb
|
168
|
-
- lib/scout/offsite/step.rb
|
169
|
-
- lib/scout/offsite/sync.rb
|
170
123
|
- lib/scout/persist/engine.rb
|
171
124
|
- lib/scout/persist/engine/fix_width_table.rb
|
172
125
|
- lib/scout/persist/engine/packed_index.rb
|
@@ -216,7 +169,9 @@ files:
|
|
216
169
|
- lib/scout/workflow/deployment/orchestrator.rb
|
217
170
|
- lib/scout/workflow/deployment/trace.rb
|
218
171
|
- lib/scout/workflow/documentation.rb
|
172
|
+
- lib/scout/workflow/entity.rb
|
219
173
|
- lib/scout/workflow/exceptions.rb
|
174
|
+
- lib/scout/workflow/export.rb
|
220
175
|
- lib/scout/workflow/path.rb
|
221
176
|
- lib/scout/workflow/step.rb
|
222
177
|
- lib/scout/workflow/step/archive.rb
|
@@ -252,7 +207,6 @@ files:
|
|
252
207
|
- scout_commands/kb/show
|
253
208
|
- scout_commands/kb/traverse
|
254
209
|
- scout_commands/log
|
255
|
-
- scout_commands/offsite
|
256
210
|
- scout_commands/rbbt
|
257
211
|
- scout_commands/resource/produce
|
258
212
|
- scout_commands/template
|
@@ -287,10 +241,6 @@ files:
|
|
287
241
|
- test/scout/knowledge_base/test_query.rb
|
288
242
|
- test/scout/knowledge_base/test_registry.rb
|
289
243
|
- test/scout/knowledge_base/test_traverse.rb
|
290
|
-
- test/scout/offsite/test_ssh.rb
|
291
|
-
- test/scout/offsite/test_step.rb
|
292
|
-
- test/scout/offsite/test_sync.rb
|
293
|
-
- test/scout/offsite/test_task.rb
|
294
244
|
- test/scout/persist/engine/test_fix_width_table.rb
|
295
245
|
- test/scout/persist/engine/test_packed_index.rb
|
296
246
|
- test/scout/persist/engine/test_sharder.rb
|
@@ -308,7 +258,6 @@ files:
|
|
308
258
|
- test/scout/test_association.rb
|
309
259
|
- test/scout/test_entity.rb
|
310
260
|
- test/scout/test_knowledge_base.rb
|
311
|
-
- test/scout/test_offsite.rb
|
312
261
|
- test/scout/test_semaphore.rb
|
313
262
|
- test/scout/test_tsv.rb
|
314
263
|
- test/scout/test_work_queue.rb
|
@@ -351,6 +300,7 @@ files:
|
|
351
300
|
- test/scout/workflow/task/test_inputs.rb
|
352
301
|
- test/scout/workflow/test_definition.rb
|
353
302
|
- test/scout/workflow/test_documentation.rb
|
303
|
+
- test/scout/workflow/test_entity.rb
|
354
304
|
- test/scout/workflow/test_path.rb
|
355
305
|
- test/scout/workflow/test_step.rb
|
356
306
|
- test/scout/workflow/test_task.rb
|
data/lib/scout/offsite/ssh.rb
DELETED
@@ -1,175 +0,0 @@
|
|
1
|
-
require 'net/ssh'
|
2
|
-
require_relative 'exceptions'
|
3
|
-
|
4
|
-
class SSHLine
|
5
|
-
class << self
|
6
|
-
attr_accessor :default_server
|
7
|
-
def default_server
|
8
|
-
@@default_server ||= begin
|
9
|
-
ENV["SCOUT_OFFSITE"] || ENV["SCOUT_SERVER"] || 'localhost'
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
def initialize(host = :default, user = nil)
|
15
|
-
host = SSHLine.default_server if host.nil? || host == :default
|
16
|
-
@host = host
|
17
|
-
@user = user
|
18
|
-
|
19
|
-
@ssh = Net::SSH.start(@host, @user)
|
20
|
-
|
21
|
-
@ch = @ssh.open_channel do |ch|
|
22
|
-
ch.exec 'bash -l'
|
23
|
-
end
|
24
|
-
|
25
|
-
@ch.send_data("[[ -f ~/.scout/environment ]] && source ~/.scout/environment\n")
|
26
|
-
@ch.send_data("[[ -f ~/.rbbt/environment ]] && source ~/.rbbt/environment\n")
|
27
|
-
|
28
|
-
@ch.on_data do |_,data|
|
29
|
-
if m = data.match(/DONECMD: (\d+)\n/)
|
30
|
-
@exit_status = m[1].to_i
|
31
|
-
@output << data.sub(m[0],'')
|
32
|
-
serve_output
|
33
|
-
else
|
34
|
-
@output << data
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
@ch.on_extended_data do |_,c,err|
|
39
|
-
STDERR.write err
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
|
44
|
-
def self.reach?(server = SSHLine.default_server)
|
45
|
-
Persist.memory(server, :key => "Reach server") do
|
46
|
-
begin
|
47
|
-
CMD.cmd("ssh #{server} bash -l -c \"scout\"")
|
48
|
-
true
|
49
|
-
rescue Exception
|
50
|
-
false
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
def send_cmd(command)
|
56
|
-
@output = ""
|
57
|
-
@complete_output = false
|
58
|
-
@ch.send_data(command+"\necho DONECMD: $?\n")
|
59
|
-
end
|
60
|
-
|
61
|
-
def serve_output
|
62
|
-
@complete_output = true
|
63
|
-
end
|
64
|
-
|
65
|
-
def run(command)
|
66
|
-
send_cmd(command)
|
67
|
-
@ssh.loop{ ! @complete_output}
|
68
|
-
if @exit_status.to_i == 0
|
69
|
-
return @output
|
70
|
-
else
|
71
|
-
raise SSHProcessFailed.new @host, command
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
def ruby(script)
|
76
|
-
@output = ""
|
77
|
-
@complete_output = false
|
78
|
-
cmd = "ruby -e \"#{script.gsub('"','\\"')}\"\n"
|
79
|
-
Log.debug "Running ruby on #{@host}:\n#{ script }"
|
80
|
-
@ch.send_data(cmd)
|
81
|
-
@ch.send_data("echo DONECMD: $?\n")
|
82
|
-
@ssh.loop{ !@complete_output }
|
83
|
-
if @exit_status.to_i == 0
|
84
|
-
return @output
|
85
|
-
else
|
86
|
-
raise SSHProcessFailed.new @host, "Ruby script:\n#{script}"
|
87
|
-
end
|
88
|
-
end
|
89
|
-
|
90
|
-
def scout(script)
|
91
|
-
scout_script =<<-EOF
|
92
|
-
require 'scout'
|
93
|
-
SSHLine.run_local do
|
94
|
-
#{script.strip}
|
95
|
-
end
|
96
|
-
EOF
|
97
|
-
|
98
|
-
m = ruby(scout_script)
|
99
|
-
Marshal.load m
|
100
|
-
end
|
101
|
-
|
102
|
-
def workflow(workflow, script)
|
103
|
-
preamble =<<-EOF
|
104
|
-
wf = Workflow.require_workflow('#{workflow}')
|
105
|
-
EOF
|
106
|
-
|
107
|
-
scout(preamble + "\n" + script)
|
108
|
-
end
|
109
|
-
|
110
|
-
class Mock < SSHLine
|
111
|
-
def initialize
|
112
|
-
end
|
113
|
-
|
114
|
-
def run(command)
|
115
|
-
CMD.cmd(command)
|
116
|
-
end
|
117
|
-
|
118
|
-
def ruby(script)
|
119
|
-
cmd = "ruby -e \"#{script.gsub('"','\\"')}\"\n"
|
120
|
-
CMD.cmd(cmd)
|
121
|
-
end
|
122
|
-
end
|
123
|
-
|
124
|
-
@connections = {}
|
125
|
-
def self.open(host, user = nil)
|
126
|
-
@connections[[host, user]] ||=
|
127
|
-
begin
|
128
|
-
if host == 'localhost'
|
129
|
-
SSHLine::Mock.new
|
130
|
-
else
|
131
|
-
SSHLine.new host, user
|
132
|
-
end
|
133
|
-
end
|
134
|
-
end
|
135
|
-
|
136
|
-
def self.run(server, cmd, options = nil)
|
137
|
-
cmd = cmd * " " if Array === cmd
|
138
|
-
cmd += " " + CMD.process_cmd_options(options) if options
|
139
|
-
open(server).run(cmd)
|
140
|
-
end
|
141
|
-
|
142
|
-
def self.ruby(server, script)
|
143
|
-
open(server).ruby(script)
|
144
|
-
end
|
145
|
-
|
146
|
-
def self.scout(server, script)
|
147
|
-
open(server).scout(script)
|
148
|
-
end
|
149
|
-
|
150
|
-
def self.workflow(server, workflow, script)
|
151
|
-
open(server).workflow(workflow, script)
|
152
|
-
end
|
153
|
-
|
154
|
-
def self.command(server, command, argv = [], options = nil)
|
155
|
-
command = "scout #{command}" unless command && command.include?('scout')
|
156
|
-
argv_str = (argv - ["--"]).collect{|v| '"' + v.to_s + '"' } * " "
|
157
|
-
command = "#{command} #{argv_str}"
|
158
|
-
Log.debug "Offsite #{server} running: #{command}"
|
159
|
-
run(server, command, options)
|
160
|
-
end
|
161
|
-
|
162
|
-
def self.mkdir(server, path)
|
163
|
-
self.run server, "mkdir -p '#{path}'"
|
164
|
-
end
|
165
|
-
|
166
|
-
def self.run_local(&block)
|
167
|
-
res = begin
|
168
|
-
old_stdout = STDOUT.dup; STDOUT.reopen(STDERR)
|
169
|
-
block.call
|
170
|
-
ensure
|
171
|
-
STDOUT.reopen(old_stdout)
|
172
|
-
end
|
173
|
-
puts Marshal.dump(res)
|
174
|
-
end
|
175
|
-
end
|
data/lib/scout/offsite/step.rb
DELETED
@@ -1,100 +0,0 @@
|
|
1
|
-
require_relative '../workflow/step'
|
2
|
-
require_relative 'ssh'
|
3
|
-
require_relative 'sync'
|
4
|
-
|
5
|
-
module OffsiteStep
|
6
|
-
|
7
|
-
extend Annotation
|
8
|
-
annotation :server, :workflow_name, :clean_id, :slurm
|
9
|
-
|
10
|
-
def inputs_directory
|
11
|
-
@inputs_directory ||= begin
|
12
|
-
if provided_inputs && provided_inputs.any?
|
13
|
-
file = ".scout/tmp/step_inputs/#{workflow}/#{task_name}/#{name}"
|
14
|
-
TmpFile.with_path do |inputs_dir|
|
15
|
-
save_inputs(inputs_dir)
|
16
|
-
SSHLine.rsync(inputs_dir, file, target: server, directory: true)
|
17
|
-
end
|
18
|
-
file
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
def workflow_name
|
24
|
-
@workflow_name || workflow.to_s
|
25
|
-
end
|
26
|
-
|
27
|
-
def offsite_job_ssh(script)
|
28
|
-
parts = []
|
29
|
-
parts << <<~EOF.strip
|
30
|
-
wf = Workflow.require_workflow "#{workflow_name}";
|
31
|
-
EOF
|
32
|
-
|
33
|
-
if inputs_directory
|
34
|
-
parts << <<~EOF.strip
|
35
|
-
job = wf.job(:#{task_name}, "#{clean_name}", :load_inputs => "#{inputs_directory}");
|
36
|
-
EOF
|
37
|
-
else
|
38
|
-
parts << <<~EOF.strip
|
39
|
-
job = wf.job(:#{task_name}, "#{clean_name}");
|
40
|
-
EOF
|
41
|
-
end
|
42
|
-
|
43
|
-
parts << script
|
44
|
-
|
45
|
-
|
46
|
-
SSHLine.scout server, parts * "\n"
|
47
|
-
end
|
48
|
-
|
49
|
-
def offsite_path
|
50
|
-
@path = offsite_job_ssh <<~EOF
|
51
|
-
job.path.identify
|
52
|
-
EOF
|
53
|
-
end
|
54
|
-
|
55
|
-
def info
|
56
|
-
info = @info ||= offsite_job_ssh <<~EOF
|
57
|
-
info = Open.exists?(job.info_file) ? job.info : {}
|
58
|
-
info[:running] = true if job.running?
|
59
|
-
info
|
60
|
-
EOF
|
61
|
-
|
62
|
-
@info = nil unless %w(done aborted error).include?(info[:status].to_s)
|
63
|
-
|
64
|
-
info
|
65
|
-
end
|
66
|
-
|
67
|
-
def done?
|
68
|
-
status == :done
|
69
|
-
end
|
70
|
-
|
71
|
-
def orchestrate_slurm
|
72
|
-
bundle_files = offsite_job_ssh <<~EOF
|
73
|
-
require 'rbbt/hpc'
|
74
|
-
HPC::BATCH_MODULE = HPC.batch_system "SLURM"
|
75
|
-
HPC::BATCH_MODULE.orchestrate_job(job, {})
|
76
|
-
job.join
|
77
|
-
job.bundle_files
|
78
|
-
EOF
|
79
|
-
SSHLine.sync(bundle_files, source: server)
|
80
|
-
self.load
|
81
|
-
end
|
82
|
-
|
83
|
-
|
84
|
-
def exec
|
85
|
-
bundle_files = offsite_job_ssh <<~EOF
|
86
|
-
job.run
|
87
|
-
job.bundle_files
|
88
|
-
EOF
|
89
|
-
SSHLine.sync(bundle_files, source: server)
|
90
|
-
self.load
|
91
|
-
end
|
92
|
-
|
93
|
-
def run
|
94
|
-
if slurm
|
95
|
-
orchestrate_slurm
|
96
|
-
else
|
97
|
-
exec
|
98
|
-
end
|
99
|
-
end
|
100
|
-
end
|
data/lib/scout/offsite/sync.rb
DELETED
@@ -1,55 +0,0 @@
|
|
1
|
-
class SSHLine
|
2
|
-
def self.locate(server, paths, map: :user)
|
3
|
-
SSHLine.scout server, <<-EOF
|
4
|
-
map = :#{map}
|
5
|
-
paths = [#{paths.collect{|p| "'" + p + "'" } * ", " }]
|
6
|
-
located = paths.collect{|p| Path.setup(p).find(map) }
|
7
|
-
identified = paths.collect{|p| Resource.identify(p) }
|
8
|
-
[located, identified]
|
9
|
-
EOF
|
10
|
-
end
|
11
|
-
|
12
|
-
def self.rsync(source_path, target_path, directory: false, source: nil, target: nil, dry_run: false, hard_link: false)
|
13
|
-
rsync_args = "-avztHP --copy-unsafe-links --omit-dir-times "
|
14
|
-
|
15
|
-
rsync_args << "--link-dest '#{source_path}' " if hard_link && ! source
|
16
|
-
|
17
|
-
source_path = source_path + "/" if directory && ! source_path.end_with?("/")
|
18
|
-
target_path = target_path + "/" if directory && ! target_path.end_with?("/")
|
19
|
-
if target
|
20
|
-
SSHLine.mkdir target, File.dirname(target_path)
|
21
|
-
else
|
22
|
-
Open.mkdir(File.dirname(target_path))
|
23
|
-
end
|
24
|
-
|
25
|
-
cmd = 'rsync '
|
26
|
-
cmd << rsync_args
|
27
|
-
cmd << '-nv ' if dry_run
|
28
|
-
cmd << (source ? [source, source_path] * ":" : source_path) << " "
|
29
|
-
cmd << (target ? [target, target_path] * ":" : target_path) << " "
|
30
|
-
|
31
|
-
CMD.cmd_log(cmd, :log => Log::HIGH)
|
32
|
-
end
|
33
|
-
|
34
|
-
def self.sync(paths, source: nil, target: nil, map: :user, **kwargs)
|
35
|
-
source = nil if source == 'localhost'
|
36
|
-
target = nil if target == 'localhost'
|
37
|
-
|
38
|
-
if source
|
39
|
-
source_paths, identified_paths = SSHLine.locate(source, paths)
|
40
|
-
else
|
41
|
-
source_paths = paths.collect{|p| Path === p ? p.find : p }
|
42
|
-
identified_paths = paths.collect{|p| Resource.identify(p) }
|
43
|
-
end
|
44
|
-
|
45
|
-
if target
|
46
|
-
target_paths = SSHLine.locate(target, identified_paths, map: map)
|
47
|
-
else
|
48
|
-
target_paths = identified_paths.collect{|p| p.find(map) }
|
49
|
-
end
|
50
|
-
|
51
|
-
source_paths.zip(target_paths).each do |source_path,target_path|
|
52
|
-
rsync(source_path, target_path, source: source, target: target, **kwargs)
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
data/lib/scout/offsite.rb
DELETED
data/scout_commands/offsite
DELETED
@@ -1,30 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require 'scout'
|
4
|
-
require 'scout/offsite'
|
5
|
-
|
6
|
-
$0 = "scout #{$previous_commands.any? ? $previous_commands*" " + " " : "" }#{ File.basename(__FILE__) }" if $previous_commands
|
7
|
-
|
8
|
-
options = SOPT.setup <<EOF
|
9
|
-
|
10
|
-
Description of the tool
|
11
|
-
|
12
|
-
$ #{$0} [<options>] <where> <command> ... -- [<protected options>]
|
13
|
-
|
14
|
-
Run a command offsite. Use -- to make sure options reach the offsite
|
15
|
-
|
16
|
-
-h--help Print this help
|
17
|
-
EOF
|
18
|
-
if options[:help]
|
19
|
-
if defined? scout_usage
|
20
|
-
scout_usage
|
21
|
-
else
|
22
|
-
puts SOPT.doc
|
23
|
-
end
|
24
|
-
exit 0
|
25
|
-
end
|
26
|
-
|
27
|
-
where = ARGV.shift
|
28
|
-
command = ARGV.shift
|
29
|
-
|
30
|
-
puts SSHLine.command(where, command, ARGV)
|
@@ -1,15 +0,0 @@
|
|
1
|
-
require File.expand_path(__FILE__).sub(%r(/test/.*), '/test/test_helper.rb')
|
2
|
-
require File.expand_path(__FILE__).sub(%r(.*/test/), '').sub(/test_(.*)\.rb/,'\1')
|
3
|
-
|
4
|
-
class TestSSH < Test::Unit::TestCase
|
5
|
-
def test_marshal
|
6
|
-
return unless SSHLine.reach?
|
7
|
-
|
8
|
-
assert TrueClass === SSHLine.scout(:default, 'true')
|
9
|
-
end
|
10
|
-
|
11
|
-
def test_localhost
|
12
|
-
assert SSHLine.scout('localhost', 'true')
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
@@ -1,32 +0,0 @@
|
|
1
|
-
require File.expand_path(__FILE__).sub(%r(/test/.*), '/test/test_helper.rb')
|
2
|
-
require File.expand_path(__FILE__).sub(%r(.*/test/), '').sub(/test_(.*)\.rb/,'\1')
|
3
|
-
|
4
|
-
class TestOffsiteStep < Test::Unit::TestCase
|
5
|
-
def test_offsite_task
|
6
|
-
workflow_code =<<-EOF
|
7
|
-
module TestWF
|
8
|
-
extend Workflow
|
9
|
-
|
10
|
-
input :string, :string, "String", "string"
|
11
|
-
task :string => :string do |string| string end
|
12
|
-
end
|
13
|
-
|
14
|
-
TestWF.directory = Path.setup("#{tmpdir.offsite.TestWF}")
|
15
|
-
EOF
|
16
|
-
|
17
|
-
TmpFile.with_file workflow_code, :extension => 'rb' do |wffile|
|
18
|
-
wf = Workflow.require_workflow wffile
|
19
|
-
|
20
|
-
job = wf.job(:string)
|
21
|
-
|
22
|
-
off = OffsiteStep.setup job, server: 'localhost', workflow_name: wffile
|
23
|
-
|
24
|
-
refute off.done?
|
25
|
-
assert_equal 'string', off.run
|
26
|
-
|
27
|
-
assert off.done?
|
28
|
-
assert_equal 'string', off.run
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
@@ -1,36 +0,0 @@
|
|
1
|
-
require File.expand_path(__FILE__).sub(%r(/test/.*), '/test/test_helper.rb')
|
2
|
-
require File.expand_path(__FILE__).sub(%r(.*/test/), '').sub(/test_(.*)\.rb/,'\1')
|
3
|
-
|
4
|
-
class TestSync < Test::Unit::TestCase
|
5
|
-
def test_sync
|
6
|
-
TmpFile.with_path do |tmpdir|
|
7
|
-
tmpdir = Scout.tmp.tmpdir_sync
|
8
|
-
tmpdir.dir1.foo.write("FOO")
|
9
|
-
tmpdir.dir1.bar.write("BAR")
|
10
|
-
|
11
|
-
TmpFile.with_path do |tmpdir2|
|
12
|
-
Misc.in_dir tmpdir2 do
|
13
|
-
SSHLine.sync([tmpdir.dir1], map: :current)
|
14
|
-
|
15
|
-
assert tmpdir2.glob("**/*").select{|f| f.include?('foo') }.any?
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
def test_sync_dir_map
|
22
|
-
TmpFile.with_path do |tmpdir|
|
23
|
-
tmpdir = Scout.tmp.tmpdir_sync
|
24
|
-
tmpdir.dir1.foo.write("FOO")
|
25
|
-
tmpdir.dir1.bar.write("BAR")
|
26
|
-
|
27
|
-
TmpFile.with_path do |tmpdir2|
|
28
|
-
SSHLine.sync([tmpdir.dir1], map: tmpdir2)
|
29
|
-
Misc.in_dir tmpdir2 do
|
30
|
-
assert tmpdir2.glob("**/*").select{|f| f.include?('foo') }.any?
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
File without changes
|
data/test/scout/test_offsite.rb
DELETED
File without changes
|