in dell_ai/models.py [0:0]
def _handle_resource_not_found(client, e, model_id, platform_id, num_gpus):
"""
Handle ResourceNotFoundError by providing more specific error messages.
Args:
client: The Dell AI client
e: The original ResourceNotFoundError
model_id: The model ID
platform_id: The platform SKU ID
num_gpus: The number of GPUs
Raises:
ResourceNotFoundError: With a more specific error message
ValidationError: If the configuration is invalid
"""
# If the error is about the model, provide a specific error
if e.resource_type.lower() == "models":
raise ResourceNotFoundError("model", model_id)
# If we can get the model details, check if this might be a configuration issue
try:
model = get_model(client, model_id)
# Check if platform is valid but GPU config is invalid
if platform_id in model.configs_deploy:
valid_configs = model.configs_deploy[platform_id]
valid_gpus = {config.num_gpus for config in valid_configs}
if num_gpus not in valid_gpus:
gpu_list = ", ".join(str(g) for g in sorted(valid_gpus))
raise ValidationError(
f"Invalid number of GPUs ({num_gpus}) for model {model_id} on platform {platform_id}. Valid GPU counts: {gpu_list}",
parameter="num_gpus",
valid_values=sorted(valid_gpus),
)
except ResourceNotFoundError:
# The model truly doesn't exist
raise ResourceNotFoundError("model", model_id)
# If we couldn't determine a more specific cause, re-raise the original error
raise e