def cast_metric_val(val):
    # ensure that the metric value is a numeric type
    if not isinstance(val, NumericTypes):
        # Try the int conversion first because want to preserve
        # whether the value is an int or a float. If neither work,
        # raise a ValueError to be handled elsewhere
        for cast in [int, float]:
            try:
                val = cast(val)
                return val
            except __HOLE__:
                continue
        raise ValueError
    return val
dataset/ETHPy150Open serverdensity/sd-agent/util.py/cast_metric_val