from __future__ import annotations
import sys
import logging
from typing import TYPE_CHECKING, Callable

from deltalanguage.data_types import NoMessage

from .node_bodies import PyInteractiveBody, Latency
from .real_nodes import PythonNode, as_node

if TYPE_CHECKING:
    from deltalanguage.wiring import DeltaGraph, InteractiveProcess, Latency


class PyInteractiveNode(PythonNode):
    """Python Interactive Node defined via :py:class:`Interactive`.

    Parameters
    ----------
    graph : DeltaGraph
        Graph the node will be part of
    proc : InteractiveProcess
        Constructed process with the proc function and I/O types.
    latency : Latency
        The estimated latency for running the body.
    kwargs
        Nodes to make in-ports for or Python objects to be made into
        :py:class:`PyConstNode`.
    """

    def __init__(self, graph, body, in_params, pos_in_nodes, kw_in_nodes, in_port_size=0, node_key=None,
                 return_type=None, name=None, latency=Latency(time=350), lvl=logging.ERROR, is_autogenerated=False):
        super().__init__(graph, body, in_params, pos_in_nodes, kw_in_nodes, in_port_size=in_port_size, node_key=node_key,
                         return_type=return_type, name=name, latency=latency, lvl=lvl, is_autogenerated=is_autogenerated)


# This node is used by the Interactive decorator
InteractiveFuncType = Callable[[PyInteractiveNode], None]
