caikit.core.signature_parsing.module_signature
This package exposes useful metadata about a method on a caikit.core module, including method name, return type and input parameters.
This encapsulates a lot of custom logic used to parse input/output parameters, especially when it comes to the caikit core common data model.
Attributes
Classes
Metadata about a method on a caikit core module |
|
(TBD on new class)? Need something to hold an intentionally mutated representation of a |
Module Contents
- class caikit.core.signature_parsing.module_signature.CaikitMethodSignature(caikit_core_module: Type[caikit.core.ModuleBase], method_name: str, context_arg: str | None = None)[source]
Metadata about a method on a caikit core module
Determines the argument types and return type for a function (run, train, etc.) of the given caikit core module in any way possible!
This is the most “heuristic” part of this process. Currently, there is no well-defined mechanism for defining the types of a module’s run signature in the caikit.core API, so it is enforced by convention only. As such, this package needs to reverse engineer those conventions! It does so by walking through a list of candidate ways to determine the signature in order least- hacky to most-hacky:
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
- _module
- _method_name
- _context_arg = None
- property module: Type[caikit.core.ModuleBase]
The concrete caikit.core.ModuleBase type
- property method_name: str
The name of the method on this module, e.g. ‘run’ or ‘train’
- property return_type: Type | None
The return type annotation of the method, or None if the method does not exist
- property parameters: Dict[str, Type] | None
A dictionary of the parameter names to their types, or None if the method does not exist
- property default_parameters: Dict[str, Any]
A set of all parameter names which have default values
- property method_signature: inspect.Signature
The raw method signature for the Module function
- property qualified_name: str
The full qualified name for the source function
- property context_arg: str | None
The name of the context arg to pass to the function
- class caikit.core.signature_parsing.module_signature.CustomSignature(original_signature: CaikitMethodSignature, parameters: Dict[str, Type], return_type: Type | None)[source]
Bases:
CaikitMethodSignature(TBD on new class)? Need something to hold an intentionally mutated representation of a method signature. This represents the extra indirection that lives in the runtime, between the service API and the actual method. For example: .train functions return a fully constructed module, but the runtime will invoke .train asynchronously and instead return some handle that can be used to check training status.
- _module
- _method_name
- _method_pointer
- _return_type
- _parameters