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")

After Change


    Returns:
        Union[int, float]: Detected resource quantity.
    
    if field_name not in container_resources:
        // No limit/resource field.
        return float("inf")
    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)
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 5

Non-data size: 5

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: microsoft/nni
Commit Name: 192a807b39bc029c273c2d1349fb73850ed9484c
Time: 2020-12-13
Author: Quanlu.Zhang@microsoft.com
File Name: nni/retiarii/converter/graph_gen.py
Class Name:
Method Name: convert_module


Project Name: deepmipt/DeepPavlov
Commit Name: c3a9468a86a0abdf78c9a8d55a0147b0a61fb16b
Time: 2018-02-05
Author: arkhipov@yahoo.com
File Name: deeppavlov/models/ner/ner.py
Class Name: NER
Method Name: infer


Project Name: keras-team/keras
Commit Name: 45577f7959dab9e29044d5ac794c8349624b4bcc
Time: 2015-10-26
Author: farizrahman4u@gmail.com
File Name: keras/layers/core.py
Class Name: Lambda
Method Name: output_shape


Project Name: GPflow/GPflow
Commit Name: f36052b395dc48a473dcc5b49d8d9a3b5d6f58ba
Time: 2020-03-18
Author: st--@users.noreply.github.com
File Name: gpflow/conditionals/util.py
Class Name:
Method Name: sample_mvn