Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed output magic message when backend unavailable #1045

Merged
merged 4 commits into from
Jan 10, 2017
Merged
Changes from 3 commits
Commits
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
2 changes: 1 addition & 1 deletion holoviews/ipython/__init__.py
Original file line number Diff line number Diff line change
@@ -186,7 +186,7 @@ def __call__(self, *args, **params):
ip = get_ipython() if ip is None else ip # noqa (get_ipython)
param_ext.load_ipython_extension(ip, verbose=False)
load_magics(ip)
OutputMagic.initialize()
OutputMagic.initialize(list( self._backends.keys()))
set_display_hooks(ip)
notebook_extension._loaded = True

21 changes: 18 additions & 3 deletions holoviews/ipython/magics.py
Original file line number Diff line number Diff line change
@@ -256,11 +256,23 @@ class OutputMagic(OptionsMagic):
#==========================#

last_backend = None
backend_list = [] # List of possible backends

def missing_dependency_exception(value, keyword, allowed):
raise Exception("Format %r does not appear to be supported." % value)

custom_exceptions = {'holomap':missing_dependency_exception}
def missing_backend_exception(value, keyword, allowed):
if value in OutputMagic.backend_list:
raise ValueError("Backend %r not available. Has it been loaded with the notebook_extension?" % value)
else:
raise ValueError("Backend %r does not exist" % value)


raise ValueError(OutputMagic.backend_list, value)
# raise ValueError("Backend %r not available. Has it been loaded with the notebook_extension?" % value)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stray comment?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!


custom_exceptions = {'holomap':missing_dependency_exception,
'backend': missing_backend_exception }

# Counter for nbagg figures
nbagg_counter = 0
@@ -360,7 +372,9 @@ def update_options(cls, options, items):
prev_backend = Store.current_backend
renderer = Store.renderers[Store.current_backend]
prev_backend += ':%s' % renderer.mode
if not backend or backend == prev_backend:

available = backend in Store.renderers.keys()
if (not backend) or (not available) or backend == prev_backend:
return options

cls._backend_options[prev_backend] = cls.options
@@ -392,7 +406,8 @@ def update_options(cls, options, items):


@classmethod
def initialize(cls):
def initialize(cls, backend_list):
cls.backend_list = backend_list
backend = cls.options.get('backend', cls.defaults['backend'])
if backend in Store.renderers:
cls.options = dict(cls.defaults)