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)
In pattern: SUPERPATTERN
Frequency: 5
Non-data size: 8
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: scikit-image/scikit-image
Commit Name: ea40a555956467d98c7d321633a73cf408d9a805
Time: 2016-11-08
Author: yue@berkeley.edu
File Name: skimage/color/colorlabel.py
Class Name:
Method Name: _match_label_with_color
Project Name: mil-tokyo/webdnn
Commit Name: 76e11372587646d49fc5948814d2694ba53cb476
Time: 2017-06-29
Author: y.kikura@gmail.com
File Name: src/graph_transpiler/webdnn/graph/traverse.py
Class Name:
Method Name: listup_nodes
Project Name: commonsense/conceptnet5
Commit Name: 7d6c3799784fda8087ee03ba1571cdb809a3ac8d
Time: 2016-07-13
Author: rob@luminoso.com
File Name: conceptnet5/readers/dbpedia.py
Class Name:
Method Name: interlanguage_mapping
Project Name: RaRe-Technologies/gensim
Commit Name: 29968840f350746647f0b0e7c880d9d3866c5522
Time: 2017-05-15
Author: chamberlain.daniel.b@gmail.com
File Name: gensim/topic_coherence/probability_estimation.py
Class Name:
Method Name: p_boolean_document