示例#1
0
def test_check():
    settings.check()
    with patch.dict(environ, {'DEBUG': 't', 'PROFILE': 't', 'QUIET': 't'}):
        settings.clear_all()
        with pytest.raises(RuntimeError):
            settings.check()
    settings.clear_all()
示例#2
0
def test_check():
    settings.check()
    with patch.dict(environ, {"DEBUG": "t", "PROFILE": "t", "QUIET": "t"}):
        settings.clear_all()
        with pytest.raises(RuntimeError):
            settings.check()
    settings.clear_all()
示例#3
0
def test_check():
    settings.check()
    with patch.dict(environ, {'DEBUG': 't', 'PROFILE': 't', 'QUIET': 't'}):
        settings.clear_all()
        with pytest.raises(RuntimeError):
            settings.check()
    settings.clear_all()
示例#4
0
def run(graph, *, plugins=None, services=None, strategy=None):
    """
    Main entry point of bonobo. It takes a graph and creates all the necessary plumbing around to execute it.

    The only necessary argument is a :class:`Graph` instance, containing the logic you actually want to execute.

    By default, this graph will be executed using the "threadpool" strategy: each graph node will be wrapped in a
    thread, and executed in a loop until there is no more input to this node.

    You can provide plugins factory objects in the plugins list, this function will add the necessary plugins for
    interactive console execution and jupyter notebook execution if it detects correctly that it runs in this context.

    You'll probably want to provide a services dictionary mapping service names to service instances.

    :param Graph graph: The :class:`Graph` to execute.
    :param str strategy: The :class:`bonobo.execution.strategies.base.Strategy` to use.
    :param list plugins: The list of plugins to enhance execution.
    :param dict services: The implementations of services this graph will use.
    :return bonobo.execution.graph.GraphExecutionContext:
    """

    plugins = plugins or []

    from bonobo import settings

    settings.check()

    if not settings.QUIET.get():  # pragma: no cover
        if _is_interactive_console():
            import mondrian

            mondrian.setup(excepthook=True)

            from bonobo.plugins.console import ConsoleOutputPlugin

            if ConsoleOutputPlugin not in plugins:
                plugins.append(ConsoleOutputPlugin)

        if _is_jupyter_notebook():
            try:
                from bonobo.contrib.jupyter import JupyterOutputPlugin
            except ImportError:
                import logging

                logging.warning(
                    'Failed to load jupyter widget. Easiest way is to install the optional "jupyter" '
                    'dependencies with «pip install bonobo[jupyter]», but you can also install a specific '
                    'version by yourself.')
            else:
                if JupyterOutputPlugin not in plugins:
                    plugins.append(JupyterOutputPlugin)

    import logging

    logging.getLogger().setLevel(settings.LOGGING_LEVEL.get())
    strategy = create_strategy(strategy)
    return strategy.execute(graph, plugins=plugins, services=services)
示例#5
0
def run(graph, *, plugins=None, services=None, strategy=None):
    """
    Main entry point of bonobo. It takes a graph and creates all the necessary plumbing around to execute it.

    The only necessary argument is a :class:`Graph` instance, containing the logic you actually want to execute.

    By default, this graph will be executed using the "threadpool" strategy: each graph node will be wrapped in a
    thread, and executed in a loop until there is no more input to this node.

    You can provide plugins factory objects in the plugins list, this function will add the necessary plugins for
    interactive console execution and jupyter notebook execution if it detects correctly that it runs in this context.

    You'll probably want to provide a services dictionary mapping service names to service instances.

    :param Graph graph: The :class:`Graph` to execute.
    :param str strategy: The :class:`bonobo.execution.strategies.base.Strategy` to use.
    :param list plugins: The list of plugins to enhance execution.
    :param dict services: The implementations of services this graph will use.
    :return bonobo.execution.graph.GraphExecutionContext:
    """

    plugins = plugins or []

    from bonobo import settings
    settings.check()

    if not settings.QUIET.get():  # pragma: no cover
        if _is_interactive_console():
            import mondrian
            mondrian.setup(excepthook=True)

            from bonobo.plugins.console import ConsoleOutputPlugin
            if ConsoleOutputPlugin not in plugins:
                plugins.append(ConsoleOutputPlugin)

        if _is_jupyter_notebook():
            try:
                from bonobo.contrib.jupyter import JupyterOutputPlugin
            except ImportError:
                import logging
                logging.warning(
                    'Failed to load jupyter widget. Easiest way is to install the optional "jupyter" '
                    'dependencies with «pip install bonobo[jupyter]», but you can also install a specific '
                    'version by yourself.'
                )
            else:
                if JupyterOutputPlugin not in plugins:
                    plugins.append(JupyterOutputPlugin)

    import logging
    logging.getLogger().setLevel(settings.LOGGING_LEVEL.get())
    strategy = create_strategy(strategy)
    return strategy.execute(graph, plugins=plugins, services=services)
示例#6
0
文件: _api.py 项目: vit-/bonobo
def run(graph, strategy=None, plugins=None, services=None):
    """
    Main entry point of bonobo. It takes a graph and creates all the necessary plumbery around to execute it.
    
    The only necessary argument is a :class:`Graph` instance, containing the logic you actually want to execute.
    
    By default, this graph will be executed using the "threadpool" strategy: each graph node will be wrapped in a
    thread, and executed in a loop until there is no more input to this node.
    
    You can provide plugins factory objects in the plugins list, this function will add the necessary plugins for
    interactive console execution and jupyter notebook execution if it detects correctly that it runs in this context.
    
    You'll probably want to provide a services dictionary mapping service names to service instances.
    
    :param Graph graph: The :class:`Graph` to execute.
    :param str strategy: The :class:`bonobo.strategies.base.Strategy` to use.
    :param list plugins: The list of plugins to enhance execution.
    :param dict services: The implementations of services this graph will use.
    :return bonobo.execution.graph.GraphExecutionContext:
    """
    strategy = create_strategy(strategy)

    plugins = plugins or []

    from bonobo import settings
    settings.check()

    if not settings.QUIET:  # pragma: no cover
        if _is_interactive_console():
            from bonobo.ext.console import ConsoleOutputPlugin
            if ConsoleOutputPlugin not in plugins:
                plugins.append(ConsoleOutputPlugin)

        if _is_jupyter_notebook():
            from bonobo.ext.jupyter import JupyterOutputPlugin
            if JupyterOutputPlugin not in plugins:
                plugins.append(JupyterOutputPlugin)

    return strategy.execute(graph, plugins=plugins, services=services)