morpheus.messages.multi_message.MultiMessage

class MultiMessage(*, meta, mess_offset=0, mess_count=- 1)[source]

Bases: morpheus.messages.message_base.MessageData

This class holds data for multiple messages at a time. To avoid copying data for slicing operations, it holds a reference to a batched metadata object and stores the offset and count into that batch.

Parameters
metaMessageMeta

Deserialized messages metadata for large batch.

mess_offsetint

Offset into the metadata batch.

mess_countint

Messages count.

Attributes
id

Returns ID column values from morpheus.pipeline.messages.MessageMeta.df as list.

id_col

Returns ID column values from morpheus.pipeline.messages.MessageMeta.df.

timestamp

Returns timestamp column values from morpheus.messages.MessageMeta.df as list.

Methods

copy_meta_ranges(ranges[, mask])

Perform a copy of the underlying dataframe for the given ranges of rows.

copy_ranges(ranges)

Perform a copy of the current message instance for the given ranges of rows.

from_message(message, *[, meta, ...])

Creates a new instance of a derived class from MultiMessage using an existing message as the template.

get_meta()

Return column values from morpheus.pipeline.messages.MessageMeta.df.

get_meta_list([col_name])

Return a column values from morpheus.messages.MessageMeta.df as a list.

get_slice(start, stop)

Returns sliced batches based on offsets supplied.

set_meta(columns, value)

Set column values to morpheus.pipelines.messages.MessageMeta.df.

copy_meta_ranges(ranges, mask=None)[source]

Perform a copy of the underlying dataframe for the given ranges of rows.

Parameters
rangestyping.List[typing.Tuple[int, int]]

Rows to include in the copy in the form of [(`start_row, stop_row),…]` The stop_row isn’t included. For example to copy rows 1-2 & 5-7 ranges=[(1, 3), (5, 8)]

masktyping.Union[None, cupy.ndarray, numpy.ndarray]

Optionally specify rows as a cupy array (when using cudf Dataframes) or a numpy array (when using pandas Dataframes) of booleans. When not-None ranges will be ignored. This is useful as an optimization as this avoids needing to generate the mask on it’s own.

Returns
Dataframe

copy_ranges(ranges)[source]

Perform a copy of the current message instance for the given ranges of rows.

Parameters
rangestyping.List[typing.Tuple[int, int]]

Rows to include in the copy in the form of [(`start_row, stop_row),…]` The stop_row isn’t included. For example to copy rows 1-2 & 5-7 ranges=[(1, 3), (5, 8)]

Returns
MultiMessage

classmethod from_message(message, *, meta=None, mess_offset=- 1, mess_count=- 1, **kwargs)[source]

Creates a new instance of a derived class from MultiMessage using an existing message as the template. This is very useful when a new message needs to be created with a single change to an existing MessageMeta.

When creating the new message, all required arguments for the class specified by cls will be pulled from message unless otherwise specified in the args or kwargs. Special handling is performed depending on whether or not a new meta object is supplied. If one is supplied, the offset and count defaults will be 0 and meta.count respectively. Otherwise offset and count will be pulled from the input message.

Parameters
clstyping.Type[Self]

The class to create

messageMultiMessage

An existing message to use as a template. Can be a base or derived from cls as long as all arguments can be pulled from message or proveded in kwargs

metaMessageMeta, optional

A new MessageMeta to use, by default None

mess_offsetint, optional

A new mess_offset to use, by default -1

mess_countint, optional

A new mess_count to use, by default -1

Returns
Self

A new instance of type cls

Raises
ValueError

If the incoming message is None

AttributeError

If some required arguments were not supplied by kwargs and could not be pulled from message

get_meta() → cudf.core.dataframe.DataFrame[source]
get_meta(columns: str) → cudf.core.series.Series
get_meta(columns: List[str]) → cudf.core.dataframe.DataFrame

Return column values from morpheus.pipeline.messages.MessageMeta.df.

Parameters
columnstyping.Union[None, str, typing.List[str]]

Input column names. Returns all columns if None is specified. When a string is passed, a Series is returned. Otherwise a Dataframe is returned.

Returns
Series or Dataframe

Column values from the dataframe.

get_meta_list(col_name=None)[source]

Return a column values from morpheus.messages.MessageMeta.df as a list.

Parameters
col_namestr

Column name in the dataframe.

Returns
List[str]

Column values from the dataframe.

get_slice(start, stop)[source]

Returns sliced batches based on offsets supplied. Automatically calculates the correct mess_offset and mess_count.

Parameters
startint

Start offset address.

stopint

Stop offset address.

Returns
MultiInferenceMessage

A new MultiInferenceMessage with sliced offset and count.

property id: List[int]

Returns ID column values from morpheus.pipeline.messages.MessageMeta.df as list.

Returns
List[int]

ID column values from the dataframe as list.

property id_col

Returns ID column values from morpheus.pipeline.messages.MessageMeta.df.

Returns
pandas.Series

ID column values from the dataframe.

set_meta(columns, value)[source]

Set column values to morpheus.pipelines.messages.MessageMeta.df.

Parameters
columnstyping.Union[None, str, typing.List[str]]

Input column names. Sets the value for the corresponding column names. If None is specified, all columns will be used. If the column does not exist, a new one will be created.

valueAny

Value to apply to the specified columns. If a single value is passed, it will be broadcast to all rows. If a Series or Dataframe is passed, rows will be matched by index.

property timestamp: List[int]

Returns timestamp column values from morpheus.messages.MessageMeta.df as list.

Returns
List[int]

Timestamp column values from the dataframe as list.

© Copyright 2023, NVIDIA. Last updated on Apr 11, 2023.