advance 0.3.0 → 0.3.1

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: 961d5cc4a945b3b3bf404f27ad1e16119d437fec4abce4d21413374087c80e5e
4
- data.tar.gz: aa4259e85e69a968a0564529433751f6a244ce1257206f7b9b048d182d85944e
3
+ metadata.gz: 21c3cea8dd88f565f5ae350bee7b7839763da2ab59d46bfd630cdc2c17a63bab
4
+ data.tar.gz: f05f8f24dc30605b246de1d49b80aefef068c6f84bfad18bc83bea1c46d44dcf
5
5
  SHA512:
6
- metadata.gz: 3eb44f9dbd87f94c865760d6f0ae981647d151f074600bb9fe8a844d63efd0ab819a2de2c44f165408735914528408cf2ec550dd0f0a4f6a53d5daf9b94cdf50
7
- data.tar.gz: 196d465c18c089a7a3841cc55d4991f736c59366f38a6a1d3d4d933e93bcf1ca8ed292d094601b940c825807a495198f99500f7f89c1881309bf303215b19c46
6
+ metadata.gz: c6c14a9dd7f44f275a279ff3a2c91f621fa073d7dc52bcfd099c1994314bfdc69ecd59816514984edc4f9fa5265de5d125990d8f6f78ce25a5251e2f581851dc
7
+ data.tar.gz: b6921d82a8fae177cb0fba0583491070d9ce82939900667c705c2d1d181a91c2cf55055107d32a3c871ef3646a60cfddc019257fba05afd13b96c6bdbdfe4380
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- advance (0.3.0)
4
+ advance (0.3.1)
5
5
  team_effort
6
6
 
7
7
  GEM
@@ -1,3 +1,3 @@
1
1
  module Advance
2
- VERSION = "0.3.0"
2
+ VERSION = "0.3.1"
3
3
  end
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
- puts "loading module"
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: advance
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - janemacfarlane