judges 0.57.2 → 0.58.0
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/Gemfile.lock +6 -6
- data/bin/judges +5 -3
- data/features/test.feature +2 -2
- data/judges.gemspec +1 -1
- data/lib/judges/commands/update.rb +9 -6
- data/lib/judges/commands/upload.rb +6 -1
- data/lib/judges/judges.rb +21 -6
- data/lib/judges.rb +1 -1
- 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: 2c056c0de03fb4bdfd31ab41881fd2a45df0dce3eab4cae835cb460f54fefc51
|
|
4
|
+
data.tar.gz: 9297963335726bbcab1e7f5551eaff4ec04130b72622e902e334fed5795f598b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 734372c730e0f4fe9f8e350dce2cb550f1cdde850934394a880ed1fd0682897da74659e8ed53799a0f28b6256e1ff7fb666daeb68b3f980711f727c09d18a977
|
|
7
|
+
data.tar.gz: 28be015f363aa13e9365e22e24100b5178125a727c7907c2a2bc32c378d87b70dc7faf08fd1248156fdc3c7999166c4807c9619603ea19463cfc19eb79034cea
|
data/Gemfile.lock
CHANGED
|
@@ -22,13 +22,13 @@ PATH
|
|
|
22
22
|
GEM
|
|
23
23
|
remote: https://rubygems.org/
|
|
24
24
|
specs:
|
|
25
|
-
addressable (2.8.
|
|
26
|
-
public_suffix (>= 2.0.2, <
|
|
25
|
+
addressable (2.8.8)
|
|
26
|
+
public_suffix (>= 2.0.2, < 8.0)
|
|
27
27
|
ansi (1.5.0)
|
|
28
28
|
ast (2.4.3)
|
|
29
29
|
backtrace (0.4.1)
|
|
30
30
|
base64 (0.3.0)
|
|
31
|
-
baza.rb (0.11.
|
|
31
|
+
baza.rb (0.11.1)
|
|
32
32
|
backtrace (~> 0.4)
|
|
33
33
|
elapsed (~> 0.2)
|
|
34
34
|
faraday (~> 2.13)
|
|
@@ -70,7 +70,7 @@ GEM
|
|
|
70
70
|
cucumber-html-formatter (21.15.1)
|
|
71
71
|
cucumber-messages (> 19, < 28)
|
|
72
72
|
cucumber-messages (27.2.0)
|
|
73
|
-
cucumber-tag-expressions (8.
|
|
73
|
+
cucumber-tag-expressions (8.1.0)
|
|
74
74
|
decoor (0.1.0)
|
|
75
75
|
diff-lcs (1.6.2)
|
|
76
76
|
docile (1.4.1)
|
|
@@ -81,7 +81,7 @@ GEM
|
|
|
81
81
|
ethon (0.18.0)
|
|
82
82
|
ffi (>= 1.15.0)
|
|
83
83
|
logger
|
|
84
|
-
factbase (0.
|
|
84
|
+
factbase (0.17.0)
|
|
85
85
|
backtrace (~> 0.4)
|
|
86
86
|
decoor (~> 0.1)
|
|
87
87
|
ellipsized (~> 0.3)
|
|
@@ -166,7 +166,7 @@ GEM
|
|
|
166
166
|
ast (~> 2.4.1)
|
|
167
167
|
racc
|
|
168
168
|
prism (1.6.0)
|
|
169
|
-
public_suffix (
|
|
169
|
+
public_suffix (7.0.0)
|
|
170
170
|
qbash (0.4.8)
|
|
171
171
|
backtrace (> 0)
|
|
172
172
|
elapsed (> 0)
|
data/bin/judges
CHANGED
|
@@ -118,11 +118,11 @@ class JudgesGLI extend GLI::App
|
|
|
118
118
|
c.flag([:lib])
|
|
119
119
|
c.desc 'Shuffle judges, except those starting with the specified prefix'
|
|
120
120
|
c.flag([:shuffle], default_value: '')
|
|
121
|
-
c.desc 'Random seed for judge ordering
|
|
121
|
+
c.desc 'Random seed for judge ordering'
|
|
122
122
|
c.flag([:seed], default_value: 0, type: Integer)
|
|
123
|
-
c.desc 'Prioritize a judge to run before all others'
|
|
123
|
+
c.desc 'Prioritize a judge to run before all others (supports wildcards with *)'
|
|
124
124
|
c.flag([:boost], multiple: true)
|
|
125
|
-
c.desc 'Demote a judge to run after all others'
|
|
125
|
+
c.desc 'Demote a judge to run after all others (supports wildcards with *)'
|
|
126
126
|
c.flag([:demote], multiple: true)
|
|
127
127
|
c.desc 'Maximum time in seconds for the entire update cycle'
|
|
128
128
|
c.flag([:lifetime], default_value: 300, type: Integer)
|
|
@@ -142,6 +142,8 @@ class JudgesGLI extend GLI::App
|
|
|
142
142
|
c.switch([:statistics], default_value: false)
|
|
143
143
|
c.desc 'Expect at least one judge to be used (fail if none are used)'
|
|
144
144
|
c.switch([:'expect-judges'], default_value: true)
|
|
145
|
+
c.desc 'File to write churn information to (e.g., /tmp/churn.txt)'
|
|
146
|
+
c.flag([:churn])
|
|
145
147
|
run_it(c, 'update')
|
|
146
148
|
end
|
|
147
149
|
|
data/features/test.feature
CHANGED
|
@@ -16,9 +16,9 @@ Feature: Test
|
|
|
16
16
|
And Exit code is zero
|
|
17
17
|
|
|
18
18
|
Scenario: Factbase version can be set
|
|
19
|
-
When I run bin/judges with "--factbase 0.
|
|
19
|
+
When I run bin/judges with "--factbase 0.17.0 --verbose test --judge guess ./fixtures"
|
|
20
20
|
Then Exit code is zero
|
|
21
|
-
And Stdout contains "Factbase version to be used: '0.
|
|
21
|
+
And Stdout contains "Factbase version to be used: '0.17.0'"
|
|
22
22
|
|
|
23
23
|
Scenario: Simple test of no judges
|
|
24
24
|
Given I run bin/judges with "test --judge absent_for_sure ./fixtures"
|
data/judges.gemspec
CHANGED
|
@@ -9,7 +9,7 @@ Gem::Specification.new do |s|
|
|
|
9
9
|
s.required_rubygems_version = Gem::Requirement.new('>= 0') if s.respond_to? :required_rubygems_version=
|
|
10
10
|
s.required_ruby_version = '>=3.2'
|
|
11
11
|
s.name = 'judges'
|
|
12
|
-
s.version = '0.
|
|
12
|
+
s.version = '0.58.0'
|
|
13
13
|
s.license = 'MIT'
|
|
14
14
|
s.summary = 'Command-Line Tool for a Factbase'
|
|
15
15
|
s.description =
|
|
@@ -70,9 +70,10 @@ class Judges::Update
|
|
|
70
70
|
epoch: @epoch, shuffle: opts['shuffle'], boost: opts['boost'],
|
|
71
71
|
demote: opts['demote'], seed: opts['seed']
|
|
72
72
|
)
|
|
73
|
+
churn = nil
|
|
73
74
|
begin
|
|
74
75
|
Timeout.timeout(opts['lifetime']) do
|
|
75
|
-
loop_them(
|
|
76
|
+
churn = loop_them(judges, fb, opts, options)
|
|
76
77
|
end
|
|
77
78
|
rescue Timeout::Error, Timeout::ExitException => e
|
|
78
79
|
@loog.error("Terminated due to --lifetime=#{opts['lifetime']}")
|
|
@@ -80,12 +81,16 @@ class Judges::Update
|
|
|
80
81
|
@loog.info("Had to stop due to the --lifetime=#{opts['lifetime']}")
|
|
81
82
|
ensure
|
|
82
83
|
impex.export(fb)
|
|
84
|
+
if opts['churn'] && churn
|
|
85
|
+
File.write(opts['churn'], churn.to_s)
|
|
86
|
+
@loog.info("Churn written to #{opts['churn']}: #{churn}")
|
|
87
|
+
end
|
|
83
88
|
end
|
|
84
89
|
end
|
|
85
90
|
|
|
86
91
|
private
|
|
87
92
|
|
|
88
|
-
def loop_them(
|
|
93
|
+
def loop_them(judges, fb, opts, options)
|
|
89
94
|
c = 0
|
|
90
95
|
churn = Factbase::Churn.new
|
|
91
96
|
errors = []
|
|
@@ -112,7 +117,6 @@ class Judges::Update
|
|
|
112
117
|
end
|
|
113
118
|
delta = cycle(opts, judges, fb, options, errors, statistics)
|
|
114
119
|
churn += delta
|
|
115
|
-
impex.export(fb)
|
|
116
120
|
if delta.zero?
|
|
117
121
|
@loog.info("The update cycle ##{c} has made no changes to the factbase, let's stop")
|
|
118
122
|
break
|
|
@@ -130,9 +134,8 @@ class Judges::Update
|
|
|
130
134
|
throw :"👍 Update completed in #{c} cycle(s), did #{churn}"
|
|
131
135
|
end
|
|
132
136
|
statistics&.report(@loog)
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
impex.export(fb)
|
|
137
|
+
summarize(fb, churn, errors, c) if %w[add append].include?(opts['summary'])
|
|
138
|
+
churn
|
|
136
139
|
end
|
|
137
140
|
|
|
138
141
|
# Update the summary.
|
|
@@ -44,11 +44,16 @@ class Judges::Upload
|
|
|
44
44
|
elapsed(@loog, level: Logger::INFO) do
|
|
45
45
|
id = baza.durable_find(jname, name)
|
|
46
46
|
if id.nil? || id.to_s.strip.empty?
|
|
47
|
-
Dir.
|
|
47
|
+
# Block form of Dir.mkdir causes error Errno::EACCESS on windows
|
|
48
|
+
# so we use non-block form
|
|
49
|
+
tmp = Dir.mktmpdir
|
|
50
|
+
begin
|
|
48
51
|
f = File.join(tmp, name)
|
|
49
52
|
File.write(f, 'placeholder')
|
|
50
53
|
id = baza.durable_place(jname, f)
|
|
51
54
|
@loog.info("Placed a placeholder to new durable '#{name}' in '#{jname}' (ID: #{id})")
|
|
55
|
+
ensure
|
|
56
|
+
FileUtils.rm_rf(tmp, secure: true)
|
|
52
57
|
end
|
|
53
58
|
end
|
|
54
59
|
size = File.size(path)
|
data/lib/judges/judges.rb
CHANGED
|
@@ -32,8 +32,8 @@ class Judges::Judges
|
|
|
32
32
|
# @param [Loog] loog Logging facility
|
|
33
33
|
# @param [Time] epoch Start time
|
|
34
34
|
# @param [String] shuffle Prefix for names of judges to shuffle
|
|
35
|
-
# @param [Array<String>] boost Names of judges to boost in priority
|
|
36
|
-
# @param [Array<String>] demote Names of judges to demote in priority
|
|
35
|
+
# @param [Array<String>] boost Names/patterns of judges to boost in priority (supports '*' wildcards)
|
|
36
|
+
# @param [Array<String>] demote Names/patterns of judges to demote in priority (supports '*' wildcards)
|
|
37
37
|
# @param [Integer] seed Random seed for judge ordering (default: 0)
|
|
38
38
|
def initialize(dir, lib, loog, epoch: Time.now, shuffle: '', boost: [], demote: [], seed: 0)
|
|
39
39
|
@dir = dir
|
|
@@ -66,8 +66,8 @@ class Judges::Judges
|
|
|
66
66
|
# determined by:
|
|
67
67
|
# 1. Randomly reorder judges (if shuffle prefix is empty, shuffle all judges;
|
|
68
68
|
# if prefix is not empty, shuffle only those NOT starting with the prefix)
|
|
69
|
-
# 2. Judges whose names match the boost
|
|
70
|
-
# 3. Judges whose names match the demote
|
|
69
|
+
# 2. Judges whose names match the boost patterns are placed first (supports '*' wildcards)
|
|
70
|
+
# 3. Judges whose names match the demote patterns are placed last (supports '*' wildcards)
|
|
71
71
|
#
|
|
72
72
|
# @yield [Judges::Judge] Yields each valid judge object
|
|
73
73
|
# @return [Enumerator] Returns an enumerator if no block is given
|
|
@@ -96,9 +96,9 @@ class Judges::Judges
|
|
|
96
96
|
demoted = []
|
|
97
97
|
normal = []
|
|
98
98
|
good.map { |a| a[0] }.each do |j|
|
|
99
|
-
if
|
|
99
|
+
if fits?(j.name, @boost)
|
|
100
100
|
boosted.append(j)
|
|
101
|
-
elsif
|
|
101
|
+
elsif fits?(j.name, @demote)
|
|
102
102
|
demoted.append(j)
|
|
103
103
|
else
|
|
104
104
|
normal.append(j)
|
|
@@ -124,4 +124,19 @@ class Judges::Judges
|
|
|
124
124
|
end
|
|
125
125
|
idx
|
|
126
126
|
end
|
|
127
|
+
|
|
128
|
+
private
|
|
129
|
+
|
|
130
|
+
# Checks if a judge name matches any of the given patterns.
|
|
131
|
+
# Patterns can contain '*' wildcards which are converted to '.*' regex patterns.
|
|
132
|
+
#
|
|
133
|
+
# @param [String] name The judge name to check
|
|
134
|
+
# @param [Array<String>, String, nil] patterns Array of patterns, or single pattern string, may contain '*' wildcards
|
|
135
|
+
# @return [Boolean] true if name matches any pattern, false otherwise
|
|
136
|
+
def fits?(name, patterns)
|
|
137
|
+
return false if patterns.nil? || patterns.empty?
|
|
138
|
+
Array(patterns).any? do |pattern|
|
|
139
|
+
name.match?("\\A#{pattern.gsub('*', '.*')}\\z")
|
|
140
|
+
end
|
|
141
|
+
end
|
|
127
142
|
end
|
data/lib/judges.rb
CHANGED