bff50cfc37380140d53debfb140e262a38668db0,python/ray/autoscaler/_private/kubernetes/config.py,,_get_resource,#Any#Any#Any#,102

Before Change




def _get_resource(container_resources, resource_name, field_name):
    if (field_name in container_resources
            and resource_name in container_resources[field_name]):
        return _parse_resource(container_resources[field_name][resource_name])
    else:
        return float("inf")


def _parse_resource(resource):
    resource_str = str(resource)
    if resource_str[-1] == "m":
        return math.ceil(int(resource_str[:-1]) / 1000)

After Change


    resources = container_resources[field_name]
    // Look for keys containing the resource_name. For example,
    // the key "nvidia.com/gpu" contains the key "gpu".
    matching_keys = [key for key in resources if resource_name in key.lower()]
    if len(matching_keys) == 0:
        return float("inf")
    if len(matching_keys) > 1:
        // Should have only one match -- mostly relevant for gpu.
        raise ValueError(f"Multiple {resource_name} types not supported.")
    // E.g. "nvidia.com/gpu" or "cpu".
    resource_key = matching_keys.pop()
    resource_quantity = resources[resource_key]
    return _parse_resource(resource_quantity)


def _parse_resource(resource):
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 7

Instances


Project Name: ray-project/ray
Commit Name: bff50cfc37380140d53debfb140e262a38668db0
Time: 2020-12-18
Author: 62982571+Gekho457@users.noreply.github.com
File Name: python/ray/autoscaler/_private/kubernetes/config.py
Class Name:
Method Name: _get_resource


Project Name: ray-project/ray
Commit Name: dc42abb2f5f7dd059cf6fac3eae2832931925573
Time: 2021-01-18
Author: krfricke@users.noreply.github.com
File Name: python/ray/tune/config_parser.py
Class Name:
Method Name: create_trial_from_spec


Project Name: PetrochukM/PyTorch-NLP
Commit Name: 6a5916968838686e332fb68a10cb30222843fbd9
Time: 2018-04-26
Author: florian.joh.schaefer@gmail.com
File Name: torchnlp/word_to_vector/pretrained_word_vectors.py
Class Name: _PretrainedWordVectors
Method Name: __getitem__