Converts an object / value into a string representation to pass along in the payload
    :param ref: object or value
    :param max_string_length: maximum number of characters to represent the object
    :return:

def format_reference(ref, max_string_length=1000):
    """
    Converts an object / value into a string representation to pass along in the payload
    :param ref: object or value
    :param max_string_length: maximum number of characters to represent the object
    :return:
    """
    _pass = lambda *args: None
    _numpy_info = ('dtype', 'shape', 'size', 'min', 'max')
    additionals = []
    if _NUMPY_INSTALLED and isinstance(ref, np.ndarray):
        # Check for numpy info
        for np_attr in _numpy_info:
            np_value = getattr(ref, np_attr, None)
            if np_value is not None:
                if inspect.isbuiltin(np_value):
                    try:
                        np_value = np_value()
                    except Exception as e:
                        logging.error(e)
                        continue
                additionals.append((np_attr, np_value))
    elif isinstance(ref, (list, tuple, set, dict)):
        # Check for length of reference
        length = getattr(ref, '__len__', _pass)()
        if length is not None:
            additionals.append(('length', length))

    if additionals:
        vstr = ', '.join(['%s: %s' % a for a in additionals] + [repr(ref)])
    else:
        vstr = repr(ref)

    if len(vstr) > max_string_length:
        vstr = vstr[:max_string_length] + ' ...'

    return vstr