caikit.core.signature_parsing ============================= .. py:module:: caikit.core.signature_parsing Submodules ---------- .. toctree:: :maxdepth: 1 /autoapi/caikit/core/signature_parsing/docstrings/index /autoapi/caikit/core/signature_parsing/module_signature/index /autoapi/caikit/core/signature_parsing/parsers/index Classes ------- .. autoapisummary:: caikit.core.signature_parsing.CaikitMethodSignature caikit.core.signature_parsing.CustomSignature Package Contents ---------------- .. py:class:: CaikitMethodSignature(caikit_core_module: Type[caikit.core.ModuleBase], method_name: str, context_arg: Optional[str] = None) 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 .. py:attribute:: _module .. py:attribute:: _method_name .. py:attribute:: _context_arg :value: None .. py:property:: module :type: Type[caikit.core.ModuleBase] The concrete caikit.core.ModuleBase type .. py:property:: method_name :type: str The name of the method on this module, e.g. 'run' or 'train' .. py:property:: return_type :type: Optional[Type] The return type annotation of the method, or None if the method does not exist .. py:property:: parameters :type: Optional[Dict[str, Type]] A dictionary of the parameter names to their types, or None if the method does not exist .. py:property:: default_parameters :type: Dict[str, Any] A set of all parameter names which have default values .. py:property:: method_signature :type: inspect.Signature The raw method signature for the Module function .. py:property:: qualified_name :type: str The full qualified name for the source function .. py:property:: context_arg :type: Optional[str] The name of the context arg to pass to the function .. py:class:: CustomSignature(original_signature: CaikitMethodSignature, parameters: Dict[str, Type], return_type: Optional[Type]) Bases: :py:obj:`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. .. py:attribute:: _module .. py:attribute:: _method_name .. py:attribute:: _method_pointer .. py:attribute:: _return_type .. py:attribute:: _parameters