fino 1.4.0 → 1.5.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: ee8bdd56792ffd6eed11da668a8df8785c85cc59d1bad28789131be52b7d4fe3
4
- data.tar.gz: b3d2732be842a1f04dde6faa88c89c43a39198d017e94fc8939aa3a6bec09d5a
3
+ metadata.gz: b2b3b4a00d7564afb4a9d51b1ef35e87f0af7bafb9403a5155b0931d5f3a466d
4
+ data.tar.gz: 579a93663bf8401af70283bb20b95bcd2cea8af4185ed4c422604ddad8734176
5
5
  SHA512:
6
- metadata.gz: 6a24212d5ee902d515e6566a83473e4e2a980b0dc294da36071d5b6effb8c82acf3f3836c6beefce4880dc64ff43b4df56a53e366cb9c685ffdddc0c61f26f46
7
- data.tar.gz: 27b249d2c12c74192af82b6260335044bb2fa89cd8d97d033bd4838b372c0b5e9e5c0a989544a442e7b44fda957b3925f0ed82c0317fed458a3115daa024bd9b
6
+ metadata.gz: b946c8453fa1d6b09c088360420306fa16bb27b890e84967f458361f52a311bab1551f081830c1e37e073c85e0ee47d660ea9b2aeccbdb7ae9c7081eadb62118
7
+ data.tar.gz: e43d7a8f613bd7cc605f07d008c981021a7b593a974cf4a9f005c76d7ae5a9b7a8b498e4f8478b6cb287bcd58442198ff45a06e33fe3988b06cc016d13de79f5
data/README.md CHANGED
@@ -74,6 +74,8 @@ Fino.set(model: "gpt-5", at: :openai, overrides: { "qa" => "our_local_model_not_
74
74
 
75
75
  Fino.value(:model, at: :openai) #=> "gpt-5"
76
76
  Fino.value(:model, at: :openai, for: "qa") #=> "our_local_model_not_to_pay_to_sam_altman"
77
+
78
+ Fino.setting(:model, at: :openai).overrides #=> { "qa" => "our_local_model_not_to_pay_to_sam_altman" }
77
79
  ```
78
80
 
79
81
  ### A/B testing
data/lib/fino/cache.rb CHANGED
@@ -1,11 +1,31 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Fino::Cache
4
- def fetch(key, &)
4
+ def exist?(key)
5
+ raise NotImplementedError
6
+ end
7
+
8
+ def read(key)
5
9
  raise NotImplementedError
6
10
  end
7
11
 
8
12
  def write(key, value)
9
13
  raise NotImplementedError
10
14
  end
15
+
16
+ def fetch(key, &block)
17
+ raise NotImplementedError
18
+ end
19
+
20
+ def fetch_multi(*keys, &block)
21
+ raise NotImplementedError
22
+ end
23
+
24
+ def delete(key)
25
+ raise NotImplementedError
26
+ end
27
+
28
+ def clear
29
+ raise NotImplementedError
30
+ end
11
31
  end
@@ -1,25 +1,41 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Fino::Configuration
4
- attr_reader :registry, :adapter_builder_block, :cache_builder_block, :pipeline_builder_block
4
+ attr_reader :registry, :pipeline_builder_block
5
5
 
6
6
  def initialize(registry)
7
7
  @registry = registry
8
8
  end
9
9
 
10
+ def adapter_builder_block
11
+ @wrapped_adapter_builder_block || @adapter_builder_block
12
+ end
13
+
10
14
  def adapter(&block)
11
15
  @adapter_builder_block = block
12
16
  end
13
17
 
18
+ def wrap_adapter(&block)
19
+ @wrapped_adapter_builder_block = proc { block.call(@adapter_builder_block.call) }
20
+ end
21
+
22
+ def cache_builder_block
23
+ @wrapped_cache_builder_block || @cache_builder_block
24
+ end
25
+
14
26
  def cache(&block)
15
27
  @cache_builder_block = block
16
28
  end
17
29
 
30
+ def wrap_cache(&block)
31
+ @wrapped_cache_builder_block = proc { block.call(@cache_builder_block.call) }
32
+ end
33
+
18
34
  def pipeline(&block)
19
35
  @pipeline_builder_block = block
20
36
  end
21
37
 
22
- def settings(&)
23
- Fino::Registry::DSL.new(registry).instance_eval(&)
38
+ def settings(&block)
39
+ Fino::Registry::DSL.new(registry).instance_eval(&block)
24
40
  end
25
41
  end
@@ -28,13 +28,11 @@ class Fino::Definition::Setting
28
28
  end
29
29
 
30
30
  def default
31
- return @default if defined?(@default)
32
-
33
- @default = options[:default]
31
+ defined?(@default) ? @default : @default = type_class.deserialize(options[:default])
34
32
  end
35
33
 
36
34
  def description
37
- options[:description]
35
+ defined?(@description) ? @description : @description = options[:description]
38
36
  end
39
37
 
40
38
  def path
@@ -9,8 +9,10 @@ class Fino::Pipe::Cache
9
9
  end
10
10
 
11
11
  def read(setting_definition)
12
- cache.fetch(setting_definition.key) do
13
- pipe.read(setting_definition)
12
+ return cache.read(setting_definition.key) if cache.exist?(setting_definition.key)
13
+
14
+ pipe.read(setting_definition).tap do |result|
15
+ cache.write(setting_definition.key, result)
14
16
  end
15
17
  end
16
18
 
data/lib/fino/pipeline.rb CHANGED
@@ -8,26 +8,20 @@ class Fino::Pipeline
8
8
  def initialize(storage, pipes = [])
9
9
  @storage = storage
10
10
  @pipes = pipes
11
- @pipe_wrapper = ->(pipe) { pipe }
12
11
  end
13
12
 
14
- def use(pipe_class, *args, **kwargs, &block)
15
- pipes << ->(pipe) { pipe_class.new(pipe, *args, **kwargs, &block) }
16
- @pipeline = nil
17
- end
18
-
19
- def wrap(&block)
20
- @pipe_wrapper = block
13
+ def use(pipe_class, ...)
14
+ pipes << ->(pipe) { pipe_class.new(pipe, ...) }
21
15
  @pipeline = nil
22
16
  end
23
17
 
24
18
  private
25
19
 
26
- attr_reader :storage, :pipes, :pipe_wrapper
20
+ attr_reader :storage, :pipes
27
21
 
28
22
  def pipeline
29
- @pipeline ||= pipes.inject(pipe_wrapper.call(storage)) do |pipe, builder|
30
- pipe_wrapper.call(builder.call(pipe))
23
+ @pipeline ||= pipes.inject(storage) do |pipe, builder|
24
+ builder.call(pipe)
31
25
  end
32
26
  end
33
27
  end
data/lib/fino/registry.rb CHANGED
@@ -37,7 +37,7 @@ class Fino::Registry
37
37
  )
38
38
  end
39
39
 
40
- def section(section_name, options = {}, &)
40
+ def section(section_name, options = {}, &block)
41
41
  section_definition = Fino::Definition::Section.new(
42
42
  name: section_name,
43
43
  **options
@@ -45,7 +45,7 @@ class Fino::Registry
45
45
 
46
46
  @registry.register_section(section_definition)
47
47
 
48
- SectionDSL.new(section_definition, @registry).instance_eval(&)
48
+ SectionDSL.new(section_definition, @registry).instance_eval(&block)
49
49
  end
50
50
  end
51
51
 
@@ -2,6 +2,7 @@
2
2
 
3
3
  class Fino::Settings::Float
4
4
  include Fino::Setting
5
+ include Fino::Settings::Numeric
5
6
 
6
7
  self.type_identifier = :float
7
8
 
@@ -2,6 +2,7 @@
2
2
 
3
3
  class Fino::Settings::Integer
4
4
  include Fino::Setting
5
+ include Fino::Settings::Numeric
5
6
 
6
7
  self.type_identifier = :integer
7
8
 
@@ -0,0 +1,44 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Fino::Settings::Numeric
4
+ module Unit
5
+ class Generic
6
+ attr_reader :name, :short_name
7
+
8
+ def initialize(name, short_name = nil)
9
+ @name = name
10
+ @short_name = short_name || name
11
+ end
12
+ end
13
+
14
+ class Milliseconds < Generic
15
+ def initialize = super("Milliseconds", "ms")
16
+ end
17
+
18
+ module_function
19
+
20
+ def for(identifier)
21
+ case identifier
22
+ when :ms
23
+ Milliseconds.new
24
+ else
25
+ Generic.new(identifier.to_s.capitalize)
26
+ end
27
+ end
28
+ end
29
+
30
+ def unit
31
+ return unless (identifier = definition.options[:unit])
32
+
33
+ @unit ||= Unit.for(identifier)
34
+ end
35
+
36
+ private
37
+
38
+ def inspectable_attributes
39
+ additional_attributes = {}
40
+ additional_attributes[:unit] = unit.short_name if unit
41
+
42
+ super.merge(additional_attributes)
43
+ end
44
+ end
data/lib/fino/solid.rb CHANGED
@@ -19,7 +19,4 @@ require "fino/solid/setting"
19
19
  require "fino/solid/adapter"
20
20
  require "fino/solid/railtie" if defined?(Rails::Railtie)
21
21
 
22
- if defined?(Rails) && defined?(Rails::Generators)
23
- require "rails/generators"
24
- require_relative "solid/generators/install/install_generator"
25
- end
22
+ require "fino/solid/generators/install/install_generator"
data/lib/fino/version.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Fino
4
- VERSION = "1.4.0"
4
+ VERSION = "1.5.1"
5
5
  REQUIRED_RUBY_VERSION = ">= 3.0.0"
6
6
  end
data/lib/fino.rb CHANGED
@@ -10,8 +10,7 @@ module Fino
10
10
  end
11
11
 
12
12
  def reset!
13
- Thread.current[:fino_library] = nil
14
-
13
+ @library = nil
15
14
  @registry = nil
16
15
  @configuration = nil
17
16
  end
@@ -22,7 +21,7 @@ module Fino
22
21
  end
23
22
 
24
23
  def library
25
- Thread.current[:fino_library] ||= Fino::Library.new(configuration)
24
+ @library ||= Fino::Library.new(configuration)
26
25
  end
27
26
 
28
27
  def registry
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fino
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.0
4
+ version: 1.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Egor Iskrenkov
@@ -58,6 +58,7 @@ files:
58
58
  - lib/fino/settings/boolean.rb
59
59
  - lib/fino/settings/float.rb
60
60
  - lib/fino/settings/integer.rb
61
+ - lib/fino/settings/numeric.rb
61
62
  - lib/fino/settings/section.rb
62
63
  - lib/fino/settings/string.rb
63
64
  - lib/fino/solid.rb