Skip to content

schema

Classes:

Name Description
HashableBaseModel

A base class for hashable dataclasses.

Stream

A 'Stream' represents a sequence of data flow in the Directed Acyclic Graph (DAG).

Node

A 'Node' represents a single operation in the Directed Acyclic Graph (DAG).

HashableBaseModel dataclass

HashableBaseModel()

A base class for hashable dataclasses.

Attributes:

Name Type Description
hex str

Get the hexadecimal hash of the object.

hex cached property

hex: str

Get the hexadecimal hash of the object.

Stream dataclass

Stream(*, node: Node, index: int | None = None)

Bases: HashableBaseModel

A 'Stream' represents a sequence of data flow in the Directed Acyclic Graph (DAG).

Note

Each stream in the DAG is a sequence of operations that transforms the data from its input form to its output form. The stream is an essential component of the DAG, as it defines the order and the nature of the operations that are performed on the data.

Methods:

Name Description
view

Visualize the stream.

Attributes:

Name Type Description
hex str

Get the hexadecimal hash of the object.

node Node

Represents the node that the stream is connected to in the upstream direction.

index int | None

Represents the index of the stream in the node's output streams.

hex cached property

hex: str

Get the hexadecimal hash of the object.

node instance-attribute

node: Node

Represents the node that the stream is connected to in the upstream direction.

Note

In the context of a data stream, the 'upstream' refers to the source of the data, or where the data is coming from. Therefore, the 'upstream node' is the node that is providing the data to the current stream.

index class-attribute instance-attribute

index: int | None = None

Represents the index of the stream in the node's output streams.

Note

See Also: Stream specifiers stream_index

view

view(format: Literal['png', 'svg', 'dot'] = 'png') -> str

Visualize the stream.

Parameters:

Name Type Description Default
format Literal['png', 'svg', 'dot']

The format of the view.

'png'

Returns:

Type Description
str

The file path of the visualization.

Node dataclass

Node(
    *,
    kwargs: tuple[
        tuple[str, str | int | float | bool | LazyValue],
        ...,
    ] = (),
    inputs: tuple[Stream, ...] = ()
)

Bases: HashableBaseModel, ABC

A 'Node' represents a single operation in the Directed Acyclic Graph (DAG).

Note

Each node in the DAG represents a single operation that transforms the data from its input form to its output form. The node is an essential component of the DAG, as it defines the nature of the operations that are performed on the data.

Methods:

Name Description
get_args

Get the arguments of the node.

repr

Get the representation of the node.

replace

Replace the old node in the graph with the new node.

view

Visualize the Node.

Attributes:

Name Type Description
hex str

Get the hexadecimal hash of the object.

kwargs tuple[tuple[str, str | int | float | bool | LazyValue], ...]

Represents the keyword arguments of the node.

inputs tuple[Stream, ...]

Represents the input streams of the node.

max_depth int

Get the maximum depth of the node.

upstream_nodes set[Node]

Get all upstream nodes of the node.

hex cached property

hex: str

Get the hexadecimal hash of the object.

kwargs class-attribute instance-attribute

kwargs: tuple[
    tuple[str, str | int | float | bool | LazyValue], ...
] = ()

Represents the keyword arguments of the node.

inputs class-attribute instance-attribute

inputs: tuple[Stream, ...] = ()

Represents the input streams of the node.

max_depth property

max_depth: int

Get the maximum depth of the node.

Returns:

Type Description
int

The maximum depth of the node.

upstream_nodes property

upstream_nodes: set[Node]

Get all upstream nodes of the node.

Returns:

Type Description
set[Node]

The upstream nodes of the node.

get_args abstractmethod

get_args(context: DAGContext = None) -> list[str]

Get the arguments of the node.

Parameters:

Name Type Description Default
context DAGContext

The DAG context.

None

Returns:

Type Description
list[str]

The arguments of the node.

repr

repr() -> str

Get the representation of the node.

Returns:

Type Description
str

The representation of the node.

replace

replace(old_node: Node, new_node: Node) -> Node

Replace the old node in the graph with the new node.

Parameters:

Name Type Description Default
old_node Node

The old node to replace.

required
new_node Node

The new node to replace with.

required

Returns:

Type Description
Node

The new graph with the replaced node.

view

view(format: Literal['png', 'svg', 'dot'] = 'png') -> str

Visualize the Node.

Parameters:

Name Type Description Default
format Literal['png', 'svg', 'dot']

The format of the view.

'png'

Returns:

Type Description
str

The file path of the visualization.