##// END OF EJS Templates
Merge pull request #1759 from Carreau/mpr...
Merge pull request #1759 from Carreau/mpr Add git-mpr, to merge PR(s) from github just by number(s). Inspired by git-mrb and test_pr, I thougth it would be usefull to be able to merge PR only by giving their number. Hence `git merge-pull-request`or `git-mpr`. usage: ```bash $ git mpr -h ~/ipython/tools usage: git-mpr [-h] [-l | -a | -m [pr-number [pr-number ...]]] Merge (one|many) github pull request by their number. If pull request can't be merge as is, cancel merge, and continue to the next if any. optional arguments: -h, --help show this help message and exit -l, --list list PR, their number and their mergeability -a, --merge-all try to merge as many PR as possible, one by one -m [pr-number [pr-number ...]], --merge [pr-number [pr-number ...]] The pull request numbers ``` examples : ```bash $ git mpr --list * #1758 [√]: test_pr, fallback on http if git protocol fail, and SSL errors... * #1755 [√]: test for pygments before running qt tests * #1715 [√]: Fix for #1688, traceback-unicode issue [...] * #1493 [√]: Selenium web tests proof-of-concept * #1471 [ ]: simplify IPython.parallel connections and enable Controller Resume * #1343 [ ]: Add prototype shutdown button to Notebook dashboard * #1285 [√]: Implementation of grepping the input history using several patterns * #1215 [√]: updated %quickref to show short-hand for %sc and %sx ``` PR number, mergeability and title Quite slow, as it does 1 api call by PR, since api does not give mergeability anymore if you ask for the list of all PRs at once. merge one or more PR (skip the ones with conflict and present a nice list to copy and past to do it by hand) ```bash $ git mpr --merge [pr-number [pr-number ...]]] [...] ************************************************************************************* the following branch have not been merged automatically, considere doing it by hand : PR 1630: git pull https://github.com/minrk/ipython.git mergekernel PR 1343: git pull https://github.com/takluyver/ipython.git notebook-shutdown PR 1715: git pull https://github.com/jstenar/ipython.git ultratb-pycolorize-unicode PR 1732: git pull https://github.com/fperez/ipython.git cellmagics PR 1471: git pull https://github.com/minrk/ipython.git connection PR 1674: git pull https://github.com/mdboom/ipython.git notebook-carriage-return ************************************************************************************* ``` And last, ``` git mpr --merge-all ``` That is pretty self explainatory

File last commit:

r6883:d2f71ea5
r7531:029bbad1 merge
Show More
clustermanager.py
172 lines | 5.7 KiB | text/x-python | PythonLexer
"""Manage IPython.parallel clusters in the notebook.
Authors:
* Brian Granger
"""
#-----------------------------------------------------------------------------
# Copyright (C) 2008-2011 The IPython Development Team
#
# Distributed under the terms of the BSD License. The full license is in
# the file COPYING, distributed as part of this software.
#-----------------------------------------------------------------------------
#-----------------------------------------------------------------------------
# Imports
#-----------------------------------------------------------------------------
import os
from tornado import web
from zmq.eventloop import ioloop
from IPython.config.configurable import LoggingConfigurable
from IPython.config.loader import load_pyconfig_files
from IPython.utils.traitlets import Dict, Instance, CFloat
from IPython.parallel.apps.ipclusterapp import IPClusterStart
from IPython.core.profileapp import list_profiles_in
from IPython.core.profiledir import ProfileDir
from IPython.utils.path import get_ipython_dir
from IPython.utils.sysinfo import num_cpus
#-----------------------------------------------------------------------------
# Classes
#-----------------------------------------------------------------------------
class DummyIPClusterStart(IPClusterStart):
"""Dummy subclass to skip init steps that conflict with global app.
Instantiating and initializing this class should result in fully configured
launchers, but no other side effects or state.
"""
def init_signal(self):
pass
def reinit_logging(self):
pass
class ClusterManager(LoggingConfigurable):
profiles = Dict()
delay = CFloat(1., config=True,
help="delay (in s) between starting the controller and the engines")
loop = Instance('zmq.eventloop.ioloop.IOLoop')
def _loop_default(self):
from zmq.eventloop.ioloop import IOLoop
return IOLoop.instance()
def build_launchers(self, profile_dir):
starter = DummyIPClusterStart(log=self.log)
starter.initialize(['--profile-dir', profile_dir])
cl = starter.controller_launcher
esl = starter.engine_launcher
n = starter.n
return cl, esl, n
def get_profile_dir(self, name, path):
p = ProfileDir.find_profile_dir_by_name(path,name=name)
return p.location
def update_profiles(self):
"""List all profiles in the ipython_dir and cwd.
"""
for path in [get_ipython_dir(), os.getcwdu()]:
for profile in list_profiles_in(path):
pd = self.get_profile_dir(profile, path)
if profile not in self.profiles:
self.log.debug("Overwriting profile %s" % profile)
self.profiles[profile] = {
'profile': profile,
'profile_dir': pd,
'status': 'stopped'
}
def list_profiles(self):
self.update_profiles()
result = [self.profile_info(p) for p in sorted(self.profiles.keys())]
return result
def check_profile(self, profile):
if profile not in self.profiles:
raise web.HTTPError(404, u'profile not found')
def profile_info(self, profile):
self.check_profile(profile)
result = {}
data = self.profiles.get(profile)
result['profile'] = profile
result['profile_dir'] = data['profile_dir']
result['status'] = data['status']
if 'n' in data:
result['n'] = data['n']
return result
def start_cluster(self, profile, n=None):
"""Start a cluster for a given profile."""
self.check_profile(profile)
data = self.profiles[profile]
if data['status'] == 'running':
raise web.HTTPError(409, u'cluster already running')
cl, esl, default_n = self.build_launchers(data['profile_dir'])
n = n if n is not None else default_n
def clean_data():
data.pop('controller_launcher',None)
data.pop('engine_set_launcher',None)
data.pop('n',None)
data['status'] = 'stopped'
def engines_stopped(r):
self.log.debug('Engines stopped')
if cl.running:
cl.stop()
clean_data()
esl.on_stop(engines_stopped)
def controller_stopped(r):
self.log.debug('Controller stopped')
if esl.running:
esl.stop()
clean_data()
cl.on_stop(controller_stopped)
dc = ioloop.DelayedCallback(lambda: cl.start(), 0, self.loop)
dc.start()
dc = ioloop.DelayedCallback(lambda: esl.start(n), 1000*self.delay, self.loop)
dc.start()
self.log.debug('Cluster started')
data['controller_launcher'] = cl
data['engine_set_launcher'] = esl
data['n'] = n
data['status'] = 'running'
return self.profile_info(profile)
def stop_cluster(self, profile):
"""Stop a cluster for a given profile."""
self.check_profile(profile)
data = self.profiles[profile]
if data['status'] == 'stopped':
raise web.HTTPError(409, u'cluster not running')
data = self.profiles[profile]
cl = data['controller_launcher']
esl = data['engine_set_launcher']
if cl.running:
cl.stop()
if esl.running:
esl.stop()
# Return a temp info dict, the real one is updated in the on_stop
# logic above.
result = {
'profile': data['profile'],
'profile_dir': data['profile_dir'],
'status': 'stopped'
}
return result
def stop_all_clusters(self):
for p in self.profiles.keys():
self.stop_cluster(p)