Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
103 commits
Select commit Hold shift + click to select a range
d754418
Draft of new main BaseIPythonApplication.
ellisonbg May 18, 2011
8ef4ec5
Updates to config/application.
ellisonbg May 18, 2011
f89956d
Fixing minor bug in config.application.
ellisonbg May 18, 2011
a3caa0b
Fixing bugs in BaseIPythonApplication.
ellisonbg May 18, 2011
1b5d4b7
allow utils.text.indent to [optionally] flatten existing indentation.
minrk May 18, 2011
1e62cdf
include default value in help output
minrk May 19, 2011
71caec7
exit cleanly on help/version
minrk May 20, 2011
311d79c
add `--help-all` flag, and don't print all configurables by default
minrk May 20, 2011
361af6d
update configurable test_help to match new format
minrk May 20, 2011
1748753
raise test log_level, to prevent output during tests
minrk May 20, 2011
5753a65
add subcommand support
minrk May 20, 2011
700d663
make config_file_paths List instead of Unicode
minrk May 21, 2011
6427730
print usage on invalid command-line arguments
minrk May 21, 2011
b40bf51
make subcommands optional
minrk May 21, 2011
dd11d73
add initialize() to BaseIPythonApplication
minrk May 25, 2011
94d9737
reorganize default config files to match profiles as directories
minrk May 25, 2011
3a0676e
Application profiles are now directories
minrk May 25, 2011
e416c1a
fix _profile_changes/d typo in newapplication
minrk May 29, 2011
9bacc77
prevent flags from clobbering entire config sections
minrk May 29, 2011
c4b5fb1
allow extra_args in applications
minrk May 29, 2011
e6715a0
strip whitespace from configurable help
minrk May 30, 2011
dd553fc
allow empty strings in kv_pattern
minrk May 30, 2011
6253af4
add clear_instance() to SingletonConfigurable
minrk Jun 7, 2011
d622ed9
use App.instance() in Application.initialize_subapp
minrk Jun 7, 2011
c9ef4c7
Terminal IPython working with newapp
minrk May 28, 2011
5578040
update config files to match new namespace.
minrk May 30, 2011
cacef55
remove old default config files
minrk May 30, 2011
9e6944d
update docs with new cl-arguments
minrk Jun 1, 2011
783bdda
minor helpstring cleanup per review.
minrk Jun 2, 2011
9bf0859
Split generic part of terminal frontend/terminal/ipapp into core/shel…
minrk Jun 4, 2011
6d4471d
use App.instance() in launch_new_instance
minrk Jun 7, 2011
c5a3579
zmq kernels now started via newapp
minrk May 30, 2011
e4196fb
QtConsole now uses newapp
minrk Jun 1, 2011
8a102b8
qt font family/size configurable
minrk Jun 1, 2011
4c5383b
add InlineBackendConfig
minrk Jun 1, 2011
5e622ef
cleanup channel names to match function not socket
minrk Jun 1, 2011
b77bc75
use Monospace as default font on Linux
minrk Jun 1, 2011
4097157
update docs/default config for qtconsole
minrk Jun 1, 2011
3ffb5e7
expand default_editor message to include configurable
minrk Jun 1, 2011
b9aeee7
update QtConfig section of ipython_config to match actual defaults
minrk Jun 2, 2011
61fead1
IPKernelApp now based on InteractiveShellApp
minrk Jun 4, 2011
ca91d03
use App.instance() in kernel launchers
minrk Jun 7, 2011
c20e80e
use logging instead of `print >>` in pykernel
minrk Jun 9, 2011
9dcf7cd
add qtconsole as subapp of terminal ipapp
minrk Jun 9, 2011
9ab214e
add confirm_exit option to qtconsole to suppress exit dialog
minrk Jun 9, 2011
27e5f25
update pylabtools test to use new print_figure
minrk Jun 10, 2011
ebe5cf5
all ipcluster scripts in some degree of working order with new config
minrk May 18, 2011
e3d7fc2
ipcluster implemented with new subcommands
minrk May 21, 2011
39c98c7
restore auto_create behavior
minrk May 24, 2011
5f4abd1
cleanup parallel traits
minrk May 24, 2011
2e5a116
re-enable log forwarding and iplogger
minrk May 25, 2011
080d3c7
parallel docs, tests, default config updated to newconfig
minrk May 25, 2011
475b2c3
use BaseIPythonApp.load_config, not Application.load_config
minrk May 25, 2011
54eceb8
update parallel apps to use ProfileDir
minrk May 28, 2011
876bf20
rename clusterdir to more descriptive baseapp
minrk May 28, 2011
d551635
remove uneccesary Config objects from flags.
minrk May 30, 2011
b5eb8e4
update default config files with new app namespace
minrk May 30, 2011
26fbd20
cleanup Hub/Scheduler to prevent '%s'%<nonascii> errors
minrk Jun 2, 2011
b550778
fix %px magic output for single target
minrk Jun 7, 2011
80c7e64
use Context.instance() for default in SessionFactory
minrk Jun 7, 2011
2491bfa
use App.instance() in launch_new_instance (parallel apps)
minrk Jun 7, 2011
59bfd5d
use HMAC digest to sign messages instead of cleartext key
minrk Jun 2, 2011
f33ae76
don't pass profile_dir as kwarg in ipclusterapp
minrk Jun 9, 2011
ce97508
fix SGE jobarray regex
minrk Jun 9, 2011
e783b52
Replace Itpl with str.format in parallel launcher.
takluyver Jun 10, 2011
551fa49
add EvalFormatter for batch system (PBS) launcher templates
minrk Jun 11, 2011
bbc9e72
fix double-encoding of png data
minrk Jun 14, 2011
68691d2
merge IPython.parallel.streamsession into IPython.zmq.session
minrk Jun 8, 2011
0a6d540
reorganize Factory classes to follow relocation of Session object
minrk Jun 8, 2011
bdc1136
handle datetime objects in Session
minrk Jun 8, 2011
ecf8fee
use 'timestamp' datatype for timestamps in sqlitedb
minrk Jun 8, 2011
deb5e7c
don't clobber existing dicts in extract_dates/squash_dates
minrk Jun 11, 2011
a016cea
properly handle nothing to recv in StreamKernel.abort
minrk Jun 11, 2011
710a3b3
get default logger from Application.instance()
minrk Jun 11, 2011
0c25086
allow configuration of packer/unpacker in client
minrk Jun 11, 2011
cf11d28
prevent few remaining db requests from crashing Hub
minrk Jun 11, 2011
82222c3
finish plumbing config to Session objects
minrk Jun 11, 2011
4c910d2
add LoggingConfigurable base class
minrk Jun 14, 2011
7459658
update Session object per review
minrk Jun 14, 2011
9950e71
update recently changed modules with Authors in docstring
minrk Jun 15, 2011
3c996c3
scrub twisted/deferred references from launchers
minrk Jun 15, 2011
7733e3c
wrap helpstring output to 80 cols
minrk Jun 15, 2011
087a201
code updates per review of PR #454
minrk Jun 15, 2011
2bdfb69
rename ipythonqt to qtconsoleapp
minrk Jun 15, 2011
0869c34
rename core.newapplication -> core.application
minrk Jun 15, 2011
4512e66
move ipcluster create|list to `ipython profile create|list`
minrk Jun 15, 2011
cbcdfbc
default config files are automatically generated
minrk Jun 15, 2011
a80225e
`ipython profile` prints profile help
minrk Jun 16, 2011
10dfc1c
Don't try to install IPython.config.default (no longer there).
takluyver Jun 16, 2011
71e6a4a
update zmq dependency to 2.1.4
minrk Jun 16, 2011
2c9bbc2
catch up tests to recent changes
minrk Jun 16, 2011
c335e49
load_subconfig supports profiles
minrk Jun 17, 2011
fe05b94
Fixing --log-level problem in WinHPC job setup.
ellisonbg Jun 18, 2011
b3c5b0c
raise PIDFileError on empty PID file, not ValueError in baseapp
minrk Jun 18, 2011
5a3efb2
dir changed from cluster_iptest to profile_iptest
jenshnielsen Jun 20, 2011
f7c3a49
move coding declaration above docstring in test_view
minrk Jun 20, 2011
bf600d5
Do not flatten unicode on unpacking
takluyver Jun 20, 2011
fdbd582
move rekey to jsonutil from parallel.util
minrk Jun 20, 2011
02e639e
don't print full old-config message for each old config file
minrk Jun 20, 2011
e6accb8
rename '--cluster' flag to '--parallel' in ProfileApp
minrk Jun 20, 2011
b6c5bfb
fix setting log_level by name in Application
minrk Jun 20, 2011
158cc42
update config docs with recent changes
minrk Jun 20, 2011
2b56c84
don't display profile in banner if default
minrk Jun 21, 2011
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
281 changes: 222 additions & 59 deletions IPython/config/application.py

Large diffs are not rendered by default.

130 changes: 110 additions & 20 deletions IPython/config/configurable.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@

* Brian Granger
* Fernando Perez
* Min RK
"""

#-----------------------------------------------------------------------------
# Copyright (C) 2008-2010 The IPython Development Team
# 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.
Expand All @@ -20,12 +21,12 @@
# Imports
#-----------------------------------------------------------------------------

from copy import deepcopy
import datetime
from copy import deepcopy

from loader import Config
from IPython.utils.traitlets import HasTraits, Instance
from IPython.utils.text import indent
from IPython.utils.text import indent, wrap_paragraphs


#-----------------------------------------------------------------------------
Expand All @@ -44,14 +45,13 @@ class MultipleInstanceError(ConfigurableError):
# Configurable implementation
#-----------------------------------------------------------------------------


class Configurable(HasTraits):

config = Instance(Config,(),{})
created = None

def __init__(self, **kwargs):
"""Create a conigurable given a config config.
"""Create a configurable given a config config.

Parameters
----------
Expand Down Expand Up @@ -146,18 +146,72 @@ def class_get_help(cls):
final_help = []
final_help.append(u'%s options' % cls.__name__)
final_help.append(len(final_help[0])*u'-')
for k, v in cls_traits.items():
help = v.get_metadata('help')
header = "%s.%s : %s" % (cls.__name__, k, v.__class__.__name__)
final_help.append(header)
if help is not None:
final_help.append(indent(help))
for k,v in cls.class_traits(config=True).iteritems():
help = cls.class_get_trait_help(v)
final_help.append(help)
return '\n'.join(final_help)

@classmethod
def class_get_trait_help(cls, trait):
"""Get the help string for a single trait."""
lines = []
header = "%s.%s : %s" % (cls.__name__, trait.name, trait.__class__.__name__)
lines.append(header)
try:
dvr = repr(trait.get_default_value())
except Exception:
dvr = None # ignore defaults we can't construct
if dvr is not None:
if len(dvr) > 64:
dvr = dvr[:61]+'...'
lines.append(indent('Default: %s'%dvr, 4))
if 'Enum' in trait.__class__.__name__:
# include Enum choices
lines.append(indent('Choices: %r'%(trait.values,)))

help = trait.get_metadata('help')
if help is not None:
help = '\n'.join(wrap_paragraphs(help, 76))
lines.append(indent(help, 4))
return '\n'.join(lines)

@classmethod
def class_print_help(cls):
"""Get the help string for a single trait and print it."""
print cls.class_get_help()

@classmethod
def class_config_section(cls):
"""Get the config class config section"""
def c(s):
"""return a commented, wrapped block."""
s = '\n\n'.join(wrap_paragraphs(s, 78))

return '# ' + s.replace('\n', '\n# ')

# section header
breaker = '#' + '-'*78
s = "# %s configuration"%cls.__name__
lines = [breaker, s, breaker, '']
# get the description trait
desc = cls.class_traits().get('description')
if desc:
desc = desc.default_value
else:
# no description trait, use __doc__
desc = getattr(cls, '__doc__', '')
if desc:
lines.append(c(desc))
lines.append('')

for name,trait in cls.class_traits(config=True).iteritems():
help = trait.get_metadata('help') or ''
lines.append(c(help))
lines.append('# c.%s.%s = %r'%(cls.__name__, name, trait.get_default_value()))
lines.append('')
return '\n'.join(lines)



class SingletonConfigurable(Configurable):
"""A configurable that only allows one instance.
Expand All @@ -168,7 +222,32 @@ class SingletonConfigurable(Configurable):
"""

_instance = None


@classmethod
def _walk_mro(cls):
"""Walk the cls.mro() for parent classes that are also singletons

For use in instance()
"""

for subclass in cls.mro():
if issubclass(cls, subclass) and \
issubclass(subclass, SingletonConfigurable) and \
subclass != SingletonConfigurable:
yield subclass

@classmethod
def clear_instance(cls):
"""unset _instance for this class and singleton parents.
"""
if not cls.initialized():
return
for subclass in cls._walk_mro():
if isinstance(subclass._instance, cls):
# only clear instances that are instances
# of the calling class
subclass._instance = None

@classmethod
def instance(cls, *args, **kwargs):
"""Returns a global instance of this class.
Expand Down Expand Up @@ -202,14 +281,10 @@ def instance(cls, *args, **kwargs):
if cls._instance is None:
inst = cls(*args, **kwargs)
# Now make sure that the instance will also be returned by
# the subclasses instance attribute.
for subclass in cls.mro():
if issubclass(cls, subclass) and \
issubclass(subclass, SingletonConfigurable) and \
subclass != SingletonConfigurable:
subclass._instance = inst
else:
break
# parent classes' _instance attribute.
for subclass in cls._walk_mro():
subclass._instance = inst

if isinstance(cls._instance, cls):
return cls._instance
else:
Expand All @@ -223,3 +298,18 @@ def initialized(cls):
"""Has an instance been created?"""
return hasattr(cls, "_instance") and cls._instance is not None


class LoggingConfigurable(Configurable):
"""A parent class for Configurables that log.

Subclasses have a log trait, and the default behavior
is to get the logger from the currently running Application
via Application.instance().log.
"""

log = Instance('logging.Logger')
def _log_default(self):
from IPython.config.application import Application
return Application.instance().log


Empty file removed IPython/config/default/__init__.py
Empty file.
Loading