hyperstream.tool package

Submodules

hyperstream.tool.aggregate_tool module

class hyperstream.tool.aggregate_tool.AggregateTool(aggregation_meta_data, **kwargs)[source]

Bases: hyperstream.tool.tool.Tool

This type of tool aggregates over a given plate. For example, if the input is all the streams in a node on plate A.B, and the aggregation is over plate B, the results will live on plate A alone. This can also be thought of as marginalising one dimension of a tensor over the plates

hyperstream.tool.base_tool module

class hyperstream.tool.base_tool.BaseTool(**kwargs)[source]

Bases: hyperstream.utils.containers.Printable, hyperstream.utils.containers.Hashable

Base class for all tools

get_model()[source]

Gets the mongoengine model for this tool, which serializes parameters that are functions

Returns:The mongoengine model. TODO: Note that the tool version is currently incorrect (0.0.0)
message(interval)[source]

Get the execution message

Parameters:interval – The time interval
Returns:The execution message
name

Get the name of the tool, converted to snake format (e.g. “splitter_from_stream”)

Returns:The name
parameters

Get the tool parameters

Returns:The tool parameters along with additional information (whether they are functions or sets)
parameters_dict

Get the tool parameters as a simple dictionary

Returns:The tool parameters
static parameters_from_dicts(parameters)[source]

Get the tool parameters model from dictionaries

Parameters:parameters – The parameters as dictionaries
Returns:The tool parameters model
static parameters_from_model(parameters_model)[source]

Get the tool parameters model from dictionaries

Parameters:parameters_model – The parameters as a mongoengine model
Returns:The tool parameters as a dictionary
static write_to_history(**kwargs)[source]

Write to the history of executions of this tool

Parameters:kwargs – keyword arguments describing the executions
Returns:None

hyperstream.tool.multi_output_tool module

class hyperstream.tool.multi_output_tool.MultiOutputTool(**kwargs)[source]

Bases: hyperstream.tool.base_tool.BaseTool

Special type of tool that outputs multiple streams on a new plate rather than a single stream. There are in this case multiple sinks rather than a single sink, and a single source rather than multiple sources. Note that no alignment stream is required here. Also note that we don’t subclass Tool due to different calling signatures

execute(source, splitting_stream, sinks, interval, meta_data_id, output_plate_values)[source]

Execute the tool over the given time interval.

Parameters:
  • source (Stream) – The source stream
  • splitting_stream – The stream over which to split
  • sinks (list[Stream] | tuple[Stream]) – The sink streams
  • interval (TimeInterval) – The time interval
  • meta_data_id (str) – The meta data id of the output plate
  • output_plate_values (list | tuple) – The values of the plate where data is put onto
Returns:

None

hyperstream.tool.plate_creation_tool module

class hyperstream.tool.plate_creation_tool.PlateCreationTool(**kwargs)[source]

Bases: hyperstream.tool.base_tool.BaseTool

Special type of tool that creates a new plate. There is no sink in this case, as it does not yet exist. Note that no alignment stream is required here. Also note that we don’t subclass Tool due to different calling signatures

execute(source, interval, input_plate_value)[source]

Execute the tool over the given time interval.

Parameters:
  • source (Stream) – The source stream
  • interval (TimeInterval) – The time interval
  • input_plate_value (tuple[tuple[str, str]] | None) – The value of the plate where data comes from (can be None)
Returns:

None

hyperstream.tool.selector_tool module

class hyperstream.tool.selector_tool.SelectorTool(selector_meta_data, **kwargs)[source]

Bases: hyperstream.tool.base_tool.BaseTool

This type of tool performs sub-selection of streams within a node. This can either be done using a selector in the parameters or using an input stream. The sink node plate should be a sub-plate of the source node. Examples are IndexOf and SubArray, either with fixed or variable parameters

execute(sources, sinks, interval)[source]

Execute the tool over the given time interval.

Parameters:
Returns:

None

hyperstream.tool.tool module

class hyperstream.tool.tool.Tool(**kwargs)[source]

Bases: hyperstream.tool.base_tool.BaseTool

Base class for tools. Tools are the unit of computation, operating on input streams to produce an output stream

execute(sources, sink, interval, alignment_stream=None)[source]

Execute the tool over the given time interval. If an alignment stream is given, the output instances will be aligned to this stream

Parameters:
  • sources (list[Stream] | tuple[Stream] | None) – The source streams (possibly None)
  • sink (Stream) – The sink stream
  • alignment_stream (Stream | None) – The alignment stream
  • interval (TimeInterval) – The time interval
Returns:

None

Module contents

Tool package. Defines Tool, MultiOutputTool and SelectorTool base classes.