Skip to content

Function definition

FunctionDefinition

Bases: Resource

Configuration for a StreamPipes Function.

This class maps to the FunctionDefinition class in the StreamPipes model. It contains all metadata that are required to register a function at the StreamPipes backend.

ATTRIBUTE DESCRIPTION
consumed_streams

List of data streams the function is consuming from

TYPE: List[str]

function_id

identifier object of a StreamPipes function

TYPE: FunctionId

output_data_streams

Map off all output data streams added to the function definition

TYPE: Dict[str, DataStream]

Config

Configuration class for Pydantic. Defines alias generator to convert field names from camelCase (API) to snake_case (Python codebase).

add_output_data_stream(data_stream)

Adds an output data stream to the function which makes it possible to write data back to StreamPipes.

PARAMETER DESCRIPTION
data_stream

The schema of the output data stream.

TYPE: DataStream

RETURNS DESCRIPTION
self

Instance of the function definition that is extended by the provided DataStream

TYPE: FunctionDefinition

convert_to_pandas_representation()

Returns the dictionary representation of a function definition to be used when creating a pandas Dataframe.

RETURNS DESCRIPTION
pandas_repr

Pandas representation of the resource as a dictionary, which is then used by the respource container to create a data frame from a collection of resources.

TYPE: Dict[str, Any]

get_output_data_streams()

Get the output data streams of the function.

RETURNS DESCRIPTION
output_streams

Dictionary with every known stream id and the related output stream.

TYPE: Dict[str, DataStream]

get_output_stream_ids()

Get the stream ids of the output data streams.

RETURNS DESCRIPTION
output_stream_ids

List of all stream ids

TYPE: List[str]

to_dict(use_source_names=True)

Returns the resource in dictionary representation.

PARAMETER DESCRIPTION
use_source_names

Indicates if the dictionary keys are in python representation or equally named to the StreamPipes backend

DEFAULT: True

RETURNS DESCRIPTION
resource

The resource as dictionary representation

TYPE: Dict[str, Any]

FunctionId

Bases: BasicModel

Identification object for a StreamPipes function.

Maps to the FunctionId class defined in the StreamPipes model.

ATTRIBUTE DESCRIPTION
id

unique identifier of the function instance

TYPE: str

version

version of the corresponding function

TYPE: int

Config

Configuration class for Pydantic. Defines alias generator to convert field names from camelCase (API) to snake_case (Python codebase).


Last update: December 7, 2024