tensorbay.utility.common

Common_loads method, EqMixin class.

common_loads() is a common method for loading an object from a dict or a list of dict.

EqMixin is a mixin class to support __eq__() method, which compares all the instance variables.

tensorbay.utility.common.common_loads(object_class: Type[tensorbay.utility.common._T], contents: Any) tensorbay.utility.common._T[source]

A common method for loading an object from a dict or a list of dict.

Parameters
  • object_class – The class of the object to be loaded.

  • contents – The information of the object in a dict or a list of dict.

Returns

The loaded object.

class tensorbay.utility.common.EqMixin[source]

Bases: object

A mixin class to support __eq__() method.

The __eq__() method defined here compares all the instance variables.

tensorbay.utility.common.locked(func: tensorbay.utility.common._CallableWithoutReturnValue) tensorbay.utility.common._CallableWithoutReturnValue[source]

The decorator to add threading lock for methods.

Parameters

func – The method needs to add threading lock.

Returns

The method with theading locked.

class tensorbay.utility.common.Deprecated(*, since: str, removed_in: Optional[str] = None, substitute: Union[None, str, Callable[[...], Any]] = None)[source]

Bases: object

A decorator for deprecated functions.

Parameters
  • since – The version the function is deprecated.

  • removed_in – The version the function will be removed in.

  • substitute – The substitute function.

class tensorbay.utility.common.KwargsDeprecated(keywords: Tuple[str, ...], *, since: str, removed_in: Optional[str] = None, substitute: Optional[str] = None)[source]

Bases: object

A decorator for the function which has deprecated keyword arguments.

Parameters
  • keywords – The keyword arguments which need to be deprecated.

  • since – The version the keyword arguments are deprecated.

  • remove_in – The version the keyword arguments will be removed in.

  • substitute – The substitute usage.

class tensorbay.utility.common.DefaultValueDeprecated(keyword: str, *, since: str, removed_in: Optional[str] = None)[source]

Bases: object

A decorator for the function which has deprecated argument default value.

Parameters
  • keyword – The argument keyword whose default value needs to be deprecated.

  • since – The version the keyword arguments are deprecated.

  • remove_in – The version the keyword arguments will be removed in.

class tensorbay.utility.common.Disable(*, since: str, enabled_in: Optional[str], reason: Optional[str])[source]

Bases: object

A decorator for the function which is disabled temporarily.

Parameters
  • since – The version the function is disabled temporarily.

  • enabled_in – The version the function will be enabled again.

  • reason – The reason that the function is disabled temporarily.