Skip to content

Commit

Permalink
--ammend
Browse files Browse the repository at this point in the history
  • Loading branch information
coolGi69 committed Jun 17, 2024
1 parent 3f2c16d commit e635da4
Showing 1 changed file with 22 additions and 21 deletions.
43 changes: 22 additions & 21 deletions src/linux/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -548,28 +548,29 @@ impl GeneralReadout for LinuxGeneralReadout {
}

fn gpus(&self) -> Result<Vec<String>, ReadoutError> {
match Database::read() {
Ok(db) => {
let devices = get_pci_devices()?;
let mut gpus = vec![];

for device in devices {
if !device.is_gpu(&db) {
continue;
};

if let Some(sub_device_name) = device.get_device_name(&db) {
gpus.push(sub_device_name);
};
}
let db = match Database::read() {
Ok(db) => db,
_ => return Err(ReadoutError::MetricNotAvailable),
};

if gpus.is_empty() {
Err(ReadoutError::MetricNotAvailable)
} else {
Ok(gpus)
}
},
_ => Err(ReadoutError::MetricNotAvailable),

let devices = get_pci_devices()?;
let mut gpus = vec![];

for device in devices {
if !device.is_gpu(&db) {
continue;
};

if let Some(sub_device_name) = device.get_device_name(&db) {
gpus.push(sub_device_name);
};
}

if gpus.is_empty() {
Err(ReadoutError::MetricNotAvailable)
} else {
Ok(gpus)
}
}
}
Expand Down

0 comments on commit e635da4

Please sign in to comment.