caikit.core.signature_parsing.parsers
Contains functions that attempt to parse the I/O types of member methods on `caikit.core.module`s
Attributes
Functions
|
Get the type for a return type based on the name of the module class and |
|
Get the python types for each parameter to this method, returned in a dict. |
|
Get the the mapping of all argument names that have defaults to their |
|
Get the python type for a named argument to a Module's given method. This |
|
Simple snake -> camel conversion |
|
Given a data model class name, look up the data model class itself |
|
Tries to infer a type from the default value of the argument |
Module Contents
- caikit.core.signature_parsing.parsers.KNOWN_ARG_TYPES
- caikit.core.signature_parsing.parsers.get_output_type_name(module_class: caikit.core.modules.ModuleBase.__class__, fn_signature: inspect.Signature, fn: Callable) Type[source]
Get the type for a return type based on the name of the module class and the Caikit library naming convention.
- caikit.core.signature_parsing.parsers.get_argument_types(module_method: Callable) Dict[str, Type][source]
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
- caikit.core.signature_parsing.parsers.get_args_with_defaults(module_method: Callable) Dict[str, Any][source]
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.
- caikit.core.signature_parsing.parsers._get_argument_type(arg: inspect.Parameter, module_method: Callable) Type[source]
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
- caikit.core.signature_parsing.parsers._snake_to_camel(string: str) str[source]
Simple snake -> camel conversion
- caikit.core.signature_parsing.parsers._get_dm_type_from_name(data_model_class_name: str | None) Type[source]
Given a data model class name, look up the data model class itself
- caikit.core.signature_parsing.parsers._get_default_type(arg: inspect.Parameter) Type | None[source]
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