optify-config 1.3.1-arm64-darwin → 1.4.1-arm64-darwin
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/lib/optify.rb +1 -0
- data/lib/optify_ruby/3.2/optify_ruby.bundle +0 -0
- data/lib/optify_ruby/3.4/optify_ruby.bundle +0 -0
- data/lib/optify_ruby/get_options_preferences.rb +13 -0
- data/lib/optify_ruby/provider_module.rb +20 -8
- data/rbi/optify.rbi +18 -1
- data/sig/optify.rbs +14 -1
- metadata +13 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d5323df292e4343c8e96adefab27f4c86fb02144af156f9c68c9d121365186c5
|
4
|
+
data.tar.gz: ab4346606d0624c868cb9bb980f25567f99a0961651b715620b16915ac3b857d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f660032bbb46c1ec49b9eca62cb7f7b07b213c4050c8794bc7b6d493418c281038c7acc2e0ca2bde8de59fbb7b67961c8d39df8f7e64104b80b972dc38a445a0
|
7
|
+
data.tar.gz: 1230db10484560654152e9bfe0bdc41dd0f2d33e8728b23f5998a607ef625a3c7eff6adecb80268261d6e2aca84cbf869a881e706387b921f44490486c58bfe1
|
data/lib/optify.rb
CHANGED
Binary file
|
Binary file
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
# typed: strict
|
3
|
+
|
4
|
+
module Optify
|
5
|
+
# Preferences for `get_options`.
|
6
|
+
class GetOptionsPreferences
|
7
|
+
# @param overrides [Hash]
|
8
|
+
#: (Hash[untyped, untyped] overrides) -> void
|
9
|
+
def overrides=(overrides)
|
10
|
+
self.overrides_json = overrides.to_json
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -11,7 +11,7 @@ module Optify
|
|
11
11
|
#: (Array[String] feature_names) -> Array[String]
|
12
12
|
def get_canonical_feature_names(feature_names)
|
13
13
|
# Try to optimize a typical case where there are just a few features.
|
14
|
-
# Ideally in production, a single feature that imports many other features is used for the most common
|
14
|
+
# Ideally in production, a single feature that imports many other features is used for the most common scenarios.
|
15
15
|
# Benchmarks show that it is faster to use a loop than to call the Rust implementation which involves making a `Vec<String>` and returning a `Vec<String>`.
|
16
16
|
if feature_names.length < 4
|
17
17
|
feature_names.map { |feature_name| get_canonical_feature_name(feature_name) }
|
@@ -87,19 +87,31 @@ module Optify
|
|
87
87
|
# Cache directly in Ruby instead of Rust because:
|
88
88
|
# * Avoid any possible conversion overhead.
|
89
89
|
# * Memory management: probably better to do it in Ruby for a Ruby app and avoid memory in Rust.
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
# When there are over 7 names, then it is faster to convert them with one call to Rust.
|
94
|
-
feature_names = get_canonical_feature_names(feature_names)
|
90
|
+
if preferences&.overrides?
|
91
|
+
Kernel.raise ArgumentError,
|
92
|
+
'Caching when overrides are given is not supported. Do not pass cache options when using overrides in preferences.'
|
95
93
|
end
|
96
94
|
|
95
|
+
init unless @cache
|
96
|
+
feature_names = get_canonical_feature_names(feature_names) unless preferences&.skip_feature_name_conversion
|
97
|
+
|
97
98
|
cache_key = [key, feature_names, config_class]
|
98
99
|
result = @cache&.fetch(cache_key, NOT_FOUND_IN_CACHE_SENTINEL)
|
99
100
|
return result unless result.equal?(NOT_FOUND_IN_CACHE_SENTINEL)
|
100
101
|
|
101
|
-
|
102
|
-
|
102
|
+
# Handle a cache miss.
|
103
|
+
|
104
|
+
# We can avoid converting the features names because they're already converted, if that was desired.
|
105
|
+
if preferences.nil?
|
106
|
+
preferences = GetOptionsPreferences.new
|
107
|
+
preferences.skip_feature_name_conversion = true
|
108
|
+
else
|
109
|
+
# Indeed the copying of preferences could be wasteful, but this only happens on a cache miss
|
110
|
+
# and when no custom preferences are provided.
|
111
|
+
preferences = preferences.dup
|
112
|
+
preferences.skip_feature_name_conversion = true
|
113
|
+
end
|
114
|
+
|
103
115
|
result = get_options(key, feature_names, config_class, nil, preferences)
|
104
116
|
|
105
117
|
T.must(@cache)[cache_key] = result
|
data/rbi/optify.rbi
CHANGED
@@ -43,8 +43,25 @@ module Optify
|
|
43
43
|
|
44
44
|
# Preferences when getting options.
|
45
45
|
class GetOptionsPreferences
|
46
|
-
|
46
|
+
# Indicates if overrides are set.
|
47
|
+
sig { returns(T::Boolean) }
|
48
|
+
def overrides?; end
|
49
|
+
|
50
|
+
# Set overrides to apply after building the options based on the feature names.
|
51
|
+
# Do not provide overrides when requesting cached options.
|
52
|
+
# @param value The overrides to apply.
|
53
|
+
sig { params(value: T.nilable(T::Hash[T.untyped, T.untyped])).void }
|
54
|
+
def overrides=(value); end
|
55
|
+
|
56
|
+
# Set overrides to apply after building the options based on the feature names.
|
57
|
+
# Do not provide overrides when requesting cached options.
|
58
|
+
# @param value The overrides to apply as serialized JSON.
|
59
|
+
sig { params(value: T.nilable(String)).void }
|
60
|
+
def overrides_json=(value); end
|
61
|
+
|
62
|
+
sig { params(value: T::Boolean).void }
|
47
63
|
def skip_feature_name_conversion=(value); end
|
64
|
+
|
48
65
|
sig { returns(T::Boolean) }
|
49
66
|
def skip_feature_name_conversion; end
|
50
67
|
end
|
data/sig/optify.rbs
CHANGED
@@ -35,7 +35,20 @@ end
|
|
35
35
|
|
36
36
|
# Preferences when getting options.
|
37
37
|
class Optify::GetOptionsPreferences
|
38
|
-
|
38
|
+
# Indicates if overrides are set.
|
39
|
+
def overrides?: () -> bool
|
40
|
+
|
41
|
+
# Set overrides to apply after building the options based on the feature names.
|
42
|
+
# Do not provide overrides when requesting cached options.
|
43
|
+
# @param value The overrides to apply.
|
44
|
+
def overrides=: (::Hash[untyped, untyped]? value) -> void
|
45
|
+
|
46
|
+
# Set overrides to apply after building the options based on the feature names.
|
47
|
+
# Do not provide overrides when requesting cached options.
|
48
|
+
# @param value The overrides to apply as serialized JSON.
|
49
|
+
def overrides_json=: (String? value) -> void
|
50
|
+
|
51
|
+
def skip_feature_name_conversion=: (bool value) -> void
|
39
52
|
|
40
53
|
def skip_feature_name_conversion: () -> bool
|
41
54
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: optify-config
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.1
|
5
5
|
platform: arm64-darwin
|
6
6
|
authors:
|
7
7
|
- Justin D. Harris
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-05-
|
11
|
+
date: 2025-05-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sorbet-runtime
|
@@ -16,56 +16,56 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.5.
|
19
|
+
version: 0.5.12083
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.5.
|
26
|
+
version: 0.5.12083
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake-compiler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 1.
|
33
|
+
version: 1.3.0
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 1.
|
40
|
+
version: 1.3.0
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rbs
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 3.9.
|
47
|
+
version: 3.9.3
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 3.9.
|
54
|
+
version: 3.9.3
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: sorbet
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 0.5.
|
61
|
+
version: 0.5.12083
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: 0.5.
|
68
|
+
version: 0.5.12083
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: tapioca
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -86,14 +86,14 @@ dependencies:
|
|
86
86
|
requirements:
|
87
87
|
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: 3.6.
|
89
|
+
version: 3.6.8
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: 3.6.
|
96
|
+
version: 3.6.8
|
97
97
|
description: |-
|
98
98
|
Simplifies getting the right configuration options for a process using pre-loaded configurations
|
99
99
|
from files to manage options for experiments or flights.
|
@@ -106,6 +106,7 @@ files:
|
|
106
106
|
- lib/optify_ruby/3.2/optify_ruby.bundle
|
107
107
|
- lib/optify_ruby/3.4/optify_ruby.bundle
|
108
108
|
- lib/optify_ruby/base_config.rb
|
109
|
+
- lib/optify_ruby/get_options_preferences.rb
|
109
110
|
- lib/optify_ruby/implementation.rb
|
110
111
|
- lib/optify_ruby/options_metadata.rb
|
111
112
|
- lib/optify_ruby/provider_module.rb
|