caikit.runtime.service_generation.protoable
This file contains our logic about what constitutes a proto-able for RPC generation purposes
Attributes
Functions
|
Returns dictionary of protoable types only |
|
Handles various protoable arg types from a Union. |
|
Create a union from list type objects |
|
Helper function that determines the right data model type to use from a Union |
|
Returns True if arg_type is in PROTO_TYPE_MAP(float, int, bool, str, bytes) |
Module Contents
- caikit.runtime.service_generation.protoable.to_protoable_signature(signature: Dict[str, Type]) Dict[str, Type][source]
Returns dictionary of protoable types only If there is a Union, pick the protoable type
- Args:
signature (Dict[str, Type]): module signature of parameters and types
- caikit.runtime.service_generation.protoable.handle_protoables_in_union(field_name: str, arg_type: Type) Type[source]
Handles various protoable arg types from a Union.
If arg_type is a union, then this will return the union back if all types in it are proto-able, or the first proto-able arg type if the union has non-protoable arg types.
If arg_type is not a union nor protoable at all, this returns None.
Examples: Union[protoable_type, non_protoable_type] -> protoable_type Union[protoable_type_1, protoable_type_2] -> Union[protoable_type_1, protoable_type_2] Union[protoable_type_1, protoable_type_2, non_protoable_type] -> protoable_type_1
- caikit.runtime.service_generation.protoable.get_union_list_type(field_name: str, union_protoables: List) Type[caikit.core.data_model.base.DataBase][source]
Create a union from list type objects
- caikit.runtime.service_generation.protoable.get_protoable_return_type(arg_type: Type) Type[source]
Helper function that determines the right data model type to use from a Union
- caikit.runtime.service_generation.protoable.is_protoable_type(arg_type: Type) bool[source]
Returns True if arg_type is in PROTO_TYPE_MAP(float, int, bool, str, bytes) Or if it’s an imported Caikit data model class. Or if it’s a Union of at least one of those. Or if it’s a List of one of those. Or if it’s a Dict of one of those. False otherwise