hydrosdk.signature module

class hydrosdk.signature.AnyDimSize

Bases: object

Validation class for dimensions, used for -1 dims

class hydrosdk.signature.ProfilingType(value)

Bases: enum.Enum

Profiling Types are used to tell monitoring services how to analyse signature fields.

hydrosdk.signature.ModelSignature_to_signature_dict(signature)

Serializes ModelSignature into a signature dict

Parameters

signature (hydro_serving_grpc.serving.contract.signature_pb2.ModelSignature) – model signature obj

Raises

TypeError – If signature invalid

Returns

dict with signature_name, inputs, outputs

Return type

dict

hydrosdk.signature.attach_ds(result_dict, field)

Adds dtype or subfields

Parameters
  • result_dict (dict) –

  • field

Raises

ValueError – If field invalid

Returns

result_dict with dtype or subfields

Return type

dict

hydrosdk.signature.field_from_dict(field_name, field_dict)

Deserialization into ModelField.

Parameters
  • field_name (str) –

  • field_dict (dict) – data

Raises

ValueError – If data_dict is invalid

Returns

ModelField

Return type

hydro_serving_grpc.serving.contract.field_pb2.ModelField

hydrosdk.signature.field_to_dict(field)

Serializes model field into name, profile and optional shape

Parameters

field (hydro_serving_grpc.serving.contract.field_pb2.ModelField) – model field

Raises

TypeError – If field is invalid

Returns

dict with name and profile

Return type

dict

hydrosdk.signature.mock_input_data(signature)

Creates dummy input data

Parameters

signature (hydro_serving_grpc.serving.contract.signature_pb2.ModelSignature) –

Returns

list of input tensors

hydrosdk.signature.parse_field(name, dtype, shape, profile=ProfilingType.NONE)

Creates a proto ModelField object

Parameters
  • name (str) – name of a model field

  • dtype (Union[str, int, numpy.dtype]) – data type of model field, either string dtype alias (“double”, “int” .. ), proto DataType value or name, or a Numpy data type

  • shape (Iterable[int]) – shape of a model field

  • profile (hydrosdk.signature.ProfilingType) – profile of a model field

Raises

ValueError – If dtype is invalid

Returns

ModelField proto object

Return type

hydro_serving_grpc.serving.contract.field_pb2.ModelField

hydrosdk.signature.shape_to_dict(shape=None)

Serializes model field’s shape to dict

Parameters

shape (Optional[TensorShape]) – TensorShape

Returns

dict with dim

Return type

dict

hydrosdk.signature.signature_dict_to_ModelSignature(data)

Internal method. A method that creates ModelSignature out of a signature dict. :param data: :return:

Parameters

data (dict) –

Return type

hydro_serving_grpc.serving.contract.signature_pb2.ModelSignature