[core] Moves bonobo.execution context related package to new bonobo.execution.contexts package, also moves bonobo.strategies to new bonobo.execution.strategies package, so everything related to execution is now contained under the bonobo.execution package.
This commit is contained in:
@ -1,7 +1,7 @@
|
||||
from bonobo.execution.strategies import create_strategy
|
||||
from bonobo.nodes import CsvReader, CsvWriter, FileReader, FileWriter, Filter, JsonReader, JsonWriter, Limit, \
|
||||
PickleReader, PickleWriter, PrettyPrinter, RateLimited, Tee, arg0_to_kwargs, count, identity, kwargs_to_arg0, noop
|
||||
from bonobo.nodes import LdjsonReader, LdjsonWriter
|
||||
from bonobo.strategies import create_strategy
|
||||
from bonobo.structs import Bag, ErrorBag, Graph, Token
|
||||
from bonobo.util import get_name
|
||||
from bonobo.util.environ import parse_args, get_argument_parser
|
||||
@ -35,7 +35,7 @@ def run(graph, *, plugins=None, services=None, strategy=None):
|
||||
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 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:
|
||||
@ -93,10 +93,10 @@ def inspect(graph, *, format):
|
||||
print(_inspect_formats[format](graph))
|
||||
|
||||
|
||||
# bonobo.structs
|
||||
# data structures
|
||||
register_api_group(Bag, ErrorBag, Graph, Token)
|
||||
|
||||
# bonobo.strategies
|
||||
# execution strategies
|
||||
register_api(create_strategy)
|
||||
|
||||
|
||||
@ -125,7 +125,7 @@ def open_fs(fs_url=None, *args, **kwargs):
|
||||
return _open_fs(expanduser(str(fs_url)), *args, **kwargs)
|
||||
|
||||
|
||||
# bonobo.nodes
|
||||
# standard transformations
|
||||
register_api_group(
|
||||
CsvReader,
|
||||
CsvWriter,
|
||||
|
||||
0
bonobo/execution/contexts/__init__.py
Normal file
0
bonobo/execution/contexts/__init__.py
Normal file
@ -1,7 +1,6 @@
|
||||
import sys
|
||||
from contextlib import contextmanager
|
||||
from logging import WARNING, ERROR
|
||||
from time import sleep
|
||||
|
||||
import mondrian
|
||||
from bonobo.config import create_container
|
||||
@ -1,13 +1,12 @@
|
||||
from functools import partial
|
||||
from time import sleep
|
||||
|
||||
from whistle import EventDispatcher
|
||||
|
||||
from bonobo.config import create_container
|
||||
from bonobo.constants import BEGIN, END
|
||||
from bonobo.execution import events
|
||||
from bonobo.execution.node import NodeExecutionContext
|
||||
from bonobo.execution.plugin import PluginExecutionContext
|
||||
from bonobo.execution.contexts.node import NodeExecutionContext
|
||||
from bonobo.execution.contexts.plugin import PluginExecutionContext
|
||||
from whistle import EventDispatcher
|
||||
|
||||
|
||||
class GraphExecutionContext:
|
||||
@ -1,12 +1,11 @@
|
||||
import sys
|
||||
import threading
|
||||
from queue import Empty
|
||||
from time import sleep
|
||||
from types import GeneratorType
|
||||
|
||||
from bonobo.constants import NOT_MODIFIED, BEGIN, END
|
||||
from bonobo.errors import InactiveReadableError, UnrecoverableError
|
||||
from bonobo.execution.base import LoopingExecutionContext
|
||||
from bonobo.execution.contexts.base import LoopingExecutionContext
|
||||
from bonobo.structs.bags import Bag
|
||||
from bonobo.structs.inputs import Input
|
||||
from bonobo.structs.tokens import Token
|
||||
@ -1,4 +1,4 @@
|
||||
from bonobo.execution.base import LoopingExecutionContext, recoverable
|
||||
from bonobo.execution.contexts.base import LoopingExecutionContext
|
||||
|
||||
|
||||
class PluginExecutionContext(LoopingExecutionContext):
|
||||
@ -1,5 +1,5 @@
|
||||
from bonobo.strategies.executor import ProcessPoolExecutorStrategy, ThreadPoolExecutorStrategy
|
||||
from bonobo.strategies.naive import NaiveStrategy
|
||||
from bonobo.execution.strategies.executor import ProcessPoolExecutorStrategy, ThreadPoolExecutorStrategy
|
||||
from bonobo.execution.strategies.naive import NaiveStrategy
|
||||
|
||||
__all__ = [
|
||||
'create_strategy',
|
||||
@ -21,8 +21,8 @@ def create_strategy(name=None):
|
||||
:param name:
|
||||
:return: Strategy
|
||||
"""
|
||||
from bonobo.strategies.base import Strategy
|
||||
import logging
|
||||
from bonobo.execution.strategies.base import Strategy
|
||||
|
||||
if isinstance(name, Strategy):
|
||||
return name
|
||||
@ -39,4 +39,4 @@ def create_strategy(name=None):
|
||||
'Invalid strategy {}. Available choices: {}.'.format(repr(name), ', '.join(sorted(STRATEGIES.keys())))
|
||||
) from exc
|
||||
|
||||
return factory()
|
||||
return factory()
|
||||
@ -1,4 +1,4 @@
|
||||
from bonobo.execution.graph import GraphExecutionContext
|
||||
from bonobo.execution.contexts.graph import GraphExecutionContext
|
||||
|
||||
|
||||
class Strategy:
|
||||
@ -1,13 +1,12 @@
|
||||
import functools
|
||||
import logging
|
||||
import sys
|
||||
from concurrent.futures import Executor, ProcessPoolExecutor, ThreadPoolExecutor, wait, FIRST_EXCEPTION
|
||||
from time import sleep
|
||||
from concurrent.futures import Executor, ProcessPoolExecutor, ThreadPoolExecutor
|
||||
|
||||
from bonobo.util import get_name
|
||||
from bonobo.constants import BEGIN, END
|
||||
from bonobo.strategies.base import Strategy
|
||||
from bonobo.structs.bags import Bag
|
||||
from bonobo.constants import BEGIN, END
|
||||
from bonobo.execution.strategies.base import Strategy
|
||||
from bonobo.util import get_name
|
||||
|
||||
|
||||
class ExecutorStrategy(Strategy):
|
||||
@ -1,5 +1,5 @@
|
||||
from bonobo.constants import BEGIN, END
|
||||
from bonobo.strategies.base import Strategy
|
||||
from bonobo.execution.strategies.base import Strategy
|
||||
from bonobo.structs.bags import Bag
|
||||
|
||||
|
||||
@ -170,4 +170,4 @@ class IOBuffer():
|
||||
def memory_usage():
|
||||
import os, psutil
|
||||
process = psutil.Process(os.getpid())
|
||||
return process.memory_info()[0] / float(2 ** 20)
|
||||
return process.memory_info()[0] / float(2**20)
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
from contextlib import contextmanager
|
||||
|
||||
from bonobo import open_fs, Token
|
||||
from bonobo.execution.graph import GraphExecutionContext
|
||||
from bonobo.execution.node import NodeExecutionContext
|
||||
from bonobo.execution.contexts.graph import GraphExecutionContext
|
||||
from bonobo.execution.contexts.node import NodeExecutionContext
|
||||
|
||||
|
||||
@contextmanager
|
||||
|
||||
Reference in New Issue
Block a user