hyperstream.stream package

Submodules

hyperstream.stream.stream module

class hyperstream.stream.stream.AssetStream(channel, stream_id, calculated_intervals, last_accessed, last_updated, sandbox, mongo_model=None)[source]

Bases: hyperstream.stream.stream.DatabaseStream

Simple subclass that overrides the calculated intervals property

calculated_intervals
class hyperstream.stream.stream.DatabaseStream(channel, stream_id, calculated_intervals, last_accessed, last_updated, sandbox, mongo_model=None)[source]

Bases: hyperstream.stream.stream.Stream

Simple subclass that overrides the calculated intervals property

calculated_intervals

Gets the calculated intervals from the database

Returns:The calculated intervals
last_accessed

Gets the last accessed time from the database

Returns:The last accessed time
last_updated

Gets the last updated time from the database

Returns:The last updated time
load()[source]

Load the stream definition from the database

Returns:None
save()[source]

Saves the stream definition to the database. This assumes that the definition doesn’t already exist, and will raise an exception if it does.

Returns:None
class hyperstream.stream.stream.Stream(channel, stream_id, calculated_intervals, sandbox)[source]

Bases: hyperstream.utils.containers.Hashable

Stream reference class

calculated_intervals

Get the calculated intervals This will be read from the stream_status collection if it’s in the database channel

Returns:The calculated intervals
parent_node
purge()[source]

Purge the stream. This removes all data and clears the calculated intervals

Returns:None
set_tool_reference(tool_reference)[source]

Set the back reference to the tool that populates this stream. This is needed to traverse the graph outside of workflows

Parameters:tool_reference – The toool
Returns:None
window(time_interval=None, force_calculation=False)[source]

Gets a view on this stream for the time interval given

Parameters:
  • time_interval (None | Iterable | TimeInterval) – either a TimeInterval object or (start, end) tuple of type str or datetime
  • force_calculation (bool) – Whether we should force calculation for this stream view if data does not exist
Returns:

a stream view object

writer

hyperstream.stream.stream_collections module

class hyperstream.stream.stream_collections.StreamDict(*args, **kwargs)[source]

Bases: hyperstream.utils.containers.TypedBiDict

Custom bi-directional dictionary where keys are StreamID objects and values are Stream objects. Raises ValueDuplicationError if the same Stream is added again

class hyperstream.stream.stream_collections.StreamInstanceCollection[source]

Bases: hyperstream.utils.containers.FrozenKeyDict

A custom frozen dictionary for stream instances. Will raise an exception if a repeated instance is added

append(instance)[source]
extend(instances)[source]

hyperstream.stream.stream_id module

class hyperstream.stream.stream_id.StreamId(name, meta_data=None)[source]

Bases: hyperstream.utils.containers.Hashable

Helper class for stream identifiers. A stream identifier contains the stream name and any meta-data

as_dict()[source]
as_raw()[source]

Return a representation of this object that can be used with mongoengine Document.objects(__raw__=x) Example:

>>> stream_id = StreamId(name='test', meta_data=((u'house', u'1'), (u'resident', u'1')))
>>> stream_id.as_raw()
{'stream_id.meta_data': [(u'house', u'1'), (u'resident', u'1')], 'stream_id.name': 'test'}
Returns:The raw representation of this object.
to_json()[source]
hyperstream.stream.stream_id.get_stream_id(item)[source]

hyperstream.stream.stream_instance module

class hyperstream.stream.stream_instance.StreamInstance[source]

Bases: hyperstream.stream.stream_instance.StreamInstance

Simple helper class for storing data instances that’s a bit neater than simple tuples

as_dict(flat=True)[source]
as_list(flat=True)[source]
class hyperstream.stream.stream_instance.StreamMetaInstance[source]

Bases: hyperstream.stream.stream_instance.StreamMetaInstance

StreamInstance that also contains meta data

hyperstream.stream.stream_view module

class hyperstream.stream.stream_view.StreamView(stream, time_interval, force_calculation=False)[source]

Bases: hyperstream.utils.containers.Printable

Simple helper class for storing streams with a time interval (i.e. a “view” on a stream) :param stream: The stream upon which this is a view :param time_interval: The time interval over which this view is defined :param force_calculation: Whether we should force calculation for this stream view if data does not exist :type stream: Stream :type time_interval: TimeInterval

component(key)[source]
component_filter(key, values)[source]
delete_nones()[source]
dict_items(flat=True)[source]
dict_iteritems(flat=True)[source]
first(default=None)[source]
head(n)[source]
islice(start, stop=None, step=1)[source]
items()[source]

Return all results as a list :return: The results :rtype: list[StreamInstance]

iteritems()[source]
itertimestamps()[source]
itervalues()[source]
last(default=None)[source]
tail(n)[source]
timestamps()[source]
values()[source]

Module contents