ansible / ansible-jupyter-kernel

Jupyter Notebook Kernel for running Ansible Tasks and Playbooks
Other
534 stars 62 forks source link

No ansible export choices in jupyter lab #50

Closed ShadowMitia closed 6 years ago

ShadowMitia commented 6 years ago

Describe the bug When running a jupyter notebook (with jupyter notebook command), there available ansible exports in File -> Download As.

When running jupyterlab (with jupyter lab command), the menu is called Exports, and doesn't contain ansible exports choices.

To Reproduce Steps to reproduce the behavior:

  1. Install jupyterlab and jupyter-kernel using pip3 (pip3 install jupyterlab ansible-kernel) 2 Launch jupyter lab
  2. Open or create an ansible notebook
  3. Go to File -> Export Notebook As
  4. Menu has a missing "ansible playboook" export item

Expected behavior In jupyterlab there should be an option to export notebook as ansible playbooks.

Screenshots

Expected behaviour in jupyter notebook: screenshot from 2018-07-25 09-50-28

Missing menu item in jupyterlab: screenshot from 2018-07-25 09-50-43

Desktop (please complete the following information):

benthomasson commented 6 years ago

To recreate this issue please include the versions of Jupyter Notebook, Jupyter Lab, and Ansible Kernel that you have installed. Please also include the steps that you used to install Ansible Kernel.

ShadowMitia commented 6 years ago

@benthomasson I edited my message. Sorry about that.

benthomasson commented 6 years ago

It looks like the way that adding custom exporters changed in Jupyter Lab from Jupyter Notebook. I'll look into supporting Jupyter Lab.

benthomasson commented 6 years ago

Your first screen shot for jupyter notebook is missing a few exporters. Try running this command python -m ansible_kernel.install --sys-prefix to enable them.

From the command line you should see:

$ jupyter nbconvert -h | grep ansible
    Options include ['ansible_playbook', 'ansible_tasks', 'ansible_zip', 'asciidoc', 'custom', 'html', 'latex', 'markdown', 'notebook', 'pdf', 'python', 'rst', 'script', 'slides']
benthomasson commented 6 years ago

Unfortunately the list of exporters appears to be hardcoded in this version of Jupyter Lab. I manually add the exporters on this branch: https://github.com/benthomasson/jupyterlab/tree/ansible_exporters

If you want to try this out run this:

git clone https://github.com/benthomasson/jupyterlab.git
cd jupyterlab
git checkout ansible_exporters
pip install -e .
jlpm install
jlpm run build
jlpm run build:core 
jupyter lab build 
jupyter lab --dev-mode
ShadowMitia commented 6 years ago

I tried testing your branch, but I think I have something wrong with my jupyter installation, when running jupyter lab --dev-mode it fails to launch with a FileNotFoundError: [Errno 2] No such file or directory: '/home/dimitri/.local/lib/python3.6/site-packages/packages/theme-light-extension': '/home/dimitri/.local/lib/python3.6/site-packages/packages/theme-light-extension'.

I'll just have to remember to test this kernel in the notebook in the meantime.

Thank you for the quick response! Hope they'll fix this harcoded exports list business soon.

benthomasson commented 6 years ago

I ran into the same issue. Try running pip install -e . again in the jupyterlab directory.

ShadowMitia commented 6 years ago

You mean the one inside the cloned folder? I get this message: Directory '.' is not installable. File 'setup.py' not found.

benthomasson commented 6 years ago

Try the parent directory. There should be a setup.py there.

ShadowMitia commented 6 years ago

I managed to make it work by using pip3 install --user -e . (I was using sudo before). Finally I can see the exports!

Thanks!

benthomasson commented 6 years ago

I added a feature request for this in JupyterLab here: jupyterlab/jupyterlab#5015