Module: Cnvrg::Helpers

Extended by:
Helpers
Included in:
Helpers
Defined in:
lib/cnvrg/helpers.rb

Instance Method Summary collapse

Instance Method Details

#checkmarkObject



5
6
7
8
# File 'lib/cnvrg/helpers.rb', line 5

def checkmark
checkmark = "\u2713"
return checkmark.encode('utf-8')
end

#cnvrgignore_contentObject



52
53
54
55
56
57
58
59
# File 'lib/cnvrg/helpers.rb', line 52

def cnvrgignore_content
  %{
           # cnvrg ignore: Ignore the following directories and files
# for example:
# some_dir/
# some_file.txt
        }.strip
end

#cpu_timeObject

cpu



102
103
104
# File 'lib/cnvrg/helpers.rb', line 102

def cpu_time
  Process.clock_gettime(Process::CLOCK_PROCESS_CPUTIME_ID, :microsecond)
end

#get_mem(pid) ⇒ Object

memory



112
113
# File 'lib/cnvrg/helpers.rb', line 112

def get_mem(pid)
end

#internet_connection?Boolean

Returns:

  • (Boolean)


10
11
12
13
14
15
16
# File 'lib/cnvrg/helpers.rb', line 10

def internet_connection?
  begin
    true if open("http://www.google.com/")
  rescue
    false
  end
end

#linux?Boolean

Returns:

  • (Boolean)


45
46
47
# File 'lib/cnvrg/helpers.rb', line 45

def linux?
  not mac? and not windows?
end

#look_for_in_path(path, name) ⇒ Object



90
91
92
93
94
95
96
97
98
# File 'lib/cnvrg/helpers.rb', line 90

def look_for_in_path(path, name)
  url_split = path.split("/")
  url_split.each_with_index do |u, i|
    if u == name
      return i
    end
  end
  return -1
end

#mac?Boolean

Returns:

  • (Boolean)


41
42
43
# File 'lib/cnvrg/helpers.rb', line 41

def mac?
  !!(RUBY_PLATFORM =~ /-darwin\d/)
end

#netrc_domainObject



86
87
88
# File 'lib/cnvrg/helpers.rb', line 86

def netrc_domain
  "cnvrg.io"
end

#readme_contentObject



61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/cnvrg/helpers.rb', line 61

def readme_content
  %{
        # README

        This README would normally contain some context and description about the project. 

        Things you may want to cover:

        * Data description

        * Benchmark and measurement guidelines

        * Used algorithms

        * Scores

        * Configurations

        * Requirements

        * How to run the experiments

        * ...}.strip
end

#remote_urlObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/cnvrg/helpers.rb', line 17

def remote_url
  home_dir = File.expand_path('~')
  config = ""
  begin
    if File.exist? home_dir+"/.cnvrg/config.yml"
      config = YAML.load_file(home_dir+"/.cnvrg/config.yml")
    else
      return "https://cnvrg.io"
    end

  rescue
    return "https://cnvrg.io"
  end
  if !config or config.empty? or config.to_h[:api].nil?
    return "https://cnvrg.io"
  else
    return config.to_h[:api].gsub("/api","")
  end
end

#ubuntu?Boolean

Returns:

  • (Boolean)


48
49
50
51
# File 'lib/cnvrg/helpers.rb', line 48

def ubuntu?
  unix = `cat /etc/lsb-release`.downcase!
  return unix.include? "ubuntu"
end

#wall_timeObject



106
107
108
# File 'lib/cnvrg/helpers.rb', line 106

def wall_time
  Process.clock_gettime(Process::CLOCK_MONOTONIC, :microsecond)
end

#windows?Boolean

Returns:

  • (Boolean)


37
38
39
# File 'lib/cnvrg/helpers.rb', line 37

def windows?
  !!(RUBY_PLATFORM =~ /mswin32|mingw32/)
end