hyped.core.nodes.processor module¶
Provides base classe for data processors in a data flow graph.
This module defines the base class for data processors, which represent nodes in a data flow graph. It includes generic classes for defining data processors with configurable input and output types.
- class hyped.core.nodes.processor.BaseDataProcessor(*args: Any, **kwargs: Any)[source]¶
-
Base class for data processors in a data flow graph.
This class serves as the base for all data processors, representing nodes in a data flow graph. Subclasses of
BaseDataProcessorimplement specific process functions that map input features to output features. Custom data processors must either override thebatch_process()method or theprocess()method to define their processing logic.- abstractmethod process(ctx: RunContext, *args: Feature | Any | list[Any] | Scalar | Array, **kwargs: Feature | Any | list[Any] | Scalar | Array) Feature | Any | list[Any] | Scalar | Array[source]¶
Process function.
This method should be implemented by subclasses to define the processing logic. It may either be synchronous or asynchronous, depending on the subclass.
- Parameters:
ctx (RunContext) – The context for the current process call.
*args (Feature) – Positional feature arguments.
**kwargs (Feature) – Keyword feature arguments.
- Returns:
The resulting processed feature.
- Return type:
- async run(ctx: RunContext, arrays: dict[str, Array]) Array[source]¶
Execute the main processing logic for the data processor.
This method serves as the primary entry point for processing data within a data flow graph. It orchestrates the execution of the
processmethod according to the configuredProcessMode, handling input preparation, processing, and output finalization. In detail the workflow is:Determine the processing mode (
ProcessMode) based on theprocessmethod’s configuration.Prepare the input data using the
ProcessMode.preparemethod.Apply the
processmethod to the prepared inputs. If the method is asynchronous, the outputs are awaited usingasyncio.gather.Finalize the outputs using the
ProcessMode.finalizemethod, which ensures that the results are correctly formatted as anPyArrowarray.
- Parameters:
ctx (RunContext) – The execution context containing.
arrays (dict[str, pa.Array]) – A dictionary mapping input names to
PyArrowarrays, representing the input data to be processed.
- Returns:
The processed output as a
PyArrowarray.- Return type:
pa.Array
- property signature: Signature¶
Get the signature of the
process()method.Returns the signature of the
process()method with thectxparameter removed, keeping only the feature inputs modeled in the data flow graph.- Returns:
The signature of the
process()method excluding thectxparameter.- Return type:
- class hyped.core.nodes.processor.BaseDataProcessorConfig[source]¶
Bases:
BaseNodeConfigBase configuration class for data processors.
This class serves as the base configuration class for data processors. It inherits from
BaseNodeConfig, a Pydantic model, providing basic configuration functionality for data processing tasks.- model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'validate_default': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].