elasticai.creator.ir.core.implementation#

Module Contents#

Classes#

Data#

API#

elasticai.creator.ir.core.implementation.N#

‘TypeVar(…)’

elasticai.creator.ir.core.implementation.E#

‘TypeVar(…)’

elasticai.creator.ir.core.implementation.StoredT#

‘TypeVar(…)’

elasticai.creator.ir.core.implementation.VisibleT#

‘TypeVar(…)’

elasticai.creator.ir.core.implementation.P#

‘ParamSpec(…)’

class elasticai.creator.ir.core.implementation.NodeFn[source]#

Bases: typing.Protocol[elasticai.creator.ir.core.implementation.N]

__call__(name: str, data: dict[str, elasticai.creator.ir.base.Attribute]) elasticai.creator.ir.core.implementation.N[source]#
class elasticai.creator.ir.core.implementation.EdgeFn[source]#

Bases: typing.Protocol[elasticai.creator.ir.core.implementation.E]

__call__(src: str, dst: str, data: dict[str, elasticai.creator.ir.base.Attribute]) elasticai.creator.ir.core.implementation.E[source]#
class elasticai.creator.ir.core.implementation.Implementation(*, graph: elasticai.creator.graph.Graph[str], node_fn: elasticai.creator.ir.core.implementation.NodeFn = Node, edge_fn: elasticai.creator.ir.core.implementation.EdgeFn = Edge, data: dict[str, elasticai.creator.ir.base.Attribute] | None = None)[source]#

Bases: elasticai.creator.ir.base.IrData, typing.Generic[elasticai.creator.ir.core.implementation.N, elasticai.creator.ir.core.implementation.E]

__slots__#

(‘data’, ‘graph’, ‘_node_fn’, ‘_edge_fn’, ‘_nodes’, ‘_edges’)

name: str#

None

type: str#

None

add_node(*args, **kwargs) Self[source]#
add_edge(*args, **kwargs) Self[source]#
add_nodes(ns: collections.abc.Iterable[elasticai.creator.ir.core.core.Node]) Self[source]#
add_edges(es: collections.abc.Iterable[elasticai.creator.ir.core.core.Edge]) Self[source]#
successors(node: str | elasticai.creator.ir.core.core.Node) collections.abc.Mapping[str, elasticai.creator.ir.core.implementation.N][source]#
predecessors(node: str | elasticai.creator.ir.core.core.Node) collections.abc.Mapping[str, elasticai.creator.ir.core.implementation.N][source]#
get_node_mapping(keys: collections.abc.Callable[[], collections.abc.Iterable[str]]) collections.abc.Mapping[str, elasticai.creator.ir.core.implementation.N][source]#

Create a read-only mapping of names to Nodes in the order of keys().

get_edge_mapping(keys: collections.abc.Callable[[], collections.abc.Iterable[tuple[str, str]]]) collections.abc.Mapping[tuple[str, str], elasticai.creator.ir.core.implementation.E][source]#

Create a read-only mapping of (src, dst) pairs to Edges in the order of keys().

nodes(_: dict[str, elasticai.creator.ir.base.Attribute]) collections.abc.Mapping[str, elasticai.creator.ir.core.implementation.N]#
edges(_: dict[str, elasticai.creator.ir.base.Attribute]) collections.abc.Mapping[tuple[str, str], elasticai.creator.ir.core.implementation.E]#
as_dict() dict[str, elasticai.creator.ir.base.Attribute][source]#
sync_data_with_graph() Self[source]#

Removes nodes/edges from data that are not in the graph, add empty fields for new nodes/edges.

load_from_dict(d: dict[str, Any]) Implementation[N, E][source]#

Load attributes, nodes and edges from a dictionary, that was created by as_dict.

Opposed to the constructor, this will add all nodes and edges to the underlying graph.

Important

This will override all state of the current object.