Module: Cnvrg::Helpers
Instance Method Summary collapse
- #checkmark ⇒ Object
- #cnvrgignore_content ⇒ Object
-
#cpu_time ⇒ Object
cpu.
-
#get_mem(pid) ⇒ Object
memory.
- #internet_connection? ⇒ Boolean
- #linux? ⇒ Boolean
- #look_for_in_path(path, name) ⇒ Object
- #mac? ⇒ Boolean
- #netrc_domain ⇒ Object
- #os ⇒ Object
- #readme_content ⇒ Object
- #remote_url ⇒ Object
- #ubuntu? ⇒ Boolean
- #wall_time ⇒ Object
- #windows? ⇒ Boolean
Instance Method Details
#checkmark ⇒ Object
6 7 8 9 |
# File 'lib/cnvrg/helpers.rb', line 6 def checkmark checkmark = "\u2713" return checkmark.encode('utf-8') end |
#cnvrgignore_content ⇒ Object
73 74 75 76 77 78 79 80 |
# File 'lib/cnvrg/helpers.rb', line 73 def cnvrgignore_content %{ # cnvrg ignore: Ignore the following directories and files # for example: # some_dir/ # some_file.txt }.strip end |
#cpu_time ⇒ Object
cpu
123 124 125 |
# File 'lib/cnvrg/helpers.rb', line 123 def cpu_time Process.clock_gettime(Process::CLOCK_PROCESS_CPUTIME_ID, :microsecond) end |
#get_mem(pid) ⇒ Object
memory
133 134 |
# File 'lib/cnvrg/helpers.rb', line 133 def get_mem(pid) end |
#internet_connection? ⇒ Boolean
11 12 13 14 15 16 17 |
# File 'lib/cnvrg/helpers.rb', line 11 def internet_connection? begin true if open("http://www.google.com/") rescue false end end |
#linux? ⇒ Boolean
64 65 66 |
# File 'lib/cnvrg/helpers.rb', line 64 def linux? not mac? and not windows? end |
#look_for_in_path(path, name) ⇒ Object
111 112 113 114 115 116 117 118 119 |
# File 'lib/cnvrg/helpers.rb', line 111 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
60 61 62 |
# File 'lib/cnvrg/helpers.rb', line 60 def mac? !!(RUBY_PLATFORM =~ /-darwin\d/) end |
#netrc_domain ⇒ Object
107 108 109 |
# File 'lib/cnvrg/helpers.rb', line 107 def netrc_domain "cnvrg.io" end |
#os ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/cnvrg/helpers.rb', line 39 def os if windows? return "windows" elsif mac? return "mac" elsif ubuntu? return "ubuntu" elsif linux? return "linux" else return "N/A" end end |
#readme_content ⇒ Object
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/cnvrg/helpers.rb', line 82 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_url ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/cnvrg/helpers.rb', line 19 def remote_url home_dir = File.('~') 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
68 69 70 71 |
# File 'lib/cnvrg/helpers.rb', line 68 def ubuntu? unix = `cat /etc/lsb-release`.downcase! return unix.include? "ubuntu" end |
#wall_time ⇒ Object
127 128 129 |
# File 'lib/cnvrg/helpers.rb', line 127 def wall_time Process.clock_gettime(Process::CLOCK_MONOTONIC, :microsecond) end |
#windows? ⇒ Boolean
56 57 58 |
# File 'lib/cnvrg/helpers.rb', line 56 def windows? !!(RUBY_PLATFORM =~ /mswin32|mingw32/) end |