示例#1
0
文件: init.py 项目: licode/VisTrails
def menu_items():
    return (
        ("Start new engine processes", lambda: EngineManager.start_engines()),
        ("Show information on the cluster", lambda: EngineManager.info()),
        ("Change profile", lambda: EngineManager.change_profile()),
        ("Cleanup started processes", lambda: EngineManager.cleanup()),
        ("Request cluster shutdown", lambda: EngineManager.shutdown_cluster()),
    )
示例#2
0
文件: init.py 项目: Nikea/VisTrails
def menu_items():
    return (
            ("Start new engine processes",
             lambda: EngineManager.start_engines()),
            ("Show information on the cluster",
             lambda: EngineManager.info()),
            ("Change profile",
             lambda: EngineManager.change_profile()),
            ("Cleanup started processes",
             lambda: EngineManager.cleanup()),
            ("Request cluster shutdown",
             lambda: EngineManager.shutdown_cluster()),
    )
示例#3
0
def get_client(ask=True):
    """Returns a Client object, from which you can construct a view.

    This may return None if no client is available, if the user cancels, etc.
    In this case, you might want to raise a ModuleError.
    """
    from engine_manager import EngineManager

    c = EngineManager.ensure_controller(connect_only=not ask)
    if c is not None and ask and not c.ids:
        EngineManager.start_engines(
                prompt="A module requested an IPython cluster, but no engines "
                       "are started. Do you want to start some?")
    if c is not None and c.ids:
        return c
    else:
        return None
示例#4
0
def parallel_map(function, *args, **kwargs):
    """Wrapper around IPython's map_sync() that defaults to map().

    This might use IPython's parallel map_sync(), or the standard map()
    function if IPython cannot be used.

    If the 'ask' keyword argument is true, the user will be prompted to start
    IPython engines, but the function will still default to map() if the user
    cancels.
    If the 'ipython' keyword argument is True, the function will return an
    additional boolean indicating whether this was computed through IPython
    (True) or with the default map() function (False).
    """
    say_ipython = kwargs.pop('ipython', False)
    ask = kwargs.pop('ask', False)
    if kwargs:
        raise TypeError("map() got unexpected keyword arguments")

    try:
        import IPython.parallel
    except ImportError:
        result, ipython = map(function, *args), False
    else:
        from engine_manager import EngineManager
        c = EngineManager.ensure_controller(connect_only=not ask)
        if c is not None and not c.ids:
            EngineManager.start_engines(
                    prompt="A module is performing a parallelizable "
                    "operation, however no IPython engines are running. Do "
                    "you want to start some?")

        if c is None or not c.ids:
            result, ipython = map(function, *args), False
        else:
            ldview = c.load_balanced_view()
            result, ipython = ldview.map_sync(function, *args), True

    if say_ipython:
        return result, ipython
    else:
        return result
示例#5
0
文件: init.py 项目: licode/VisTrails
def finalize():
    EngineManager.cleanup()
示例#6
0
current_time = lambda: int(round(time.time() * 1000))
config_dict = get_config_dict('config.yaml')
'''
Create data access object.
This object will be used by all classes through out the project
to add, update or search in the database
'''
#dao = Dao('postgres:321', 'orchestrator')
'''
Engine manager is created here.
Engine manager will manage all the engines created 
Engine manager adds data to database, later engines accesses those data
'''
buildings = rg.generate_buildings(config_dict.get('number_blocks'))
city_map = rg.create_adjacency_list_buildings(list(buildings))
engine_mngr = EngineManager(city_map)
'''
Resource pool is created here. 
Callback function of engine manage is gived here, so that when new 
resources arrive it calls the engine manage to make the entry into the db
'''
resourcepool = ResourcePool(engine_mngr.place_blocks,
                            engine_mngr.update_blocks)
'''
Service pool is created here. 
Callback function of engine manage is gived here, so that when new 
service arrives it calls the engine manager for scheduling
'''
servicepool = ServicePool(engine_mngr.place_service,
                          engine_mngr.wait_for_finish)
'''
示例#7
0
文件: init.py 项目: Nikea/VisTrails
def finalize():
    EngineManager.cleanup()
示例#8
0
from DatabaseAccess import Dao
import time

current_time = lambda: int(round(time.time() * 1000))
'''
Create data access object.
This object will be used by all classes through out the project
to add, update or search in the database
'''
dao = Dao('postgres:321', 'orchestrator')
'''
Engine manager is created here.
Engine manager will manage all the engines created 
Engine manager adds data to database, later engines accesses those data
'''
engine_mngr = EngineManager(dao)
'''
Resource pool is created here. 
Callback function of engine manage is gived here, so that when new 
resources arrive it calls the engine manage to make the entry into the db
'''
resourcepool = ResourcePool(engine_mngr.place_blocks)
'''
Service pool is created here. 
Callback function of engine manage is gived here, so that when new 
service arrives it calls the engine manager for scheduling
'''
servicepool = ServicePool(engine_mngr.place_service)
'''
Resource pool accepts resources here.
It is a high level interface to