lab_coat 0.1.5 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ruby-version +1 -0
- data/CHANGELOG.md +5 -0
- data/lib/lab_coat/experiment.rb +20 -9
- data/lib/lab_coat/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '0628ef15e87d895d4df9ae050de05097b419938cacc86b057c1770599beecf50'
|
4
|
+
data.tar.gz: 17b42de37d69c9a9537c4af31b4a4be1c485d943d259a2eba3e72ddc7120d4d1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 68a87b23225316873c1a0db120bc4e882bd981cee36192b767170944166f8975f4400397a9e517e2aa626f512632e25587ea5c528ea15eb7b6b4b3bf7724cee7
|
7
|
+
data.tar.gz: 7797d9da59a9cc808cdf6226c300864a0e67d40989efcadd87284b7efe8f1c2ad5a476d9994f3a1969d4bf0ed1f3894843188d5250d732413fe8970e091a56e1
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
3.2.4
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
## [0.1.7] - Unreleased
|
2
|
+
|
3
|
+
## [0.1.6] - 2024-06-17
|
4
|
+
- [#1](https://github.com/omkarmoghe/lab_coat/issues/1)
|
5
|
+
|
1
6
|
## [0.1.5] - 2024-05-20
|
2
7
|
- Adds `select_observation` to allow users to control which observation value is returned by the experiment. This helps with controlled rollout.
|
3
8
|
|
data/lib/lab_coat/experiment.rb
CHANGED
@@ -3,6 +3,8 @@
|
|
3
3
|
module LabCoat
|
4
4
|
# A base experiment class meant to be subclassed to define various experiments.
|
5
5
|
class Experiment
|
6
|
+
OBSERVATIONS = %w[control candidate].freeze
|
7
|
+
|
6
8
|
attr_reader :name, :context
|
7
9
|
|
8
10
|
def initialize(name)
|
@@ -76,24 +78,33 @@ module LabCoat
|
|
76
78
|
# It's not recommended to override this method.
|
77
79
|
# @param context [Hash] Any data needed at runtime.
|
78
80
|
# @return [Object] An `Observation` value.
|
79
|
-
def run!(**context) # rubocop:disable Metrics/MethodLength
|
81
|
+
def run!(**context) # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
|
80
82
|
# Set the context for this run.
|
81
83
|
@context = context
|
82
84
|
|
83
85
|
# Run the control and exit early if the experiment is not enabled.
|
84
|
-
|
85
|
-
|
86
|
-
|
86
|
+
unless enabled?
|
87
|
+
control_obs = Observation.new("control", self) { control }
|
88
|
+
raised(control_obs) if control_obs.raised?
|
89
|
+
return control_obs.value
|
90
|
+
end
|
87
91
|
|
88
|
-
#
|
89
|
-
|
90
|
-
|
92
|
+
# Otherwise run the control and candidate in random order.
|
93
|
+
observations = OBSERVATIONS.shuffle.map do |name|
|
94
|
+
Observation.new(name, self) { public_send(name) }.tap do |observation|
|
95
|
+
raised(observation) if observation.raised?
|
96
|
+
end
|
97
|
+
end
|
91
98
|
|
92
99
|
# Compare and publish the results.
|
93
|
-
result =
|
100
|
+
result = if observations.first.name == "control"
|
101
|
+
Result.new(self, observations.first, observations.last)
|
102
|
+
else
|
103
|
+
Result.new(self, observations.last, observations.first)
|
104
|
+
end
|
94
105
|
publish!(result)
|
95
106
|
|
96
|
-
#
|
107
|
+
# Return the selected observations, control by default.
|
97
108
|
select_observation(result).value.tap do
|
98
109
|
# Reset the context for this run. Done here so that `select_observation` has access to the runtime context.
|
99
110
|
@context = {}
|
data/lib/lab_coat/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lab_coat
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Omkar Moghe
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-06-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: minitest
|
@@ -46,6 +46,7 @@ extensions: []
|
|
46
46
|
extra_rdoc_files: []
|
47
47
|
files:
|
48
48
|
- ".rubocop.yml"
|
49
|
+
- ".ruby-version"
|
49
50
|
- CHANGELOG.md
|
50
51
|
- LICENSE.txt
|
51
52
|
- README.md
|
@@ -77,7 +78,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
77
78
|
- !ruby/object:Gem::Version
|
78
79
|
version: '0'
|
79
80
|
requirements: []
|
80
|
-
rubygems_version: 3.4.
|
81
|
+
rubygems_version: 3.4.19
|
81
82
|
signing_key:
|
82
83
|
specification_version: 4
|
83
84
|
summary: A simple experiment library to safely test new code paths.
|