# Path: alvi/client/scenes/base.py
# class Scene(api.BaseScene):
#     """base class for container based scenes"""
#     class Form(forms.Form):
#         pass
# 
#     @classmethod
#     def run_wrapper(cls, scene, pipe, **kwargs):
#         container = cls.container_class()(pipe)
#         kwargs['container'] = container
#         scene.run(**kwargs)
# 
#     @classmethod
#     def container_name(cls):
#         return cls.container_class().name()
# 
#     @classmethod
#     @abc.abstractmethod
#     def container_class(cls):
#         raise NotImplementedError
# 
#     def test(self, container, test_case):
#         logger.warning("skipping test for %s" % self.__class__.__name__)
# 
# Path: alvi/client/containers/graph.py
# class Graph(base.Container):
#     def create_node(self, value):
#         return Node(self, None, value)


from alvi.client.scenes.base import Scene
from alvi.client.containers.graph import Graph


class GraphCreateNode(Scene):
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.nodes = []

    def run(self, **kwargs):
        data_generator = kwargs['data_generator']
        graph = kwargs['container']
        value = next(data_generator.values)
        node = graph.create_node(value)
        self.nodes.append(node)
        for i, value in enumerate(data_generator.values):
            node = node.children.create(i+1)
            self.nodes.append(node)
        node.create_edge(self.nodes[0])
        graph.sync()

    @classmethod
    def container_class(cls):

# Path: alvi/client/scenes/base.py
# class Scene(api.BaseScene):
#     """base class for container based scenes"""
#     class Form(forms.Form):
#         pass
# 
#     @classmethod
#     def run_wrapper(cls, scene, pipe, **kwargs):
#         container = cls.container_class()(pipe)
#         kwargs['container'] = container
#         scene.run(**kwargs)
# 
#     @classmethod
#     def container_name(cls):
#         return cls.container_class().name()
# 
#     @classmethod
#     @abc.abstractmethod
#     def container_class(cls):
#         raise NotImplementedError
# 
#     def test(self, container, test_case):
#         logger.warning("skipping test for %s" % self.__class__.__name__)
# 
# Path: alvi/client/containers/graph.py
# class Graph(base.Container):
#     def create_node(self, value):
#         return Node(self, None, value)


# Path: alvi/tests/resources/client/local_python_client/scenes/graph/create_node.py
from alvi.client.scenes.base import Scene
from alvi.client.containers.graph import Graph



class GraphCreateNode(Scene):
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.nodes = []

    def run(self, **kwargs):
        data_generator = kwargs['data_generator']
        graph = kwargs['container']
        value = next(data_generator.values)
        node = graph.create_node(value)
        self.nodes.append(node)
        for i, value in enumerate(data_generator.values):
            node = node.children.create(i+1)
            self.nodes.append(node)
        node.create_edge(self.nodes[0])
        graph.sync()

    @classmethod
    def container_class(cls):

        return Graph