Module: DeepdetectRuby

Extended by:
Configuration
Defined in:
lib/info.rb,
lib/train.rb,
lib/predict.rb,
lib/service.rb,
lib/dede_server.rb,
lib/configuration.rb,
lib/deepdetect_ruby.rb,
lib/deepdetect_ruby/version.rb

Defined Under Namespace

Modules: Configuration Classes: DedeServer, Predict, Service, Train

Constant Summary collapse

VERSION =
"1.0.2"

Constants included from Configuration

Configuration::DEFAULT_HOST, Configuration::DEFAULT_HOST_TRAIN, Configuration::VALID_CONFIG_KEYS

Class Method Summary collapse

Methods included from Configuration

configure, extended, options, reset

Class Method Details

.get_server(server_index = 1) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/info.rb', line 21

def self.get_server(server_index = 1)
  debug = DeepdetectRuby.options[:debug]
  if DeepdetectRuby.options[:is_scaling]
    servers = DeepdetectRuby.options[:servers].split(",").map{|s| s.strip}
    puts "\n[get_server] server #{server_index} is running. We have #{servers.count} server working together. \n" if debug
    if !servers.nil? && servers.present?
      dede_index = server_index - 1
      if dede_index >= 0
        return servers[dede_index]
      else
        puts "\n[DedeServer] server_index must be greater than 0 \n" if debug
      end
    else
      puts "\n[DedeServer] hosts must not be empty \n" if debug
    end
  else
    puts "\n[get_server] single server is running \n" if debug
    return DeepdetectRuby.options[:host]
  end
end

.info(options = {}) ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/info.rb', line 2

def self.info(options = {})
  begin
    server_index = options[:server_index] || 1
    dede_host = DeepdetectRuby::DedeServer.get_server(server_index)
    info_url = "#{dede_host}/info"
    dede_info = HTTParty.get(info_url)
    info = JSON.parse(dede_info.to_json)
    info.extend DeepSymbolizable
    return info.deep_symbolize
  rescue Exception => e
    puts "\n[DeepdetectRuby Info]. #{e.to_s} \n"
    return nil
  end
end

.status(options = {}) ⇒ Object



17
18
19
# File 'lib/info.rb', line 17

def self.status(options = {})
  info(options)
end