compute_unit 0.2.1 → 0.3.0

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: 82032a2c2110769430dd7b1a3f4b624227275eb5a3a3e62f6e0e42bdb41790c3
4
- data.tar.gz: 7e45e2b1cd11b5cb0cfb40b00fee99a20ecc6e125064a2251372c4e14f22e1ca
3
+ metadata.gz: dcc45e864245505b64cd82233ca7f8ad70d0d12ca1a976862ba46c80e66fefc8
4
+ data.tar.gz: 6903aff2b613ee6f88c41aa051e65404f31c8923bab2059323dfd27bc99cc5e0
5
5
  SHA512:
6
- metadata.gz: 8c818aa6ba28c5af8d57e8e99e4deb81a3eb4cc19532ce68d4888e6f644d780360c5568272667a9c5edc4807da90b49ee7c454c86164d925eab409c0332385c2
7
- data.tar.gz: 2898757c00752709b8cfec4a4137f3bc65310d0e1af2a68637a1b3eba385f7e0188acb2790538b40e1fd2a650f65152175bfd99947cdd2d023baee3fa321aa64
6
+ metadata.gz: a971813c562bc8c29305f1fe3668f229b52bd018049d36879fcc943a935232e8d8bb34095e74643ca9d3da594796a4cdfdc33fe06b36a8501a75c0a330489cb3
7
+ data.tar.gz: bc17da953ab1904661c7037977c36b1dda69c7c4236c5854730743fa9332987a92ba3891e97052c4ee9361bea7a0b830a917235e15f1db75e8246b7835715a6e
@@ -2,6 +2,13 @@
2
2
 
3
3
  ## Unrleased
4
4
 
5
+ ## 0.3.0
6
+ Released 6/16/2020
7
+
8
+ * Add name method to the cpu class
9
+ * Use constant for proc path
10
+ * Use debug when kernel file doesn't exist
11
+
5
12
  ## 0.2.1
6
13
  Released 6/6/2020
7
14
 
@@ -7,6 +7,8 @@ module ComputeUnit
7
7
  DEVICE_CLASS = '060000'
8
8
  DEVICE_CLASS_NAME = 'CPU'
9
9
  # @return [Array] - returns a list of device paths of all devices considered for display
10
+ alias name model
11
+
10
12
  def self.devices
11
13
  ComputeUnit::ComputeBase.devices.find_all do |device|
12
14
  ComputeUnit::Device.device_class(device) == DEVICE_CLASS
@@ -10,7 +10,7 @@ module ComputeUnit
10
10
  class Device
11
11
  # We can supply a mock sysfs path in order to test with containers and other scenarios
12
12
  SYSFS_DEVICES_PATH = File.join(ComputeUnit::SYSFS_PATH, 'bus', 'pci', 'devices')
13
-
13
+ PROC_PATH = ENV['PROC_PATH'] || '/proc'
14
14
  attr_reader :device_class_id,
15
15
  :device_id,
16
16
  :device_vendor_id,
@@ -130,7 +130,7 @@ module ComputeUnit
130
130
  rescue Errno::EINVAL, Errno::EPERM
131
131
  default
132
132
  rescue Errno::ENOENT
133
- logger.warn("File #{path} does not exist, using defaults")
133
+ logger.debug("File #{path} does not exist, using defaults")
134
134
  default
135
135
  rescue Errno::EACCES
136
136
  logger.fatal('run this command as root or with sudo, using default value')
@@ -271,7 +271,7 @@ module ComputeUnit
271
271
  logger.fatal(e.message)
272
272
  default
273
273
  rescue Errno::ENOENT
274
- logger.warn("File #{path} does not exist")
274
+ logger.debug("File #{path} does not exist")
275
275
  default
276
276
  rescue Errno::EACCES
277
277
  logger.fatal('Run this command as root or with sudo')
@@ -8,6 +8,7 @@ module ComputeUnit
8
8
  MAKE = 'Nvidia'
9
9
  SUBTYPE = 'nvidia'
10
10
  NVIDIA_SMI = '/usr/bin/nvidia-smi'
11
+ NVIDIA_PROC_PATH = ENV['NVIDIA_PROC_PATH'] || File.join(ComputeUnit::Device::PROC_PATH, 'driver', 'nvidia', 'gpus')
11
12
 
12
13
  def initialize(device_path, opts = {})
13
14
  data = self.class.read_information_file(device_path).merge(opts)
@@ -159,7 +160,7 @@ module ComputeUnit
159
160
  def information_file
160
161
  @information_file ||= begin
161
162
  device_name = File.basename(device_path)
162
- File.join('/proc/driver/nvidia/gpus', device_name, 'information')
163
+ File.join(NVIDIA_PROC_PATH, device_name, 'information')
163
164
  end
164
165
  end
165
166
 
@@ -209,7 +210,8 @@ module ComputeUnit
209
210
  # :device_minor=>"7"}
210
211
  def self.read_information_file(device_path)
211
212
  device_name = File.basename(device_path)
212
- information_file = "/proc/driver/nvidia/gpus/#{device_name}/information"
213
+ information_file = File.join(NVIDIA_PROC_PATH, device_name, 'information')
214
+
213
215
  File.open(information_file, 'r') do |file|
214
216
  content = file.read
215
217
  content.scan(/\n?([\w\s]*):\s+(.*)/).map { |key, value| [key.downcase.tr(' ', '_').to_sym, value] }.to_h
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ComputeUnit
4
- VERSION = '0.2.1'
4
+ VERSION = '0.3.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: compute_unit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Corey Osman
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-06-07 00:00:00.000000000 Z
11
+ date: 2020-06-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: opencl_ruby_ffi