caikit.core.signature_parsing

Submodules

Classes

CaikitMethodSignature

Metadata about a method on a caikit core module

CustomSignature

(TBD on new class)? Need something to hold an intentionally mutated representation of a

Package Contents

class caikit.core.signature_parsing.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:

  1. Look for a known type mapping based on the name of the argument

  2. Look for python type annotations

  3. Look for a default value and check its type

  4. 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.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