nv_ingest_api.util.introspection package#
Submodules#
nv_ingest_api.util.introspection.class_inspect module#
- nv_ingest_api.util.introspection.class_inspect.find_pydantic_config_schema(
- actor_class: Type,
- base_class_to_find: Type,
- param_name: str = 'config',
Introspects a class’s MRO to find a Pydantic model in its __init__ signature.
This function is designed to find the specific Pydantic configuration model for a pipeline actor, which might be a direct class or a proxy object.
- Parameters:
actor_class (Type) – The actor class or proxy object to inspect.
base_class_to_find (Type) – The specific base class (e.g., RaySource, RayStage) to look for when resolving the true actor class from a proxy.
param_name (str, optional) – The name of the __init__ parameter to inspect for the Pydantic schema, by default “config”.
- Returns:
The Pydantic BaseModel class if found, otherwise None.
- Return type:
Optional[Type[BaseModel]]
- nv_ingest_api.util.introspection.class_inspect.find_pydantic_config_schema_for_callable(
- callable_fn: Callable,
- param_name: str = 'stage_config',
Introspects a callable’s signature to find a Pydantic model parameter.
This function is designed to find the specific Pydantic configuration model for a pipeline callable function.
- Parameters:
callable_fn (Callable) – The callable function to inspect.
param_name (str, optional) – The name of the parameter to inspect for the Pydantic schema, by default “stage_config”.
- Returns:
The Pydantic BaseModel class if found, otherwise None.
- Return type:
Optional[Type[BaseModel]]
- nv_ingest_api.util.introspection.class_inspect.find_pydantic_config_schema_unified(
- target: Type | Callable,
- base_class_to_find: Type | None = None,
- param_name: str = 'config',
Unified function to find Pydantic schema for either classes or callables.
- Parameters:
target (Union[Type, Callable]) – The class or callable to inspect.
base_class_to_find (Optional[Type], optional) – The specific base class to look for when resolving actor classes from proxies. Only used for class inspection.
param_name (str, optional) – The name of the parameter to inspect for the Pydantic schema. For classes: defaults to “config” For callables: should be “stage_config”
- Returns:
The Pydantic BaseModel class if found, otherwise None.
- Return type:
Optional[Type[BaseModel]]
nv_ingest_api.util.introspection.function_inspect module#
Utilities for introspecting and analyzing UDF function specifications.
- nv_ingest_api.util.introspection.function_inspect.infer_udf_function_name(udf_function: str) str | None [source]#
Attempts to infer the UDF function name from the provided function string.
Supports three formats: 1. Inline function: ‘def my_func(control_message): …’ -> ‘my_func’ 2. Import path: ‘my_module.my_function’ -> ‘my_function’ 3. File path: ‘/path/to/file.py:function_name’ -> ‘function_name’
- Parameters:
udf_function (str) – The UDF function string.
- Returns:
The inferred UDF function name, or None if inference is not possible.
- Return type:
Optional[str]
Examples
>>> infer_udf_function_name("def my_custom_func(control_message): pass") 'my_custom_func'
>>> infer_udf_function_name("my_module.submodule.process_data") 'process_data'
>>> infer_udf_function_name("/path/to/script.py:custom_function") 'custom_function'
>>> infer_udf_function_name("/path/to/script.py") None