MCPcopy Create free account
hub / github.com/NVIDIA/OpenShell / vm_gpu_device_id

Function vm_gpu_device_id

crates/openshell-driver-vm/src/driver.rs:3200–3224  ·  view source on GitHub ↗
(sandbox: &Sandbox)

Source from the content-addressed store, hash-verified

3198
3199#[allow(clippy::result_large_err)]
3200fn vm_gpu_device_id(sandbox: &Sandbox) -> Result<Option<String>, Status> {
3201 let Some(spec) = sandbox.spec.as_ref() else {
3202 return Ok(None);
3203 };
3204 let gpu_device_ids = VmSandboxDriverConfig::from_sandbox(sandbox)
3205 .map_err(Status::invalid_argument)?
3206 .gpu_device_ids
3207 .unwrap_or_default();
3208 let gpu_requirements = driver_gpu_requirements(spec.resource_requirements.as_ref());
3209 validate_specific_gpu_device_request(
3210 gpu_requirements,
3211 &gpu_device_ids,
3212 "driver_config.gpu_device_ids",
3213 )
3214 .map_err(Status::invalid_argument)?;
3215 if gpu_device_ids.len() > 1 {
3216 return Err(Status::invalid_argument(
3217 "vm driver currently supports at most one gpu_device_ids entry",
3218 ));
3219 }
3220
3221 Ok(gpu_requirements
3222 .is_some()
3223 .then(|| gpu_device_ids.into_iter().next().unwrap_or_default()))
3224}
3225
3226#[allow(clippy::result_large_err)]
3227fn validate_sandbox_id(sandbox_id: &str) -> Result<(), Status> {

Callers 2

validate_gpu_requestFunction · 0.85

Calls 4

driver_gpu_requirementsFunction · 0.85
lenMethod · 0.80
nextMethod · 0.45

Tested by

no test coverage detected