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

Export archive #280

Closed
vascotenner opened this issue Oct 8, 2015 · 14 comments
Closed

Export archive #280

vascotenner opened this issue Oct 8, 2015 · 14 comments
Assignees
Milestone

Comments

@vascotenner
Copy link
Contributor

I cannot get export an archive. No files are exported:

import holoviews as hv
%load_ext holoviews.ipython
import numpy as np
from holoviews.ipython import display_hooks
display_hooks.ABBREVIATE_TRACEBACKS=False
hv.archive.auto()

Automatic capture is now enabled. [2015-10-08 09:47:07]

%%opts ErrorBars [yrotation=15, xrotation=45]
hv.ErrorBars((0,1,.5,3))
WARNING:root:ErrorBars01244: Could not pickle custom style information.

+image

hv.archive.export()
Export name: '{notebook}'
Directory    '/media/data2/tenner/data/ipython-notebooks'

If no output appears, please check holoviews.archive.last_export_status()
hv.archive.last_export_status()
Status of the last call to holoviews.archive.export is unknown.
(Re-execute this method once kernel status is idle.)
hv.archive.contents()
ErrorBars.svg : image/svg+xml
ErrorBars.hvz : application/zip
@jlstevens
Copy link
Contributor

Thanks for reporting this! I'll have to look into it...

@philippjfr
Copy link
Member

Yes, thanks I meant to file an issue about problems with archiving myself but forgot about it. Here's a related issue: ioam/topographica#631

@philippjfr philippjfr added this to the v1.4.0 milestone Oct 14, 2015
@philippjfr philippjfr mentioned this issue Nov 10, 2015
42 tasks
@vascotenner
Copy link
Contributor Author

The export is not totally fixed in #284. When I run the Exporting tutorial, it does not export in cell 13. Also hv.archive.last_export_status() does not give usefull output. However, when I add the lines:

holoviews = hv
holoviews.archive.export()

It exports the data, but in the directory {notebook}, instead of Exporting.

hv.archive.last_export_status() now gives the right output.

This goes wrong because the namespace variable is wrong in holoviews/ipyhton/archive.py:69

This namespace is then used on line 139 and 162

@philippjfr philippjfr assigned philippjfr and jlstevens and unassigned philippjfr Nov 23, 2015
@philippjfr
Copy link
Member

Thanks, for looking into this. We're trying to get a release candidate out by the end of this week, so hopefully @jlstevens will get to this issue soon.

@jlstevens
Copy link
Contributor

I've finally had a chance to have a look...

I suspect the issue is that IPython/Jupyter have changed their JavaScript API needed for the fancier parts of the export (trying to get the notebook name and capturing the active notebook). If in the tutorial, you set the options like this instead:

hv.archive.auto(skip_notebook_export=True, export_name='Exporting')

Then it works again. I feel we ought to document this in the tutorial - I don't like the Javascript code we are using and I don't trust it not to break between Jupyter releases.

Anyway, I've just found the issue - we used to do import holoviews but now we do import holoviews as hv. This is up to the user but breaks the Python/Javascript link as the Javascript tries to set data on holoviews.archive which doesn't exist if you imported as hv (this is extremely fragile but I haven't found a more robust way!). This also works:

hv.archive.auto(namespace='hv.archive')

We could:

  1. Change the namespace default to hv.archive
  2. Document this issue in the tutorial
  3. Somehow try to use both common forms (i.e try testing holoviews or hv). Or maybe you can do something fancy as I can use IPython to see what is defined in the notebook namespace - I could see if something called 'hv' or 'holoviews' is defined as assume it is actually holoviews!

I would recommend a combination of 1. and 2. - set the default to hv and state in the tutorial that if you import holoviews some other way, it won't work. What are your thoughts on this?

@philippjfr
Copy link
Member

I'd just consistently move to using hv as that is now our recommendation and document that in the Exporting Tutorial.

@jlstevens
Copy link
Contributor

Ok, the change to the default is implemented in 8037a29. The tutorial is updated in 2ca621e.

I am happy to hear any suggestions on how to make the tutorial clearer. I'll close the issue now, but if @vascotenner has any comments on further improvements, I'll reopen the issue and we can discuss them.

@jbednar
Copy link
Member

jbednar commented Nov 30, 2015

This sounds very fragile. Can the current module name be provided to Javascript from Python initially? Otherwise, can Javascript at least try both "holoviews" and "hv"?

@vascotenner
Copy link
Contributor Author

Or maybe always print a "warning" when enabling archiving, that the hv modules should be imported or renamed to hv or holoviews.

The main problem here, is that the ipython kernel does not know it is run from a notebook or a shell or something else.

@jlstevens
Copy link
Contributor

I have this quick hack that might do the job:

import sys
def get_namespace():
    if 'holoviews' not in sys.modules:
        raise ImportError('HoloViews does not seem to be imported')
    matches = [k for k,v in globals().items()
       if not k.startswith('_') and v == sys.modules['holoviews']]
    return matches[0] if len(matches) > 0 else None

This should be run when auto is called and may fix the problem. If not, I agree with @vascotenner that a warning would help.

Edit: I have to use get_ipython().user_ns.items() instead of globals but this does seem to work!

@philippjfr
Copy link
Member

Can't we simply add a import holoviews when calling the Python kernel from JS?

@jlstevens
Copy link
Contributor

Ok, I seem to have it working nicely in 5bab92b - I can find the name the user has available to access holoviews and remove the fragile namespace parameter entirely.

Now I need to revert my change to the tutorial....

@jbednar
Copy link
Member

jbednar commented Nov 30, 2015

Looks much less fragile, thanks.

Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 25, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants