dantro.mixins.proxy_support module

This module implements mixins that provide proxy support

class dantro.mixins.proxy_support.ProxySupportMixin[source]

Bases: object

This Mixin class overwrites the data property to allow and resolve proxy objects.

It should be used to add support for certain proxy types to a container.

A proxy object is a place holder for data that is not yet loaded. It will only be loaded if the data property is directly or indirectly accessed.

DATA_ALLOW_PROXY = True
PROXY_RESOLVE_ASTYPE = None
PROXY_RETAIN = False
PROXY_REINSTATE_FAIL_ACTION = 'raise'
_retained_proxy = None
property data

The container data. If the data is a proxy, this call will lead to the resolution of the proxy.

Returns

The data stored in this container

property data_is_proxy

Returns true, if this is proxy data

Returns

Whether the currently stored data is a proxy object

Return type

bool

property proxy

If the data is proxy, returns the proxy data object without using the .data attribute (which would trigger resolving the proxy); else returns None.

Returns

If the data is proxy, return the

proxy object; else None.

Return type

Union[AbstractDataProxy, None]

reinstate_proxy()[source]

Re-instate a previously retained proxy object, discarding _data.

_format_info() → str[source]

Adds an indicator to whether data is proxy to the info string. Additionally, the proxy tags are appended.

class dantro.mixins.proxy_support.Hdf5ProxySupportMixin[source]

Bases: dantro.mixins.proxy_support.ProxySupportMixin

Specializes the ProxySupportMixin to the capabilities of Hdf5DataProxy, i.e. it allows access to the cached properties of the proxy object without resolving it.

property dtype

Returns dtype, proxy-aware

property shape

Returns shape, proxy-aware

property ndim

Returns ndim, proxy-aware

property size

Returns size, proxy-aware

property chunks

Returns chunks, proxy-aware

DATA_ALLOW_PROXY = True
PROXY_REINSTATE_FAIL_ACTION = 'raise'
PROXY_RESOLVE_ASTYPE = None
PROXY_RETAIN = False
_format_info() → str

Adds an indicator to whether data is proxy to the info string. Additionally, the proxy tags are appended.

_retained_proxy = None
property data

The container data. If the data is a proxy, this call will lead to the resolution of the proxy.

Returns

The data stored in this container

property data_is_proxy

Returns true, if this is proxy data

Returns

Whether the currently stored data is a proxy object

Return type

bool

property proxy

If the data is proxy, returns the proxy data object without using the .data attribute (which would trigger resolving the proxy); else returns None.

Returns

If the data is proxy, return the

proxy object; else None.

Return type

Union[AbstractDataProxy, None]

reinstate_proxy()

Re-instate a previously retained proxy object, discarding _data.