advance 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/advance/version.rb +1 -1
- data/lib/advance.rb +57 -3
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 21c3cea8dd88f565f5ae350bee7b7839763da2ab59d46bfd630cdc2c17a63bab
|
4
|
+
data.tar.gz: f05f8f24dc30605b246de1d49b80aefef068c6f84bfad18bc83bea1c46d44dcf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c6c14a9dd7f44f275a279ff3a2c91f621fa073d7dc52bcfd099c1994314bfdc69ecd59816514984edc4f9fa5265de5d125990d8f6f78ce25a5251e2f581851dc
|
7
|
+
data.tar.gz: b6921d82a8fae177cb0fba0583491070d9ce82939900667c705c2d1d181a91c2cf55055107d32a3c871ef3646a60cfddc019257fba05afd13b96c6bdbdfe4380
|
data/Gemfile.lock
CHANGED
data/lib/advance/version.rb
CHANGED
data/lib/advance.rb
CHANGED
@@ -1,8 +1,9 @@
|
|
1
|
-
require_relative "./advance/version"
|
2
|
-
require "find"
|
3
1
|
require "fileutils"
|
2
|
+
require "find"
|
3
|
+
require "json"
|
4
4
|
require "open3"
|
5
5
|
require "team_effort"
|
6
|
+
require_relative "./advance/version"
|
6
7
|
|
7
8
|
module Advance
|
8
9
|
RESET="\e[0m"
|
@@ -19,7 +20,45 @@ module Advance
|
|
19
20
|
WHITE="\e[1;37m"
|
20
21
|
YELLOW="\e[33m"
|
21
22
|
|
22
|
-
|
23
|
+
def self.included(pipeline_module)
|
24
|
+
$pipeline = caller_locations.first.path
|
25
|
+
meta =
|
26
|
+
if File.exist?(".meta")
|
27
|
+
JSON.parse(File.read(".meta"))
|
28
|
+
else
|
29
|
+
{}
|
30
|
+
end
|
31
|
+
last_run_number = meta["last_run_number"] ||= -1
|
32
|
+
$run_number = last_run_number + 1
|
33
|
+
end
|
34
|
+
|
35
|
+
def update_meta(step_number, processing_mode, label, command, start_time, duration, file_count)
|
36
|
+
meta =
|
37
|
+
if File.exist?(".meta")
|
38
|
+
JSON.parse(File.read(".meta"))
|
39
|
+
else
|
40
|
+
{}
|
41
|
+
end
|
42
|
+
|
43
|
+
meta["pipeline"] ||= $pipeline
|
44
|
+
meta["last_run_number"] = $run_number
|
45
|
+
meta["runs"] ||= []
|
46
|
+
|
47
|
+
step_data = {
|
48
|
+
"step_number" => step_number,
|
49
|
+
"start_time" => start_time,
|
50
|
+
"duration" => duration,
|
51
|
+
"file_count" => file_count,
|
52
|
+
"processing_mode" => processing_mode,
|
53
|
+
"label" => label,
|
54
|
+
"command" => command,
|
55
|
+
"columns" => $cols
|
56
|
+
}
|
57
|
+
meta["runs"][$run_number] ||= []
|
58
|
+
meta["runs"][$run_number] << step_data
|
59
|
+
|
60
|
+
File.write(".meta", JSON.pretty_generate(meta))
|
61
|
+
end
|
23
62
|
|
24
63
|
def advance(processing_mode, label, command)
|
25
64
|
$redo_mode ||= :checking
|
@@ -39,7 +78,11 @@ module Advance
|
|
39
78
|
do_command_wo_log "tar xzf #{previous_dir_path}"
|
40
79
|
end
|
41
80
|
previous_dir_path = previous_dir_path.gsub(/\.tgz$/, "")
|
81
|
+
start_time = Time.now
|
42
82
|
send(processing_mode, command, previous_dir_path, dir_name)
|
83
|
+
file_count = count_files(dir_name)
|
84
|
+
duration = Time.now - start_time
|
85
|
+
update_meta($step, processing_mode, label, command, start_time, duration, file_count)
|
43
86
|
end
|
44
87
|
previous_dir_path = previous_dir_path.gsub(/\.tgz$/, "")
|
45
88
|
if File.basename(previous_dir_path) =~ /^step_/
|
@@ -50,6 +93,17 @@ module Advance
|
|
50
93
|
end
|
51
94
|
end
|
52
95
|
|
96
|
+
def count_files(dir)
|
97
|
+
file_count = 0
|
98
|
+
Find.find(dir) do |path|
|
99
|
+
next if File.directory?(path)
|
100
|
+
next if File.basename(path) == "log"
|
101
|
+
next if File.basename(path) =~ /^\./
|
102
|
+
file_count += 1
|
103
|
+
end
|
104
|
+
file_count
|
105
|
+
end
|
106
|
+
|
53
107
|
def static(processing_mode, label, command)
|
54
108
|
$redo_mode ||= :checking
|
55
109
|
$step ||= 0
|