Skip to content

sgn.frames

Frame classes for the SGN framework.

DataSpec dataclass

A specification for the type of data stored in frames.

All properties in this specification will be expected to match what is stored in the frame, and what is being transferred between source and sink pads.

Source code in sgn/frames.py
 9
10
11
12
13
14
15
16
17
18
19
20
@dataclass(frozen=True, eq=True)
class DataSpec:
    """A specification for the type of data stored in frames.

    All properties in this specification will be expected to match what is
    stored in the frame, and what is being transferred between source and sink
    pads.

    """

    def update(self, **kwargs) -> DataSpec:
        return replace(self, **kwargs)

Frame dataclass

Generic class to hold the basic unit of data that flows through a graph.

Parameters:

Name Type Description Default
EOS bool

bool, default False, Whether this frame indicates end of stream (EOS)

False
is_gap bool

bool, default False, Whether this frame is marked as a gap

False
spec DataSpec

DataSpec, optional, a specification for the data captured in this frame

DataSpec()
data Any

Any, the data to store in the frame

None
metadata dict

dict, optional, Metadata associated with this frame.

dict()
Source code in sgn/frames.py
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
@dataclass
class Frame:
    """Generic class to hold the basic unit of data that flows through a graph.

    Args:
        EOS:
            bool, default False, Whether this frame indicates end of stream (EOS)
        is_gap:
            bool, default False, Whether this frame is marked as a gap
        spec:
            DataSpec, optional, a specification for the data captured in this frame
        data:
            Any, the data to store in the frame
        metadata:
            dict, optional, Metadata associated with this frame.
    """

    EOS: bool = False
    is_gap: bool = False
    spec: DataSpec = field(default_factory=DataSpec)
    data: Any = None
    metadata: dict = field(default_factory=dict)

    def __post_init__(self):
        pass

IterFrame dataclass

Bases: Frame

A frame whose data attribute is an iterable.

Parameters:

Name Type Description Default
data Iterable[Any]

Iterable, the data to store in the frame

list()
Source code in sgn/frames.py
50
51
52
53
54
55
56
57
58
59
@dataclass
class IterFrame(Frame):
    """A frame whose data attribute is an iterable.

    Args:
        data:
            Iterable, the data to store in the frame
    """

    data: Iterable[Any] = field(default_factory=list)