caikit.core.signature_parsing.parsers ===================================== .. py:module:: caikit.core.signature_parsing.parsers .. autoapi-nested-parse:: Contains functions that attempt to parse the I/O types of member methods on `caikit.core.module`s Attributes ---------- .. autoapisummary:: caikit.core.signature_parsing.parsers.log caikit.core.signature_parsing.parsers.KNOWN_ARG_TYPES Functions --------- .. autoapisummary:: caikit.core.signature_parsing.parsers.get_output_type_name caikit.core.signature_parsing.parsers.get_argument_types caikit.core.signature_parsing.parsers.get_args_with_defaults caikit.core.signature_parsing.parsers._get_argument_type caikit.core.signature_parsing.parsers._snake_to_camel caikit.core.signature_parsing.parsers._get_dm_type_from_name caikit.core.signature_parsing.parsers._get_default_type Module Contents --------------- .. py:data:: log .. py:data:: KNOWN_ARG_TYPES .. py:function:: get_output_type_name(module_class: caikit.core.modules.ModuleBase.__class__, fn_signature: inspect.Signature, fn: Callable) -> Type Get the type for a return type based on the name of the module class and the Caikit library naming convention. .. py:function:: get_argument_types(module_method: Callable) -> Dict[str, Type] Get the python types for each parameter to this method, returned in a dict. This does more than simply looking at inspect.Signature, see _get_argument_type Args: module_method (Callable): A pointer to a method Returns: Dict[str, Type]: A dictionary of parameter name to parameter type .. py:function:: get_args_with_defaults(module_method: Callable) -> Dict[str, Any] Get the the mapping of all argument names that have defaults to their default values. Args: module_method (Callable): A pointer to a method Returns: Dict[str: Any]: A set of all parameter names which have a default value. Empty if none have defaults or no parameters exist. .. py:function:: _get_argument_type(arg: inspect.Parameter, module_method: Callable) -> Type Get the python type for a named argument to a Module's given method. This is where the heuristics for determining types are implemented: * Look for a known type mapping based on the name of the argument * Look for python type annotations * Look for a default value and check its type * Parse the docstring * Look for a data model object whose name matches the argument name .. py:function:: _snake_to_camel(string: str) -> str Simple snake -> camel conversion .. py:function:: _get_dm_type_from_name(data_model_class_name: Optional[str]) -> Type Given a data model class name, look up the data model class itself .. py:function:: _get_default_type(arg: inspect.Parameter) -> Optional[Type] Tries to infer a type from the default value of the argument Args: arg: (inspect.Parameter) The inspected argument Returns: (Optional[Type]) The type of the argument,: or None if no default value is present