Class: Lemans::Config::Agent
- Inherits:
-
Object
- Object
- Lemans::Config::Agent
- Extended by:
- Conversion
- Defined in:
- lib/lemans/config/agent.rb
Overview
:nodoc:
Defined Under Namespace
Classes: Environment
Constant Summary
Constants included from Conversion
Conversion::DURATION, Conversion::DURATION_FACTORS, Conversion::SIZE, Conversion::SIZE_FACTORS
Instance Attribute Summary collapse
-
#cost_limit ⇒ Object
Returns the value of attribute cost_limit.
-
#environment ⇒ Object
Returns the value of attribute environment.
-
#exec_timeout ⇒ Object
Returns the value of attribute exec_timeout.
-
#models ⇒ Object
Returns the value of attribute models.
-
#name ⇒ Object
Returns the value of attribute name.
-
#step_limit ⇒ Object
Returns the value of attribute step_limit.
-
#timeout ⇒ Object
Returns the value of attribute timeout.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(name, model) ⇒ Agent
constructor
A new instance of Agent.
- #model ⇒ Object
Methods included from Conversion
absolute_path!, float!, integer!, megabytes!, seconds!
Constructor Details
#initialize(name, model) ⇒ Agent
Returns a new instance of Agent.
40 41 42 43 44 45 46 47 48 |
# File 'lib/lemans/config/agent.rb', line 40 def initialize(name, model) @name = name @models = Array(model) @step_limit = 100 @cost_limit = nil @exec_timeout = 300 @timeout = 30 * 60 @environment = Environment.new(network: NetworkPolicy.new) end |
Instance Attribute Details
#cost_limit ⇒ Object
Returns the value of attribute cost_limit.
32 33 34 |
# File 'lib/lemans/config/agent.rb', line 32 def cost_limit @cost_limit end |
#environment ⇒ Object
Returns the value of attribute environment.
32 33 34 |
# File 'lib/lemans/config/agent.rb', line 32 def environment @environment end |
#exec_timeout ⇒ Object
Returns the value of attribute exec_timeout.
32 33 34 |
# File 'lib/lemans/config/agent.rb', line 32 def exec_timeout @exec_timeout end |
#models ⇒ Object
Returns the value of attribute models.
32 33 34 |
# File 'lib/lemans/config/agent.rb', line 32 def models @models end |
#name ⇒ Object
Returns the value of attribute name.
32 33 34 |
# File 'lib/lemans/config/agent.rb', line 32 def name @name end |
#step_limit ⇒ Object
Returns the value of attribute step_limit.
32 33 34 |
# File 'lib/lemans/config/agent.rb', line 32 def step_limit @step_limit end |
#timeout ⇒ Object
Returns the value of attribute timeout.
32 33 34 |
# File 'lib/lemans/config/agent.rb', line 32 def timeout @timeout end |
Class Method Details
.from_config(data) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/lemans/config/agent.rb', line 9 def from_config(data) return if data.nil? name = data.fetch("name") model = data.fetch("model") conf = new(name, model) conf.step_limit = integer!(data["step_limit"]) if data["step_limit"] conf.cost_limit = float!(data["cost_limit"]) if data["cost_limit"] conf.timeout = seconds!(data["timeout"]) if data["timeout"] conf.exec_timeout = seconds!(data["exec_timeout"]) if data["exec_timeout"] if (network_data = data.dig("environment", "network")) conf.environment = Environment.new(network: NetworkPolicy.from_config(network_data)) end conf rescue KeyError => e raise ConfigError, "agent.#{e.key} must be provided" end |
Instance Method Details
#model ⇒ Object
36 |
# File 'lib/lemans/config/agent.rb', line 36 def model = models.first |