docarray.helper module

docarray.helper.typename(obj)[source]

Get the typename of object.

Parameters

obj – Target object.

Returns

Typename of the obj.

docarray.helper.deprecate_by(new_fn)[source]

A helper function to label deprecated function

Usage: old_fn_name = deprecate_by(new_fn)

Parameters

new_fn – the new function

Returns

a wrapped function with old function name

docarray.helper.dunder_get(_dict, key)[source]

Returns value for a specified dunderkey A “dunderkey” is just a fieldname that may or may not contain double underscores (dunderscores!) for referencing nested keys in a dict. eg:

>>> data = {'a': {'b': 1}}
>>> dunder_get(data, 'a__b')
1

key ‘b’ can be referrenced as ‘a__b’ :param _dict : (dict, list, struct or object) which we want to index into :param key : (str) that represents a first level or nested key in the dict :rtype: Any :return: (mixed) value corresponding to the key

docarray.helper.random_identity(use_uuid1=False)[source]

Generate random UUID.

..note::

A MAC address or time-based ordering (UUID1) can afford increased database performance, since it’s less work to sort numbers closer-together than those distributed randomly (UUID4) (see here).

A second related issue, is that using UUID1 can be useful in debugging, even if origin data is lost or not explicitly stored.

Parameters

use_uuid1 (bool) – use UUID1 instead of UUID4. This is the default Document ID generator.

Return type

str

Returns

A random UUID.

docarray.helper.random_uuid(use_uuid1=False)[source]

Get a random UUID.

Parameters

use_uuid1 (bool) – Use UUID1 if True, else use UUID4.

Return type

UUID

Returns

A random UUID.

docarray.helper.download_mermaid_url(mermaid_url, output)[source]

Download the jpg image from mermaid_url.

Parameters
  • mermaid_url – The URL of the image.

  • output – A filename specifying the name of the image to be created, the suffix svg/jpg determines the file type of the output image.

Return type

None

docarray.helper.get_request_header()[source]

Return the header of request.

Return type

Dict

Returns

request header

docarray.helper.get_full_version()[source]

Get the version of libraries used in Jina and environment variables.

Return type

Dict

Returns

Version information and environment variables

docarray.helper.random_port()[source]

Get a random available port number from ‘49153’ to ‘65535’.

Return type

Optional[int]

Returns

A random port.