sgn.sinks
¶
Sink elements for the SGN framework.
CollectSink
dataclass
¶
Bases: SinkElement
flowchart TD
sgn.sinks.CollectSink[CollectSink]
sgn.base.SinkElement[SinkElement]
sgn.base.ElementLike[ElementLike]
sgn.base.UniqueID[UniqueID]
sgn.base.SinkElement --> sgn.sinks.CollectSink
sgn.base.ElementLike --> sgn.base.SinkElement
sgn.base.UniqueID --> sgn.base.ElementLike
click sgn.sinks.CollectSink href "" "sgn.sinks.CollectSink"
click sgn.base.SinkElement href "" "sgn.base.SinkElement"
click sgn.base.ElementLike href "" "sgn.base.ElementLike"
click sgn.base.UniqueID href "" "sgn.base.UniqueID"
A sink element that has one collection per sink pad.
Each frame that is pulled into the sink is added to the collection for that pad using a ".append" method. If the extract_data flag is set, the data is extracted from the frame and added to the deque, otherwise the frame itself is added to the collection.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
collects
|
dict[str, MutableSequence]
|
dict[str, Collection], a mapping of sink pad names to Collections. The Collection must have an append method. |
dict()
|
extract_data
|
bool
|
bool, default True, flag to indicate if the data should be extracted from the frame before adding it to the deque |
True
|
skip_empty
|
bool
|
bool, default True, flag to indicate the frame should be
skipped and not collected if its |
True
|
Source code in sgn/sinks.py
pull(pad, frame)
¶
Pull in frame and add it to pad collection.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pad
|
SinkPad
|
SinkPad, the pad that the frame is pulled into |
required |
frame
|
Frame
|
Frame, the frame that is pulled into the sink |
required |
Source code in sgn/sinks.py
DequeSink
dataclass
¶
Bases: CollectSink
flowchart TD
sgn.sinks.DequeSink[DequeSink]
sgn.sinks.CollectSink[CollectSink]
sgn.base.SinkElement[SinkElement]
sgn.base.ElementLike[ElementLike]
sgn.base.UniqueID[UniqueID]
sgn.sinks.CollectSink --> sgn.sinks.DequeSink
sgn.base.SinkElement --> sgn.sinks.CollectSink
sgn.base.ElementLike --> sgn.base.SinkElement
sgn.base.UniqueID --> sgn.base.ElementLike
click sgn.sinks.DequeSink href "" "sgn.sinks.DequeSink"
click sgn.sinks.CollectSink href "" "sgn.sinks.CollectSink"
click sgn.base.SinkElement href "" "sgn.base.SinkElement"
click sgn.base.ElementLike href "" "sgn.base.ElementLike"
click sgn.base.UniqueID href "" "sgn.base.UniqueID"
A sink element that has one double-ended-queue (deque) per sink pad.
Each frame that is pulled into the sink is added to the deque for that pad. If the extract_data flag is set, the data is extracted from the frame and added to the deque , otherwise the frame itself is added to the deque.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
collects
|
dict[str, MutableSequence]
|
dict[str, deque], a mapping of sink pads to deques, where the key is the pad name and the value is the deque |
dict()
|
extract_data
|
bool
|
bool, default True, flag to indicate if the data should be extracted from the frame before adding it to the deque |
True
|
Notes
Ignoring empty frames: If the frame is empty, it is not added to the deque. The motivating principle is that "empty frames preserve the sink deque". An empty deque is equivalent (for our purposes) to a deque filled with "None" values, so we prevent the latter from being possible.
Source code in sgn/sinks.py
deques
property
¶
Explicit alias for collects.
Returns:
| Type | Description |
|---|---|
dict[str, MutableSequence]
|
dict[str, deque ]: the deques for the sink |
NullSink
dataclass
¶
Bases: SinkElement
flowchart TD
sgn.sinks.NullSink[NullSink]
sgn.base.SinkElement[SinkElement]
sgn.base.ElementLike[ElementLike]
sgn.base.UniqueID[UniqueID]
sgn.base.SinkElement --> sgn.sinks.NullSink
sgn.base.ElementLike --> sgn.base.SinkElement
sgn.base.UniqueID --> sgn.base.ElementLike
click sgn.sinks.NullSink href "" "sgn.sinks.NullSink"
click sgn.base.SinkElement href "" "sgn.base.SinkElement"
click sgn.base.ElementLike href "" "sgn.base.ElementLike"
click sgn.base.UniqueID href "" "sgn.base.UniqueID"
A sink that does precisely nothing.
It is useful for testing and debugging, or for pipelines that do not need a sink, but require one to be present in the pipeline.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
verbose
|
bool
|
bool, print frames as they pass through the internal pad |
False
|