fn new(deployment_prefix: &str, deployment: &DeploymentName) -> Option<Self> {
        if !deployment.to_str().starts_with(deployment_prefix) {
            return None;
        }
        // Cut out the prefix. Leaving only GPU part and possible RelicaSet/Pod suffixes.
        let substr = &deployment.to_str()[deployment_prefix.len()..];

        // Remove leading '-'.
        let substr = substr.trim_start_matches('-');
        // Get index of the end of the first suffix.
        let i = substr.find('-').unwrap_or(substr.len());

        // Try to convert first suffix into Gpu. Failure means that it's a Pod name without Gpu
        // suffix, so return default.
        match Gpu::from_str(&substr[..i]) {
            Ok(gpu) => Some(Self(gpu)),
            Err(_e) => Some(Self::default()),
        }
    }
Convert correct Deployment name into a Key. Also works for Pods.
prover/crates/bin/prover_autoscaler/src/key.rs