runtime_groups 0.1.1 → 0.1.2

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: 14133d120fc0a29b48cf24973d76504d49c6a3063c09b73c494ebe84d245e929
4
- data.tar.gz: 2c149b3ed4d6ddd3bad32063d99abcd8263262b41886649b1ad96e1f7ab812a0
3
+ metadata.gz: 308e171a14eaf92e5a79f1c809a3aa6cc7f3c58ac9deefbf12bfd919820dde04
4
+ data.tar.gz: f193266281d48f846fe593788bc4390be97411170b98bd8df69d1aca5def82da
5
5
  SHA512:
6
- metadata.gz: fb3550fb570bef59d0b61b1c8da6647756b7610b6064571462023936678aff347a9ffd285bab4e0bc6eec9a1dd52b5206496f6ed1bc11bf72139724244330ddb
7
- data.tar.gz: 62d5525c8e0ccb1f1ad61d5b77e7352673d0cd7e5b32310f2d95a1ee079b928244178edc098a8ae41b1d1b75fbabc9604efa86b9128b5edffbd2a4667ff95245
6
+ metadata.gz: 39782fe6ad08614d73ec1f7fb83f1eea133a1cbb471b83aa230feb999caba2fce12ff9d995228e412fba02d61bbd09aae34ee5e87a252ab7546021d72f9bfc63
7
+ data.tar.gz: bad041bff42c81c31bd9320612cce37e656c66a39c92fc681a8aca484e22fe5260ebe020ff1629ca14ea49c4df2164e50f7e7c6bb6417ae461c69d2abe74fc7c
checksums.yaml.gz.sig CHANGED
Binary file
data/CHANGELOG.md CHANGED
@@ -30,6 +30,17 @@ Please file a bug if you notice a violation of semantic versioning.
30
30
 
31
31
  ### Security
32
32
 
33
+ ## [0.1.2] - 2026-10-15
34
+
35
+ - TAG: [v0.1.2][0.1.2t]
36
+ - COVERAGE: 99.21% -- 125/126 lines in 6 files
37
+ - BRANCH COVERAGE: 96.88% -- 31/32 branches in 6 files
38
+ - 93.55% documented
39
+
40
+ ### Added
41
+
42
+ - Grouping runtime weights accept unknown_runtime: explicit weight for files missing from the runtime log, instead of the default (average of known runtimes, or 1.0 when nothing is known); parity with parallel_tests' --unknown-runtime, consumed by turbo_tests2's --unknown-runtime flag
43
+
33
44
  ## [0.1.1] - 2026-10-15
34
45
 
35
46
  - TAG: [v0.1.1][0.1.1t]
@@ -140,7 +151,9 @@ Please file a bug if you notice a violation of semantic versioning.
140
151
  legacy manual bundle install path, avoiding setup-time Bundler full-index
141
152
  failures against `gem.coop`.
142
153
 
143
- [Unreleased]: https://github.com/galtzo-floss/runtime_groups/compare/v0.1.1...HEAD
154
+ [Unreleased]: https://github.com/galtzo-floss/runtime_groups/compare/v0.1.2...HEAD
155
+ [0.1.2]: https://github.com/galtzo-floss/runtime_groups/compare/v0.1.1...v0.1.2
156
+ [0.1.2t]: https://github.com/galtzo-floss/runtime_groups/releases/tag/v0.1.2
144
157
  [0.1.1]: https://github.com/galtzo-floss/runtime_groups/compare/v0.1.0...v0.1.1
145
158
  [0.1.1t]: https://github.com/galtzo-floss/runtime_groups/releases/tag/v0.1.1
146
159
  [0.1.0]: https://github.com/galtzo-floss/runtime_groups/compare/e8764d41152b587dbc972e0abe97098794232b36...v0.1.0
data/README.md CHANGED
@@ -562,7 +562,7 @@ Thanks for RTFM. ☺️
562
562
  [📌gitmoji]: https://gitmoji.dev
563
563
  [📌gitmoji-img]: https://img.shields.io/badge/gitmoji_commits-%20%F0%9F%98%9C%20%F0%9F%98%8D-34495e.svg?style=flat-square
564
564
  [🧮kloc]: https://www.youtube.com/watch?v=dQw4w9WgXcQ
565
- [🧮kloc-img]: https://img.shields.io/badge/KLOC-0.125-FFDD67.svg?style=for-the-badge&logo=YouTube&logoColor=blue
565
+ [🧮kloc-img]: https://img.shields.io/badge/KLOC-0.126-FFDD67.svg?style=for-the-badge&logo=YouTube&logoColor=blue
566
566
  [🔐security]: https://github.com/galtzo-floss/runtime_groups/blob/main/SECURITY.md
567
567
  [🔐security-img]: https://img.shields.io/badge/security-policy-259D6C.svg?style=flat
568
568
  [📄copyright-notice-explainer]: https://opensource.stackexchange.com/questions/5778/why-do-licenses-such-as-the-mit-license-specify-a-single-year
@@ -25,17 +25,20 @@ module RuntimeGroups
25
25
  # @param runtime_log [String, nil] runtime log path (for :runtime)
26
26
  # @param allowed_missing [Float] fraction of files allowed to be missing
27
27
  # from the runtime log before {RuntimeLogTooSmallError} is raised
28
+ # @param unknown_runtime [Float, nil] weight for files missing from the
29
+ # runtime log; nil (default) uses the average of the known runtimes,
30
+ # or 1.0 when nothing is known
28
31
  # @return [Hash{String => Float}] file => weight
29
32
  # @raise [RuntimeGroups::RuntimeLogTooSmallError] when too many files are
30
33
  # missing from the runtime log
31
- def with_size(files, group_by: :runtime, runtime_log: nil, allowed_missing: 1.0)
34
+ def with_size(files, group_by: :runtime, runtime_log: nil, allowed_missing: 1.0, unknown_runtime: nil)
32
35
  case group_by
33
36
  when :found
34
37
  files.each_with_object({}) { |file, memo| memo[file] = 1.0 }
35
38
  when :filesize
36
39
  files.each_with_object({}) { |file, memo| memo[file] = File.stat(file).size.to_f }
37
40
  when :runtime
38
- runtime_weights(files, runtime_log, allowed_missing)
41
+ runtime_weights(files, runtime_log, allowed_missing, unknown_runtime)
39
42
  else
40
43
  raise Error, "invalid group-by mode #{group_by.inspect}; expected one of: runtime, filesize, found"
41
44
  end
@@ -50,11 +53,19 @@ module RuntimeGroups
50
53
  # @param runtime_log [String, nil] runtime log path (for :runtime)
51
54
  # @param allowed_missing [Float] fraction of files allowed to be missing
52
55
  # from the runtime log
56
+ # @param unknown_runtime [Float, nil] weight for files missing from the
57
+ # runtime log (nil = average of known, or 1.0 when nothing is known)
53
58
  # @return [Array<Array<String>>] exactly `num_groups` arrays of file paths
54
59
  # @raise [RuntimeGroups::Error] when num_groups or group_by is invalid
55
- def in_groups(files, num_groups, group_by: :runtime, runtime_log: nil, allowed_missing: 1.0)
60
+ def in_groups(files, num_groups, group_by: :runtime, runtime_log: nil, allowed_missing: 1.0, unknown_runtime: nil)
56
61
  groups = Array.new(RuntimeGroups.parse_count!(num_groups)) { {weight: 0.0, files: []} }
57
- weights = with_size(files, group_by: group_by, runtime_log: runtime_log, allowed_missing: allowed_missing)
62
+ weights = with_size(
63
+ files,
64
+ group_by: group_by,
65
+ runtime_log: runtime_log,
66
+ allowed_missing: allowed_missing,
67
+ unknown_runtime: unknown_runtime
68
+ )
58
69
 
59
70
  files.sort_by { |file| [-weights[file], file] }.each do |file|
60
71
  target = groups.min_by { |group| group[:weight] }
@@ -65,11 +76,11 @@ module RuntimeGroups
65
76
  groups.map { |group| group[:files] }
66
77
  end
67
78
 
68
- # Runtime weights with the missing-file budget and average-fill semantics
79
+ # Runtime weights with the missing-file budget and fill semantics
69
80
  # retained from `parallel_tests`.
70
81
  #
71
82
  # @return [Hash{String => Float}]
72
- def runtime_weights(files, runtime_log, allowed_missing)
83
+ def runtime_weights(files, runtime_log, allowed_missing, unknown_runtime = nil)
73
84
  budget = files.size * allowed_missing
74
85
  runtimes = RuntimeLog.read(runtime_log)
75
86
  known, unknown = [], []
@@ -88,7 +99,8 @@ module RuntimeGroups
88
99
  end
89
100
 
90
101
  weights = known.each_with_object({}) { |(file, seconds), memo| memo[file] = seconds }
91
- fill = known.empty? ? 1.0 : known.map(&:last).sum / known.size
102
+ fill = unknown_runtime ||
103
+ (known.empty? ? 1.0 : known.map(&:last).sum / known.size)
92
104
  unknown.each { |file| weights[file] = fill }
93
105
  weights
94
106
  end
@@ -4,7 +4,7 @@ module RuntimeGroups
4
4
  # Version namespace for this gem.
5
5
  module Version
6
6
  # Current gem version.
7
- VERSION = "0.1.1"
7
+ VERSION = "0.1.2"
8
8
  end
9
9
  # Current gem version exposed at the traditional constant location.
10
10
  VERSION = Version::VERSION # Traditional Constant Location
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: runtime_groups
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter H. Boling
@@ -284,10 +284,10 @@ licenses:
284
284
  - MIT
285
285
  metadata:
286
286
  homepage_uri: https://github.com/galtzo-floss/runtime_groups
287
- source_code_uri: https://github.com/galtzo-floss/runtime_groups/tree/v0.1.1
288
- changelog_uri: https://github.com/galtzo-floss/runtime_groups/blob/v0.1.1/CHANGELOG.md
287
+ source_code_uri: https://github.com/galtzo-floss/runtime_groups/tree/v0.1.2
288
+ changelog_uri: https://github.com/galtzo-floss/runtime_groups/blob/v0.1.2/CHANGELOG.md
289
289
  bug_tracker_uri: https://github.com/galtzo-floss/runtime_groups/issues
290
- documentation_uri: https://www.rubydoc.info/gems/runtime_groups/0.1.1
290
+ documentation_uri: https://www.rubydoc.info/gems/runtime_groups/0.1.2
291
291
  funding_uri: https://github.com/sponsors/pboling
292
292
  wiki_uri: https://github.com/galtzo-floss/runtime_groups/wiki
293
293
  news_uri: https://www.railsbling.com/tags/runtime_groups
metadata.gz.sig CHANGED
Binary file