danielballan / nbexamples

distribute notebooks for users to copy via a web interface
Other
69 stars 23 forks source link

Clicking on "share as example" button does not copy notebook to dir in config #29

Closed sheriferson closed 7 years ago

sheriferson commented 7 years ago

Hi, I'm hoping I'm missing something obvious in configuration that would fix my issue.

I'm running nbexamples with JupyterHub. I have the following two directories:

/opt/notebooks/reviewed/
/opt/notebooks/unreviewed/

and I tried to set them as the sharing directories for nbexamples both in jupyterhub_config.py and jupyter_notebook_config.py like so:

c.Examples.reviewed_example_dir = '/opt/notebooks/reviewed'
c.Examples.unreviewed_example_dir = '/opt/notebooks/unreviewed'

However, clicking on the paper airplane button seems to add the notebook I'm working on the list of shared Examples (by 'seems' I mean that the notebook then becomes listed), but the notebook does not get copied to either one of the directories listed above.

Also, any other users who log in to JupyterHub don't see anything listed under the Examples tab. Only I see the shared notebook.

Also, manually copying a notebook file to one of those directories doesn't make it visible or available to any other logged in JupyterHub users.

Am I missing a configuration or tweak somewhere? I'm happy to share any config information that might help diagnose the problem.

Thanks.

parente commented 7 years ago

You need to pass the nbexamples configuration through the spawner args in your jupyter_config.py. Your install is probably using the current working directory as the default path for both reviewed and unreviewed examples at the moment. When you share a notebook, it's basically being copied over itself and still appears in the Examples tab.

# Extra arguments to be passed to the single-user server
c.Spawner.args = [
    '--Examples.reviewed_example_dir="/opt/notebooks/reviewed"',
    '--Examples.unreviewed_example_dir="/opt/notebooks/unreviewed"'
]
sheriferson commented 7 years ago

Ah, that works. I'm still understanding the architecture of JupyterHub and spawners, so this makes sense in hindsight. Thanks!